Skip to content

Commit

Permalink
Add FMUSim GUI (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer authored Aug 5, 2024
1 parent 2f58909 commit fa19d1a
Show file tree
Hide file tree
Showing 76 changed files with 231,250 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build-fmusim-gui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build the FMUSim GUI

on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]

jobs:
build-fmusim-gui:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.7.1'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
modules: 'qtpositioning qtwebchannel qtwebengine'
- run: python -m pip install fmpy requests
- run: python fmusim-gui/build/build_cvode.py
- run: python fmusim-gui/build/build_libxml2.py
- run: python fmusim-gui/build/build_zlib.py
- run: cmake -D CMAKE_PREFIX_PATH=${{env.QT_ROOT_DIR}} -S fmusim-gui -B fmusim-gui/build/fmusim-gui
- run: cmake --build fmusim-gui/build/fmusim-gui --config Release
- run: ${{env.QT_ROOT_DIR}}\bin\windeployqt.exe fmusim-gui\build\fmusim-gui\Release\fmusim-gui.exe
- run: Copy-Item -Path fmusim-gui\build\libxml2-x86_64-windows\install\bin\libxml2.dll -Destination fmusim-gui\build\fmusim-gui\Release\
- run: Copy-Item -Path fmusim-gui\build\zlib-x86_64-windows\install\bin\zlib.dll -Destination fmusim-gui\build\fmusim-gui\Release\
- run: Copy-Item -Path fmusim-gui\LICENSE.txt -Destination fmusim-gui\build\fmusim-gui\Release\
- run: Copy-Item -Path fmusim-gui\LICENSE_QT.txt -Destination fmusim-gui\build\fmusim-gui\Release\
- uses: actions/upload-artifact@v4
with:
name: fmusim-gui-x86_64-windows
path: fmusim-gui/build/fmusim-gui/Release
if-no-files-found: error

74 changes: 74 additions & 0 deletions fmusim-gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------

*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash

# qtcreator generated files
*.pro.user*
CMakeLists.txt.user*

# xemacs temporary files
*.flc

# Vim temporary files
.*.swp

# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*

# MinGW generated files
*.Debug
*.Release

# Python byte code
*.pyc

# Binaries
# --------
*.dll
*.exe

160 changes: 160 additions & 0 deletions fmusim-gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
cmake_minimum_required(VERSION 3.5)

project(fmusim-gui VERSION 0.1 LANGUAGES C CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
set(CVODE_DIR ${CMAKE_SOURCE_DIR}/build/cvode-x86_64-windows/install)
set(LIBXML2_DIR ${CMAKE_SOURCE_DIR}/build/libxml2-x86_64-windows/install)
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/build/zlib-x86_64-windows/install)

set(ZLIB_SRC_DIR ${CMAKE_SOURCE_DIR}/build/zlib-1.3)

find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets)

set(PROJECT_SOURCES
main.cpp
MainWindow.cpp
MainWindow.h
MainWindow.ui
../src/FMI.c
../include/FMI.h
../fmusim/FMIZip.c
../fmusim/FMIZip.h
../fmusim/miniunzip.c
${ZLIB_SRC_DIR}/contrib/minizip/unzip.c
${ZLIB_SRC_DIR}/contrib/minizip/ioapi.c
${ZLIB_SRC_DIR}/contrib/minizip/iowin32.c
../fmusim/FMIModelDescription.c
../fmusim/FMIModelDescription.h
../src/structured_variable_name.tab.c
../src/structured_variable_name.yy.c
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(fmusim-gui
MANUAL_FINALIZATION
${PROJECT_SOURCES}
ModelVariablesItemModel.h
ModelVariablesItemModel.cpp
plot.html
../src/FMI1.c
../src/FMI2.c
../include/FMI1.h
../include/FMI2.h
../src/FMI3.c
../include/FMI3.h
../fmusim/FMIUtil.c
../fmusim/FMIUtil.h
../fmusim/csv.c
../fmusim/csv.h

../fmusim/FMIStaticInput.h
../fmusim/FMIStaticInput.c

../fmusim/FMI1CSSimulation.h
../fmusim/FMI1CSSimulation.c
../fmusim/FMI1MESimulation.h
../fmusim/FMI1MESimulation.c

../fmusim/FMI2CSSimulation.h
../fmusim/FMI2CSSimulation.c
../fmusim/FMI2MESimulation.h
../fmusim/FMI2MESimulation.c

../fmusim/FMI3CSSimulation.h
../fmusim/FMI3CSSimulation.c
../fmusim/FMI3MESimulation.h
../fmusim/FMI3MESimulation.c

../fmusim/FMIRecorder.h
../fmusim/FMIRecorder.c

../fmusim/FMISimulation.h
../fmusim/FMISimulation.c

../fmusim/FMIEuler.h
../fmusim/FMIEuler.c

../fmusim/FMICVode.h
../fmusim/FMICVode.c

buttons.qrc
plot.qrc
icons/variables/variables.qrc
VariablesFilterModel.h VariablesFilterModel.cpp
SimulationThread.h SimulationThread.cpp
resources.qrc
)

target_include_directories(fmusim-gui PRIVATE
../include
../fmusim
${LIBXML2_DIR}/include/libxml2
${ZLIB_DIR}/include
${ZLIB_SRC_DIR}/contrib/minizip
${CVODE_DIR}/include
)

target_compile_definitions(fmusim-gui PRIVATE
YY_NO_UNISTD_H
)

target_link_libraries(fmusim-gui PRIVATE
Qt6::WebEngineWidgets
${LIBXML2_DIR}/lib/libxml2.lib
${ZLIB_DIR}/lib/zlib.lib
${CVODE_DIR}/lib/sundials_cvode.lib
)

# Define target properties for Android with Qt 6 as:
# set_property(TARGET fmusim-gui APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(fmusim-gui SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(fmusim-gui
${PROJECT_SOURCES}
)
endif()
endif()

target_link_libraries(fmusim-gui PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.fmusim-gui)
endif()
set_target_properties(fmusim-gui PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)
install(TARGETS fmusim-gui
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(fmusim-gui)
endif()
Loading

0 comments on commit fa19d1a

Please sign in to comment.