Skip to content

Commit

Permalink
build: Add QuickPlot into QML GUI (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
rprospero authored Sep 4, 2024
1 parent e139dba commit f48d284
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
run: |
sudo apt-get update -q
sudo apt-get install ninja-build python3-setuptools uuid uuid-dev
git submodule update --init --recursive
- name: Install Conan
run: |
sudo pip3 install wheel
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/build/linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,45 @@ runs:
run: |
set -ex
### Begin unholy hack
###
### For reasons unknown, when nix is run under GitHub actions,
### it ignores the submodules flag, meaning that flakes with
### submodules cannot be built
###
### As a blasphemous workaround, I've added a step to bring the
### submodule into the main repo. Hopefully, submodules are
### made the default flake behaviour in the upcoming release,
### this will no longer be necessary. If not, we might have to
### make the submodule an extra input to the flake, but that
### will take some extra time.
###
### If you are reading this comment in 2026, try removing this
### entire hack and see if the problem fixed itself. You may
### also need to update the action that installs nix in the
### first place. If that doesn't solve the problem, then we
### should go ahead and just make the submodule a flake input.
git submodule update --init --recursive
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git rm .gitmodules
cp -r QuickPlot QuickPlot.bak
rm -rf QuickPlot.bak/.git
git rm -r QuickPlot
git commit -m "Kill submodule"
mv QuickPlot.bak QuickPlot
git add QuickPlot
git commit -m "Resurrect submodule"
### End unholy hack
# Build Singularity target
target=${{ inputs.target }}
singularityTarget=${target/dissolve/singularity}
nix build -L .#$singularityTarget
nix build -L ".?submodules=1#$singularityTarget"
# Assemble artifacts
mkdir packages-sif
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build/osx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ runs:
shell: bash
run: |
export PATH="$(python3 -m site --user-base)/bin:$PATH"
aqt install-qt --outputdir ${{ runner.temp }}/qt mac desktop ${{ env.qtVersion }}
aqt install-qt --outputdir ${{ runner.temp }}/qt mac desktop ${{ env.qtVersion }} -m all
#
# Main Build
Expand All @@ -68,6 +68,7 @@ runs:
shell: bash
run: |
set -ex
git submodule update --init --recursive
# Setup paths
export PATH="$(python3 -m site --user-base)/bin:$PATH"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build/windows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ runs:
path: ${{ runner.temp }}\qt

- name: Install Qt
if: ${{ steps.cache-qt.outputs.cache-hit != 'true' }}
# if: ${{ steps.cache-qt.outputs.cache-hit != 'true' }}
shell: bash
run: |
aqt install-qt --outputdir ${RUNNER_TEMP}/qt windows desktop ${{ env.qtVersion }} win64_msvc2019_64
aqt install-qt --outputdir ${RUNNER_TEMP}/qt windows desktop ${{ env.qtVersion }} win64_msvc2019_64 -m all
- name: Setup MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
Expand Down Expand Up @@ -150,6 +150,7 @@ runs:
if: ${{ inputs.cacheOnly == 'false' }}
shell: bash
run: |
git submodule update --init --recursive
# Setup environment
Qt6_DIR="${RUNNER_TEMP}\qt\${{ env.qtVersion }}\msvc2019_64"
ANTLR_EXE="${RUNNER_TEMP}\antlr-${{ env.antlrVersion }}-complete.jar"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/get-nix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ runs:
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
extra_nix_config: |
system-features = nixos-test benchmark big-parallel kvm
experimental-features = configurable-impure-env nix-command flakes
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "QuickPlot"]
path = QuickPlot
url = https://github.com/disorderedmaterials/QuickPlot.git
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ if(GUI)
QmlModels
QmlTools
Quick
Quick3D
3DCore
3DExtras
3DRender
3DExtras
QuickWidgets
QuickControls2
REQUIRED
Expand Down Expand Up @@ -262,7 +267,17 @@ if(GUI)
)

# Dissolve QML GUI
qt_add_executable(${qmlgui_target_name} MACOSX_BUNDLE ${SRCS}/dissolve-gui-qml.cpp ${SRCS}/gui-qml/resources.qrc)
qt_add_executable(${qmlgui_target_name} MACOSX_BUNDLE ${SRCS}/dissolve-gui-qml.cpp)
set_source_files_properties(${SRCS}/gui-qml/qml/DissolveMain.qml PROPERTIES QT_RESOURCE_ALIAS qml/DissolveMain.qml)
qt_add_qml_module(
${qmlgui_target_name}
VERSION
0.1
URI
Dissolve
QML_FILES
${SRCS}/gui-qml/qml/DissolveMain.qml
)

# Set project-local include directories for target (we expect to need less of these dependencies over time)
target_include_directories(
Expand Down Expand Up @@ -339,6 +354,8 @@ target_link_libraries(
# Build GUI target executables
if(GUI)

add_subdirectory(QuickPlot/src)

# Main Dissolve GUI
target_link_libraries(
${gui_target_name}
Expand Down Expand Up @@ -371,9 +388,9 @@ if(GUI)
${qmlgui_target_name}
PUBLIC ${WHOLE_ARCHIVE_FLAG} ${BASIC_LINK_LIBS}
# Module gui libs
gui-qml ${NO_WHOLE_ARCHIVE_FLAG}
gui-qml ${NO_WHOLE_ARCHIVE_FLAG} QuickPlotplugin
PRIVATE # External libs
Qt6::Qml ${CORE_LINK_LIBS} ${THREADING_LINK_LIBS}
Qt6::Quick3D Qt6::Qml ${CORE_LINK_LIBS} ${THREADING_LINK_LIBS}
)

qt_generate_deploy_qml_app_script(
Expand Down
1 change: 1 addition & 0 deletions QuickPlot
Submodule QuickPlot added at cc4d3a
18 changes: 8 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
libGL.dev
libglvnd
libglvnd.dev
qt6.qt3d
qt6.qtbase
qt6.qtbase.dev
qt6.qtquick3d
qt6.qtsvg
qt6.qtshadertools
qt6.qttools
Expand All @@ -70,13 +72,7 @@
pkgs.stdenv.mkDerivation ({
inherit version;
pname = exe-name mpi gui;
src = builtins.path {
path = ./.;
name = "dissolve-src";
filter = path: type:
type != "directory" || builtins.baseNameOf path
!= ".azure-pipelines" || builtins.baseNameOf path != "web";
};
src = ./. ;
buildInputs = base_libs pkgs ++ pkgs.lib.optional mpi pkgs.openmpi
++ pkgs.lib.optionals gui (gui_libs system pkgs)
++ pkgs.lib.optionals checks (check_libs pkgs)
Expand Down Expand Up @@ -189,7 +185,8 @@
}:${
pkgs.lib.makeLibraryPath [ pkgs.libglvnd ]
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export QT_PLUGIN_PATH="${pkgs.qt6.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
# export QT_PLUGIN_PATH="${pkgs.qt6.qt3d}/lib/qt-6/plugins:${pkgs.qt6.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
export QT_PLUGIN_PATH="${pkgs.qt6.qtquick3d}/lib/qt-6/plugins:${pkgs.qt6.qt3d}/lib/qt-6/plugins:${pkgs.qt6.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
'';

CMAKE_CXX_COMPILER_LAUNCHER =
Expand All @@ -198,8 +195,9 @@
"${pkgs.ccache}/bin/ccache;${pkgs.distcc}/bin/distcc";
CMAKE_CXX_FLAGS_DEBUG = "-g -O0";
CXXL = "${pkgs.stdenv.cc.cc.lib}";
QML_IMPORT_PATH = "${pkgs.qt6.qtdeclarative}/lib/qt-6/qml/";
QML2_IMPORT_PATH = "${pkgs.qt6.qtdeclarative}/lib/qt-6/qml/";
Qt6Quick3D_DIR = "${pkgs.qt6.qtquick3d}/lib/";
QML_IMPORT_PATH = "${pkgs.qt6.qtquick3d}/lib/qt-6/qml:${pkgs.qt6.qtdeclarative}/lib/qt-6/qml/";
QML2_IMPORT_PATH = "$${pkgs.qt6.qtquick3d}/lib/qt-6/qml:{pkgs.qt6.qtdeclarative}/lib/qt-6/qml/";
};

apps = {
Expand Down
2 changes: 1 addition & 1 deletion src/dissolve-gui-qml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(int args, char **argv)
QGuiApplication app(args, argv);

QQmlApplicationEngine engine;
const QUrl url(u"qrc:/main/qml/DissolveMain.qml"_qs);
const QUrl url(u"qrc:/Dissolve/qml/DissolveMain.qml"_qs);

QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); },
Expand Down
78 changes: 78 additions & 0 deletions src/gui-qml/qml/DissolveMain.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick.Controls
import ProjectDissolve
import "../../ProjectDissolve"

ApplicationWindow {
id: dissolveWindow
property vector3d scale: Qt.vector3d(Math.min(graphView.width / 2.5, graphView.height / 2.5), Math.min(graphView.width / 2.5, graphView.height / 2.5), 200)

height: 743
title: "Dissolve"
visible: true
Expand All @@ -25,6 +32,77 @@ ApplicationWindow {
width: implicitWidth
}
}
Node {
id: standAloneScene
DirectionalLight {
ambientColor: Qt.rgba(0.5, 0.5, 0.5, 1.0)
brightness: 1.0
eulerRotation.x: -25
}
ScatterModel {
id: plotLine
color: "red"
scale: dissolveWindow.scale
thickness: 0.1
xAxis: xAxis
yAxis: yAxis
}
LineModel {
color: "#006f6f"
scale: dissolveWindow.scale
thickness: 0.1
xAxis: xAxis
xs: [-1.0, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1.0]
yAxis: yAxis
ys: [1.0, 0.64, 0.36, 0.16, 0.04, 0, 0.04, 0.16, 0.36, 0.64, 1.0]
}
AxisModel {
color: "black"
scl: dissolveWindow.scale

axis: Axis {
id: xAxis
direction: true
maximum: 2.0
minimum: -2.0
thickness: 0.01
}
}
AxisModel {
color: "black"
scl: dissolveWindow.scale

axis: Axis {
id: yAxis
direction: false
maximum: 2.0
minimum: -2.0
thickness: 0.01
}
}
}
View3D {
id: graphView
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.top: tabBar.bottom
importScene: standAloneScene

MouseArea {
anchors.fill: parent

onWheel: function (event) {
xAxis.nudge(0.01 * event.pixelDelta.x);
yAxis.nudge(-0.01 * event.pixelDelta.y);
}
}

camera: OrthographicCamera {
id: cameraOrthographicLeft
z: 600
}
}

menuBar: MenuBar {
id: mainMenu
Expand Down
5 changes: 0 additions & 5 deletions src/gui-qml/resources.qrc

This file was deleted.

1 change: 1 addition & 0 deletions web/docs/userguide/developers/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Resolving deltas: 100% (27682/27682), done.
Checking out files: 100% (2309/2309), done.
bob@linux:~> cd dissolve
bob@linux:~> git submodule update --init --recursive
bob@linux:~> ls
AUTHORS changeversion commit dissolve.kdev4 extra NEWS tests
Expand Down

1 comment on commit f48d284

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: f48d284 Previous: d715075 Ratio
BM_HistogramBinning_3d/16777216 57.640470536140455 ns/iter 28.180865817928062 ns/iter 2.05

This comment was automatically generated by workflow using github-action-benchmark.

CC: @disorderedmaterials/dissolve-devs

Please sign in to comment.