Skip to content

Commit

Permalink
Add imgui-based widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Nov 26, 2024
1 parent d036a4e commit eab1966
Show file tree
Hide file tree
Showing 102 changed files with 1,756 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks: '-*,performance-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,-modernize-avoid-c-arrays,-modernize-use-auto'
Checks: '-*,performance-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,-modernize-avoid-c-arrays,-modernize-use-auto,-performance-no-int-to-ptr'
WarningsAsErrors: '*'
UseColor: true
FormatStyle: none
1 change: 1 addition & 0 deletions .github/actions/android-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ runs:
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_SYSTEM_VERSION=${{inputs.api_level}}
-DF3D_BINDINGS_JAVA=ON
-DF3D_MODULE_UI=OFF
-DF3D_PLUGIN_BUILD_EXODUS=OFF
-DF3D_STRICT_BUILD=ON
Expand Down
1 change: 1 addition & 0 deletions .github/actions/coverage-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ runs:
-DF3D_COVERAGE=ON
-DF3D_MODULE_EXR=ON
-DF3D_MODULE_RAYTRACING=ON
-DF3D_MODULE_UI=ON
-DF3D_PLUGINS_STATIC_BUILD=OFF
-DF3D_PLUGIN_BUILD_ALEMBIC=ON
-DF3D_PLUGIN_BUILD_ASSIMP=ON
Expand Down
1 change: 1 addition & 0 deletions .github/actions/external-build-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ runs:
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/
-DF3D_STRICT_BUILD=ON
-DF3D_MODULE_UI=OFF
- name: Build
shell: bash
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/f3d-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ runs:
uses: ./source/.github/actions/usd-install-dep
with:
cpu: ${{inputs.cpu}}

- name: Install ImGui dependency
uses: ./source/.github/actions/imgui-install-dep
with:
cpu: ${{inputs.cpu}}
13 changes: 7 additions & 6 deletions .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ runs:
-DF3D_MACOS_BUNDLE=${{ inputs.bundle_label == 'bundle' && 'ON' || 'OFF' }}
-DF3D_MODULE_EXR=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_MODULE_RAYTRACING=${{ inputs.raytracing_label == 'raytracing' && 'ON' || 'OFF' }}
-DF3D_MODULE_UI=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_PLUGINS_STATIC_BUILD=${{ inputs.bundle_label == 'bundle' && 'ON' || 'OFF' }}
-DF3D_PLUGIN_BUILD_ALEMBIC=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_PLUGIN_BUILD_ASSIMP=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
Expand Down Expand Up @@ -344,7 +345,7 @@ runs:
- name: Check F3D_PLUGINS_PATH using plugin example
if: |
inputs.vtk_version != 'v9.2.6' && inputs.vtk_version != 'v9.3.1' &&
inputs.cpu != 'arm64' && inputs.static_label == 'no-static'
inputs.cpu != 'arm64' && inputs.static_label == 'no-static' && inputs.optional_deps_label == 'optional-deps'
shell: bash
working-directory: ${{github.workspace}}/install
run: F3D_PLUGINS_PATH=$(pwd)/../build_plugins/example-plugin${{ runner.os == 'Windows' && '/Release' || null }} ${{ env.F3D_BIN_PATH }} ../source/examples/plugins/example-plugin/data.expl --load-plugins=example --output=../install_example_plugin_output.png --ref=../source/.github/baselines/install_example_plugin_output.png --resolution=300,300 --verbose
Expand All @@ -361,22 +362,22 @@ runs:
# https://github.com/f3d-app/f3d/issues/1276
- name: Check Install
if: |
inputs.vtk_version != 'v9.2.6' &&
inputs.vtk_version != 'v9.3.1' && inputs.cpu != 'arm64'
inputs.vtk_version != 'v9.2.6' && inputs.vtk_version != 'v9.3.1'
&& inputs.cpu != 'arm64' && inputs.optional_deps_label == 'optional-deps'
shell: bash
working-directory: ${{github.workspace}}/install
run: |
${{ env.F3D_BIN_PATH }} ../source/testing/data/dragon.vtu --output=output/install_output.png --ref=../source/.github/baselines/install_output.png --resolution=300,300 --colormap-file=viridis --comp=0 --verbose
${{ env.F3D_BIN_PATH }} ../source/testing/data/dragon.vtu --output=output/install_output.png --ref=../source/.github/baselines/install_output.png --resolution=300,300 --colormap-file=viridis --comp=0 --verbose --rendering-backend=${{ inputs.rendering_backend }}
- name: Check Install plugins
if: |
inputs.vtk_version != 'v9.2.6'
&& inputs.vtk_version != 'v9.3.1' && inputs.cpu != 'arm64'
&& inputs.static_label == 'no-static'
&& inputs.static_label == 'no-static' && inputs.optional_deps_label == 'optional-deps'
shell: bash
working-directory: ${{github.workspace}}/install
run: |
${{ env.F3D_BIN_PATH }} ../source/examples/plugins/example-plugin/data.expl --output=../install_example_plugin_output.png --ref=../source/.github/baselines/install_example_plugin_output.png --resolution=300,300 --verbose
${{ env.F3D_BIN_PATH }} ../source/examples/plugins/example-plugin/data.expl --output=../install_example_plugin_output.png --ref=../source/.github/baselines/install_example_plugin_output.png --resolution=300,300 --verbose --rendering-backend=${{ inputs.rendering_backend }}
- name: Upload Tests Install Artifact
if: failure()
Expand Down
65 changes: 65 additions & 0 deletions .github/actions/imgui-install-dep/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.16)
project(imgui CXX)

add_library(${PROJECT_NAME} STATIC "")
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

target_sources(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_tables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_widgets.cpp
)

target_compile_definitions(
${PROJECT_NAME}
PRIVATE
IMGUI_DISABLE_DEMO_WINDOWS
IMGUI_DISABLE_DEBUG_TOOLS
)

set_target_properties(
${PROJECT_NAME}
PROPERTIES
CXX_STANDARD 11
POSITION_INDEPENDENT_CODE ON
)

install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_target
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/imgui.h
${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_internal.h
${CMAKE_CURRENT_SOURCE_DIR}/imstb_textedit.h
${CMAKE_CURRENT_SOURCE_DIR}/imstb_rectpack.h
${CMAKE_CURRENT_SOURCE_DIR}/imstb_truetype.h
DESTINATION include
)

include(CMakePackageConfigHelpers)
configure_package_config_file(imgui-config.cmake.in imgui-config.cmake INSTALL_DESTINATION share/imgui)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/imgui-config.cmake DESTINATION share/imgui)

install(
EXPORT ${PROJECT_NAME}_target
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake
DESTINATION share/${PROJECT_NAME}
)
65 changes: 65 additions & 0 deletions .github/actions/imgui-install-dep/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Install ImGui Dependency'
description: 'Install ImGui Dependency using cache when possible'
inputs:
cpu:
description: 'CPU architecture to build for'
required: false
default: 'x86_64'

runs:
using: "composite"
steps:

- name: Cache ImGui
id: cache-imgui
uses: actions/cache@v4
with:
path: dependencies/imgui_install
key: imgui-v1.91.5-${{runner.os}}-${{inputs.cpu}}-2

- name: Checkout ImGui
if: steps.cache-imgui.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ocornut/imgui
path: './dependencies/imgui'
ref: v1.91.5

- name: Copy CMake files
if: steps.cache-imgui.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/dependencies/imgui
shell: bash
run: |
cp $GITHUB_ACTION_PATH/CMakeLists.txt ./
cp $GITHUB_ACTION_PATH/imgui-config.cmake.in ./
- name: Setup ImGui
if: steps.cache-imgui.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/dependencies
shell: bash
run: |
mkdir imgui_build
mkdir imgui_install
- name: Configure ImGui
if: steps.cache-imgui.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/dependencies/imgui_build
shell: bash
run: >
cmake ../imgui
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX:PATH=../imgui_install
-DCMAKE_PREFIX_PATH:PATH=../install/
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_MACOSX_RPATH=ON' || null }}
${{ runner.os == 'Windows' && '-Ax64 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL' || null }}
- name: Build ImGui
if: steps.cache-imgui.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/dependencies/imgui_build
shell: bash
run: cmake --build . --parallel 2 --target install --config Release

- name: Copy to install
working-directory: ${{github.workspace}}/dependencies/imgui_install
shell: bash
run: cp -r ./* ../install/
7 changes: 7 additions & 0 deletions .github/actions/imgui-install-dep/imgui-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_policy(SET CMP0012 NEW)

@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

include("${CMAKE_CURRENT_LIST_DIR}/imgui-targets.cmake")
1 change: 1 addition & 0 deletions .github/actions/python-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ runs:
-DF3D_PLUGIN_BUILD_VDB=${{ runner.os == 'macOS' && 'OFF' || 'ON' }};
-DF3D_MACOS_BUNDLE=OFF;
-DF3D_MODULE_EXR=ON;
-DF3D_MODULE_UI=ON;
-DF3D_WINDOWS_GUI=OFF" >> $GITHUB_ENV
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions .github/actions/sanitizer-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ runs:
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
-DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/
-DF3D_MODULE_EXR=ON
-DF3D_MODULE_UI=ON
-DF3D_PLUGIN_BUILD_ALEMBIC=ON
-DF3D_PLUGIN_BUILD_ASSIMP=ON
-DF3D_PLUGIN_BUILD_DRACO=ON
Expand Down
1 change: 1 addition & 0 deletions .github/actions/static-analysis-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ runs:
-DCMAKE_MODULE_PATH=$(pwd)/../dependencies/install/lib/cmake/OpenVDB/
-DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/
-DF3D_MODULE_EXR=ON
-DF3D_MODULE_UI=ON
-DF3D_PLUGIN_BUILD_ALEMBIC=ON
-DF3D_PLUGIN_BUILD_ASSIMP=ON
-DF3D_PLUGIN_BUILD_DRACO=ON
Expand Down
4 changes: 2 additions & 2 deletions .github/baselines/install_example_plugin_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .github/baselines/install_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mark_as_advanced(F3D_EXCLUDE_DEPRECATED)
# Modules
option(F3D_MODULE_RAYTRACING "Raytracing module" OFF)
option(F3D_MODULE_EXR "OpenEXR images module" OFF)
option(F3D_MODULE_UI "ImGui widgets module" ON)

# Use externals
option(F3D_USE_EXTERNAL_CXXOPTS "Use external cxxopts dependency" OFF)
Expand Down Expand Up @@ -303,6 +304,7 @@ f3d_report_variable(F3D_BINDINGS_PYTHON)
f3d_report_variable(F3D_BUILD_APPLICATION)
f3d_report_variable(F3D_MODULE_EXR)
f3d_report_variable(F3D_MODULE_RAYTRACING)
f3d_report_variable(F3D_MODULE_UI)
f3d_report_variable(F3D_PLUGIN_BUILD_ALEMBIC)
f3d_report_variable(F3D_PLUGIN_BUILD_ASSIMP)
f3d_report_variable(F3D_PLUGIN_BUILD_DRACO)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ F3D as a community-driven, inclusive and beginner-friendly project. We love to s

# Acknowledgments

F3D was initially created by [Kitware SAS](https://www.kitware.eu/) and is relying on many awesome open source projects, including [VTK](https://vtk.org/), [OCCT](https://dev.opencascade.org/), [Assimp](https://www.assimp.org/), [Alembic](http://www.alembic.io/), [Draco](https://google.github.io/draco/), [OpenUSD](https://openusd.org/release/index.html), [OpenVDB](https://www.openvdb.org/) and [OSPRay](https://www.ospray.org/).
F3D was initially created by [Kitware SAS](https://www.kitware.eu/) and is relying on many awesome open source projects, including [VTK](https://vtk.org/), [OCCT](https://dev.opencascade.org/), [Assimp](https://www.assimp.org/), [Alembic](http://www.alembic.io/), [Draco](https://google.github.io/draco/), [OpenUSD](https://openusd.org/release/index.html), [OpenVDB](https://www.openvdb.org/), [OSPRay](https://www.ospray.org/) and [ImGui](https://github.com/ocornut/imgui/).

# License

Expand Down
5 changes: 5 additions & 0 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ if (F3D_MODULE_EXR)
target_compile_definitions(f3d PRIVATE F3D_MODULE_EXR)
endif ()

# ui
if (F3D_MODULE_UI)
target_compile_definitions(f3d PRIVATE F3D_MODULE_UI)
endif ()

if(VTK_VERSION VERSION_LESS 9.3.20240914)
# Headless EGL build
if (VTK_OPENGL_HAS_EGL)
Expand Down
1 change: 1 addition & 0 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,7 @@ int F3DStarter::Start(int argc, char** argv)
else
{
// Create the event loop repeating timer
window.render();
interactor.createTimerCallBack(30, [this]() { this->EventLoop(); });
this->RequestRender();
interactor.start();
Expand Down
Loading

0 comments on commit eab1966

Please sign in to comment.