Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple LAMMPS GUI using Qt library #3870

Merged
merged 108 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
b87ced5
first minimal stab at LAMMPS GUI
akohlmey Jul 24, 2023
a49a1b6
update main widget to CodeEditor with line numbers and highlight. Ope…
akohlmey Jul 25, 2023
908e925
add minimal about dialogs
akohlmey Jul 25, 2023
a402d2c
simplify, move redundant operations to functions, update coding style
akohlmey Jul 25, 2023
4fd648c
add copyright message
akohlmey Jul 25, 2023
5d1251d
properly canonicalize filename
akohlmey Jul 25, 2023
5da4626
add menu hotkeys and shortcuts
akohlmey Jul 25, 2023
7eb2afa
integrate syntax highlight code from example (uses c++ syntax currently)
akohlmey Jul 25, 2023
276b893
add global error message buffer for exceptions creating a LAMMPS inst…
akohlmey Jul 25, 2023
ab792ac
catch errors via library interface and present dialog displaying them
akohlmey Jul 25, 2023
5d34cc6
temporarily disable highlighting a line
akohlmey Jul 25, 2023
8b91748
capture stdout and display in dialog window
akohlmey Jul 25, 2023
6e0aaab
first stab at LAMMPS input file syntax highlighting
akohlmey Jul 26, 2023
e4dde8e
fix shortcut implementation for log windows
akohlmey Jul 26, 2023
e548c0b
add todo list
akohlmey Jul 26, 2023
984a311
make compatible with windows cross-compiler
akohlmey Jul 26, 2023
e6dc582
more flexible font search
akohlmey Jul 26, 2023
89b92e8
make "warning" boxes on errors "critical"
akohlmey Jul 26, 2023
c96e4d5
print more config info in about dialog
akohlmey Jul 26, 2023
cde3328
update todo list
akohlmey Jul 26, 2023
3287d79
tweak/correct highlighting
akohlmey Jul 26, 2023
0120c7b
add permanent text field for status to status bar
akohlmey Jul 26, 2023
e0ed11a
add option to load LAMMPS library dynamically at runtime as plugin
akohlmey Jul 26, 2023
1698587
add a readme file
akohlmey Jul 26, 2023
f3e54ca
small layout tweaks
akohlmey Jul 26, 2023
a62d1be
add icons to menu bar
akohlmey Jul 27, 2023
da0669d
implement running LAMMPS asynchonously in a separate thread
akohlmey Jul 27, 2023
f81ee57
add button to stop a run via lammps_force_timeout()
akohlmey Jul 27, 2023
056c608
portability to macOS
akohlmey Jul 27, 2023
1697d1e
embed font and icon and make use of them
akohlmey Jul 27, 2023
a2657c6
fix typo
akohlmey Jul 27, 2023
dd25bac
fix typo in plugin interface API
akohlmey Jul 27, 2023
2644c06
update version number and "about info" to also show whether LAMMPS wa…
akohlmey Jul 27, 2023
f170d8a
update todo list
akohlmey Jul 27, 2023
034b745
add dummy help menu button
akohlmey Jul 27, 2023
e6e5be4
move initialization of plugin before opening input
akohlmey Jul 27, 2023
2da71bd
improve cmake settings for creating an app bundle
akohlmey Jul 28, 2023
7a9694b
update TODO file
akohlmey Jul 28, 2023
c1d690d
implement drag-n-drop for files
akohlmey Jul 28, 2023
bb96707
add support for "modified" indicator to window title
akohlmey Jul 28, 2023
cb5470e
add dialog checking whether to discard changes in a modified buffer
akohlmey Jul 28, 2023
62ec8e7
WIP on preferences dialog
akohlmey Jul 29, 2023
d9f4ce0
integrate packaging related changes, build script for GUI
akohlmey Jul 30, 2023
a250371
Merge branch 'lammps-gui' of github.com:akohlmey/lammps into lammps-gui
akohlmey Jul 30, 2023
81790e1
update DMG installer background image with instructions
akohlmey Jul 30, 2023
2d6ae69
include updates from @rbberger
akohlmey Jul 30, 2023
b376638
fixup rpath for lmp executable so it can find libomp
akohlmey Jul 30, 2023
e23176d
no more rpath fixing needed. add icon to disk image
akohlmey Jul 30, 2023
05c8d26
use OpenMP with maximum number of threads by default
akohlmey Jul 30, 2023
ac91634
minor layout and behavior tweaks
akohlmey Jul 30, 2023
080d868
mention setting QT_FONT_DPI in README file since it has no effect in …
akohlmey Jul 30, 2023
9e5dcfc
update for packaging a .dmg file w/o CPack (untested)
akohlmey Jul 30, 2023
12fee35
fix bugs and typos
akohlmey Jul 30, 2023
93b2f24
update installer background image
akohlmey Jul 30, 2023
2eca0f2
Merge branch 'lammps-gui' of github.com:akohlmey/lammps into lammps-gui
akohlmey Jul 30, 2023
1c8b9e9
Windos portability
akohlmey Jul 30, 2023
c95bf2c
add image viewer dialog for write_dump image output, help can open li…
akohlmey Jul 30, 2023
e899a07
Show current working directory and share space with progress bar. Sho…
akohlmey Jul 31, 2023
6d58910
Add new VS configuration for compiling LAMMPS GUI
akohlmey Jul 31, 2023
72ea267
update LAMMPS manual and README file
akohlmey Jul 31, 2023
75254bf
simplify. only look for Qt5 at the moment.
akohlmey Jul 31, 2023
cadc45d
implement quick help dialog
akohlmey Jul 31, 2023
68454b3
small help window tweak
akohlmey Jul 31, 2023
0a01842
custom message box is more readable and wider
akohlmey Jul 31, 2023
2f159df
changes for portability with Qt 5.12 on Ubuntu 20.04LTS
akohlmey Jul 31, 2023
d41bf62
display number of threads in use for LAMMPS instance in status bar
akohlmey Jul 31, 2023
b5a5cf1
support zooming image with mousewheel
akohlmey Jul 31, 2023
49d411e
update
akohlmey Jul 31, 2023
33e893d
cleanup. must include lammps-gui in install targets. windows cross-de…
akohlmey Jul 31, 2023
fbf05fb
copy runtime libs/dlls during install
akohlmey Aug 1, 2023
be9d246
install runtime deps on Linux
akohlmey Aug 1, 2023
5fdeefe
Linux deployment script
akohlmey Aug 1, 2023
349cf72
various tweaks, remove debug info, delete backward system libs
akohlmey Aug 1, 2023
0d7687c
strip debug info only on files, not symlinks. get deps for Qt platfor…
akohlmey Aug 1, 2023
488b4d4
fix minor issues
akohlmey Aug 1, 2023
418b2c3
integrate wrapper script for linux
akohlmey Aug 1, 2023
6b50daf
Merge branch 'collected-small-fixes' into lammps-gui
akohlmey Aug 1, 2023
89b205a
must use tar to preserve symlinks
akohlmey Aug 1, 2023
44cec03
set environment variables to find potentials and frc files
akohlmey Aug 1, 2023
d38ec56
more tweaks. avoid warnings. get dependencies for imageformats.
akohlmey Aug 1, 2023
b67de91
rename script
akohlmey Aug 1, 2023
1f829dd
ignore install folder created by VS
akohlmey Aug 1, 2023
b9682fc
zip file packaging for windows
akohlmey Aug 1, 2023
fd9af7d
this is packaging/install for visual studio only
akohlmey Aug 1, 2023
f2bc41a
we should be ok with CMake 3.16 as minimum version again.
akohlmey Aug 1, 2023
4f1946f
update LAMMPS GUI docs
akohlmey Aug 1, 2023
f1cda32
make it LAMMPS GUI version 1.0.0 since we're including it in the stab…
akohlmey Aug 1, 2023
f76300c
do not build packages automatically but use explicit targets
akohlmey Aug 2, 2023
310ede6
apply coding standard checks
akohlmey Aug 2, 2023
8a53c66
refactor. add LammpsWrapper class to hide plugin defines and interfac…
akohlmey Aug 2, 2023
1fa2060
Merge remote-tracking branch 'github/develop' into lammps-gui
akohlmey Aug 2, 2023
c99d0f5
cmake cleanups
akohlmey Aug 2, 2023
c918bde
fix a couple of bugs that would hang the app waiting for log output
akohlmey Aug 2, 2023
56b50d6
ensure final newline when saving to file
akohlmey Aug 2, 2023
dfb614b
fix memory leak
akohlmey Aug 2, 2023
2711917
grammar
akohlmey Aug 2, 2023
dfcd3f9
first pieces of preferences dialog
akohlmey Aug 2, 2023
e493519
more hotkeys and have Ok/Cancel on preferences dialog handled properly
akohlmey Aug 2, 2023
97d406f
update TODO list with some new ideas
akohlmey Aug 2, 2023
2808a78
more updates to preferences dialog and supporting code. almost done.
akohlmey Aug 2, 2023
c800a2c
add menu entry to reset to default settings
akohlmey Aug 2, 2023
6f6eb1d
update TODO list
akohlmey Aug 2, 2023
07b3602
small doc fix from @sjplimp
akohlmey Aug 2, 2023
f6732f0
support running with Kokkos + OpenMP
akohlmey Aug 3, 2023
2a82ed9
add accelerators for tabs and layout tweaks
akohlmey Aug 3, 2023
3f1f08d
add setting support for selecting the LAMMPS plugin shared object
akohlmey Aug 3, 2023
8d5343e
temporary skip showing broken temp file setting on macOS
akohlmey Aug 3, 2023
3c24e4f
fix typo
akohlmey Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ out/x86
out/x64
src/Makefile.package-e
src/Makefile.package.settings-e
/cmake/build/x64-Debug-Clang
/install/x64-GUI-MSVC
/install
26 changes: 6 additions & 20 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(CMAKE_POSITION_INDEPENDENT_CODE "Create object compatible with shared libraries" ON)
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF)
option(BUILD_LAMMPS_GUI "Build and install the LAMMPS GUI" OFF)

# Support using clang-tidy for C++ files with selected options
set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Include clang-tidy processing when compiling")
Expand Down Expand Up @@ -797,7 +798,7 @@ include(Documentation)
###############################################################################
# Install bench, potential and force field files in data directory
###############################################################################
set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps)
set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/lammps)

install(DIRECTORY ${LAMMPS_DIR}/bench DESTINATION ${LAMMPS_INSTALL_DATADIR})
install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR})
Expand All @@ -808,25 +809,10 @@ endif()
configure_file(etc/profile.d/lammps.sh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh @ONLY)
configure_file(etc/profile.d/lammps.csh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh @ONLY)
install(
FILES ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/profile.d)

if(CMAKE_SYSTEM_NAME STREQUAL "LinuxMUSL")
file(WRITE ${CMAKE_BINARY_DIR}/README.txt
"Statically linked, portable, serial LAMMPS binary archive for x86_64 Linux\n\n")
endif()
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
file(WRITE ${CMAKE_BINARY_DIR}/README.txt
"Multi-arch, serial LAMMPS binary archive for macOS 11 (Big Sur) and later\n\n")
endif()
if((CMAKE_SYSTEM_NAME STREQUAL "LinuxMUSL") OR (APPLE AND CMAKE_OSX_ARCHITECTURES))
file(APPEND ${CMAKE_BINARY_DIR}/README.txt
"Executables are in 'bin', potential files in 'share/lammps/potentials',\n")
file(APPEND ${CMAKE_BINARY_DIR}/README.txt
"benchmark and simple input examples are in 'share/lammps/bench'.\n")
install(FILES ${CMAKE_BINARY_DIR}/README.txt
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
FILES ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh
${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/profile.d
)

###############################################################################
# Install LAMMPS lib and python module into site-packages folder with
Expand Down
53 changes: 53 additions & 0 deletions cmake/CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"name": "ENABLE_TESTING",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_LAMMPS_GUI",
"value": "False",
"type": "BOOL"
}
]
},
Expand Down Expand Up @@ -303,6 +308,54 @@
"type": "STRING"
}
]
},
{
"name": "x64-GUI-MSVC",
"generator": "Ninja",
"configurationType": "Release",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake -D QT_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5 -D Qt5_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5",
"buildCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_TOOLS",
"value": "True",
"type": "BOOL"
},
{
"name": "LAMMPS_EXCEPTIONS",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_MPI",
"value": "False",
"type": "BOOL"
},
{
"name": "WITH_PNG",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_LAMMPS_GUI",
"value": "True",
"type": "BOOL"
}
]
}
]
}
6 changes: 5 additions & 1 deletion cmake/Modules/Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ if(BUILD_LAMMPS_SHELL)
install(FILES ${LAMMPS_TOOLS_DIR}/lammps-shell/lammps-shell.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications/)
endif()


if(BUILD_LAMMPS_GUI)
get_filename_component(LAMMPS_GUI_DIR ${LAMMPS_SOURCE_DIR}/../tools/lammps-gui ABSOLUTE)
get_filename_component(LAMMPS_GUI_BIN ${CMAKE_BINARY_DIR}/lammps-gui-build ABSOLUTE)
add_subdirectory(${LAMMPS_GUI_DIR} ${LAMMPS_GUI_BIN})
endif()
Binary file added cmake/packaging/LAMMPS_DMG_Background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions cmake/packaging/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en-US</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleDisplayName</key>
<string>The LAMMPS Molecular Dynamics Software</string>
<key>CFBundleIconFile</key>
<string>lammps</string>
<key>CFBundleIdentifier</key>
<string>org.lammps.gui</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>LAMMPS</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
</dict>
</plist>
69 changes: 69 additions & 0 deletions cmake/packaging/README.macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
LAMMPS and LAMMPS GUI universal binaries for macOS (arm64/x86_64)
=================================================================

This package provides universal binaries of LAMMPS and LAMMPS GUI that should
run on macOS systems running running macOS version 11 (Big Sur) or newer. Note
the binaries are compiled without MPI support and contain a compatible subset
of the available packages.

The following individual commands are included:
binary2txt lammps-gui lmp msi2lmp phana stl_bin2txt

After copying the lammps-gui folder into your Applications folder, please follow
these steps:

1. Open the Terminal app

2. Type the following command and press ENTER:

open ~/.zprofile

This will open a text editor for modifying the .zprofile file in your home
directory.

3. Add the following lines to the end of the file, save it, and close the editor

LAMMPS_INSTALL_DIR=/Applications/LAMMPS.app/Contents
LAMMPS_POTENTIALS=${LAMMPS_INSTALL_DIR}/share/lammps/potentials
LAMMPS_BENCH_DIR=${LAMMPS_INSTALL_DIR}/share/lammps/bench
MSI2LMP_LIBRARY=${LAMMPS_INSTALL_DIR}/share/lammps/frc_files
PATH=${LAMMPS_INSTALL_DIR}/bin:$PATH
export LAMMPS_POTENTIALS LAMMPS_BENCH_DIR PATH

4. In your existing terminal, type the following command make the settings active

source ~/.zprofile

Note, you don't have to type this in new terminals, since they will apply
the changes from .zprofile automatically.

Note: the above assumes you use the default shell (zsh) that comes with
MacOS. If you customized MacOS to use a different shell, you'll need to modify
that shell's init file (.cshrc, .bashrc, etc.) instead with appropiate commands
to modify the same environment variables.

5. Try running LAMMPS (which might fail, see step 7)

lmp -in ${LAMMPS_BENCH_DIR}/in.lj

6. Try running the LAMMPS GUI

lammps-gui ${LAMMPS_BENCH_DIR}/in.rhodo

Depending on the size and resolution of your screen, the fonts may
be too small to read. This can be adjusted by setting the environment
variable QT_FONT_DPI. The default value would be 72, so to increase
the fonts by a third one can add to the .zprofile file the line

export QT_FONT_DPI=96

and reload as shown above.

7. Give permission to execute the commands (lmp, lammps-gui, msi2lmp, binary2txt, phana, stl_bin2txt)

MacOS will likely block the initial run of the executables, since they
were downloaded from the internet and are missing a known signature from an
identified developer. Go to "Settings" and search for "Security settings". It
should display a message that an executable like "lmp" was blocked. Press
"Open anyway", which might prompt you for your admin credentials. Afterwards
"lmp" and the other executables should work as expected.
77 changes: 77 additions & 0 deletions cmake/packaging/build_linux_tgz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

APP_NAME=lammps-gui
DESTDIR=${PWD}/../LAMMPS_GUI

echo "Delete old files, if they exist"
rm -rf ${DESTDIR} ../LAMMPS-Linux-amd64.tar.gz

echo "Create staging area for deployment and populate"
DESTDIR=${DESTDIR} cmake --install . --prefix "/"

echo "Remove debug info"
for s in ${DESTDIR}/bin/* ${DESTDIR}/lib/liblammps*
do \
test -f $s && strip --strip-debug $s
done

echo "Remove libc, gcc, and X11 related shared libs"
rm -f ${DESTDIR}/lib/ld*.so ${DESTDIR}/lib/ld*.so.[0-9]
rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}.so.?
rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}-[0-9].[0-9]*.so
rm -f ${DESTDIR}/lib/libX* ${DESTDIR}/lib/libxcb*
rm -f ${DESTDIR}/lib/libgcc_s*
rm -f ${DESTDIR}/lib/libstdc++*

# get qt dir
QTDIR=$(ldd ${DESTDIR}/bin/lammps-gui | grep libQt5Core | sed -e 's/^.*=> *//' -e 's/libQt5Core.so.*$/qt5/')
cat > ${DESTDIR}/bin/qt.conf <<EOF
[Paths]
Plugins = ../qt5plugins
EOF

# platform plugin
mkdir -p ${DESTDIR}/qt5plugins/platforms
cp ${QTDIR}/plugins/platforms/libqxcb.so ${DESTDIR}/qt5plugins/platforms

# get platform plugin dependencies
QTDEPS=$(LD_LIBRARY_PATH=${DESTDIR}/lib ldd ${QTDIR}/plugins/platforms/libqxcb.so | grep -v ${DESTDIR} | grep libQt5 | sed -e 's/^.*=> *//' -e 's/\(libQt5.*.so.*\) .*$/\1/')
for dep in ${QTDEPS}
do \
cp ${dep} ${DESTDIR}/lib
done

echo "Add additional plugins for Qt"
for dir in styles imageformats
do \
cp -r ${QTDIR}/plugins/${dir} ${DESTDIR}/qt5plugins/
done

# get imageplugin dependencies
for s in ${DESTDIR}/qt5plugins/imageformats/*.so
do \
QTDEPS=$(LD_LIBRARY_PATH=${DESTDIR}/lib ldd $s | grep -v ${DESTDIR} | grep -E '(libQt5|jpeg)' | sed -e 's/^.*=> *//' -e 's/\(lib.*.so.*\) .*$/\1/')
for dep in ${QTDEPS}
do \
cp ${dep} ${DESTDIR}/lib
done
done

echo "Set up wrapper script"
MYDIR=$(dirname "$0")
cp ${MYDIR}/linux_wrapper.sh ${DESTDIR}/bin
for s in ${DESTDIR}/bin/*
do \
EXE=$(basename $s)
test ${EXE} = linux_wrapper.sh && continue
test ${EXE} = qt.conf && continue
ln -s bin/linux_wrapper.sh ${DESTDIR}/${EXE}
done

pushd ..
tar -czvvf LAMMPS-Linux-amd64.tar.gz LAMMPS_GUI
popd

echo "Cleanup dir"
rm -r ${DESTDIR}
exit 0