Skip to content

Commit 52d78b2

Browse files
committed
Introduce Dear ImGui alternative viz module
1 parent 5eeb739 commit 52d78b2

File tree

15 files changed

+2073
-7
lines changed

15 files changed

+2073
-7
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[submodule "3rdparty/robin-map"]
22
path = mola_metric_maps/3rdparty/robin-map
33
url = https://github.com/Tessil/robin-map.git
4+
[submodule "mola_viz_imgui/3rdparty/imgui"]
5+
path = mola_viz_imgui/3rdparty/imgui
6+
url = https://github.com/ocornut/imgui.git
7+
branch = docking

mola_demos/mola-cli-launchs/kitti360_just_replay.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ modules:
3737
# MolaViz
3838
# =====================
3939
- name: viz
40-
type: mola::MolaViz
40+
type: mola::MolaVizImGui
4141
#verbosity_level: DEBUG
4242
params: ~ # none

mola_demos/mola-cli-launchs/kitti_just_replay.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ modules:
3737
# MolaViz
3838
# =====================
3939
- name: viz
40-
type: mola::MolaViz
40+
type: mola::MolaVizImGui
4141
#verbosity_level: DEBUG
4242
params: ~ # none

mola_viz/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mola_viz
2-
GUI for MOLA
2+
GUI for MOLA based on nanogui
33

4-
Provides the C++ library `libmola-viz` with a flexible API for any other module
4+
Provides the C++ library `libmola_viz` with a flexible API for any other module
55
to display windows, controls, etc.
66

77
## Build and install

mola_viz/src/MolaViz.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ void MolaViz::spinOnce()
10461046
}
10471047

10481048
// ---------------------------------------------------------------------------
1049-
// Dataset UI - ported to create_subwindow_from_description
1049+
// Dataset UI
10501050
// ---------------------------------------------------------------------------
10511051

10521052
void MolaViz::dataset_ui_check_new_modules()
@@ -1927,8 +1927,8 @@ std::future<bool> MolaViz::execute_custom_code_on_background_scene(
19271927
catch (const std::exception& e)
19281928
{
19291929
MRPT_LOG_ERROR_STREAM(
1930-
"Exception in execute_custom_code_on_background_scene():\n"
1931-
<< e.what());
1930+
"Exception in execute_custom_code_on_background_scene():\n"
1931+
<< e.what());
19321932
return false;
19331933
}
19341934
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DisableFormat: true
2+
SortIncludes: Never

mola_viz_imgui/3rdparty/imgui

Submodule imgui added at 934c6a5
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ------------------------------------------------------------------------------
2+
# Static library target wrapping Dear ImGui (docking branch).
3+
#
4+
# Expected layout:
5+
# <this file's parent>/../../3rdparty/imgui/ ← git submodule
6+
#
7+
# The submodule must be the "docking" branch of
8+
# https://github.com/ocornut/imgui
9+
# ------------------------------------------------------------------------------
10+
11+
cmake_minimum_required(VERSION 3.5)
12+
project(imgui_static LANGUAGES CXX)
13+
14+
# Locate the submodule root relative to this file
15+
get_filename_component(_IMGUI_ROOT
16+
"${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/imgui" ABSOLUTE)
17+
18+
if(NOT EXISTS "${_IMGUI_ROOT}/imgui.h")
19+
message(FATAL_ERROR
20+
"Dear ImGui submodule not found at ${_IMGUI_ROOT}.\n"
21+
"Run: git submodule update --init --recursive")
22+
endif()
23+
24+
# Find GLFW (already required by mrpt-gui, so it will be present)
25+
find_package(glfw3 REQUIRED)
26+
find_package(OpenGL REQUIRED)
27+
28+
set(_IMGUI_SRCS
29+
${_IMGUI_ROOT}/imgui.cpp
30+
${_IMGUI_ROOT}/imgui_draw.cpp
31+
${_IMGUI_ROOT}/imgui_tables.cpp
32+
${_IMGUI_ROOT}/imgui_widgets.cpp
33+
# ${_IMGUI_ROOT}/imgui_demo.cpp # can be excluded in release builds
34+
${_IMGUI_ROOT}/misc/cpp/imgui_stdlib.cpp # std::string InputText support
35+
${_IMGUI_ROOT}/backends/imgui_impl_glfw.cpp
36+
${_IMGUI_ROOT}/backends/imgui_impl_opengl3.cpp
37+
)
38+
39+
add_library(imgui_static STATIC ${_IMGUI_SRCS})
40+
set_target_properties(imgui_static PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
41+
42+
target_include_directories(imgui_static
43+
PUBLIC
44+
${_IMGUI_ROOT}
45+
${_IMGUI_ROOT}/backends
46+
${_IMGUI_ROOT}/misc/cpp
47+
)
48+
49+
# Enable the docking branch feature set:
50+
target_compile_definitions(imgui_static
51+
PUBLIC
52+
IMGUI_ENABLE_DOCKING # activates docking API
53+
IMGUI_IMPL_OPENGL_LOADER_GLEW # or GLAD — adjust to whatever mrpt uses
54+
)
55+
56+
target_link_libraries(imgui_static
57+
PUBLIC
58+
glfw
59+
OpenGL::GL
60+
)
61+
62+
# Suppress warnings from third-party code
63+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
64+
target_compile_options(imgui_static PRIVATE -w)
65+
endif()
66+
67+
# Export as an alias so parent CMake can use it as imgui::imgui
68+
add_library(imgui::imgui ALIAS imgui_static)

mola_viz_imgui/CMakeLists.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ------------------------------------------------------------------------------
2+
# A Modular Optimization framework for Localization and mApping
3+
# (MOLA)
4+
#
5+
# Copyright (C) 2018-2026, Jose Luis Blanco-Claraco, contributors (AUTHORS.md)
6+
# All rights reserved.
7+
# Released under GNU GPL v3. See LICENSE file
8+
# ------------------------------------------------------------------------------
9+
10+
cmake_minimum_required(VERSION 3.5)
11+
project(mola_viz_imgui LANGUAGES CXX)
12+
13+
# MOLA CMake scripts: "mola_xxx()"
14+
find_package(mola_common REQUIRED)
15+
16+
# -- External dependencies ----------------------------------------------------
17+
find_package(mrpt-maps REQUIRED)
18+
find_package(mrpt-opengl REQUIRED)
19+
find_package(mrpt-obs REQUIRED)
20+
find_mola_package(mola_kernel)
21+
22+
# GLFW is needed explicitly for our own GLFW window management.
23+
find_package(glfw3 REQUIRED)
24+
25+
set(OpenGL_GL_PREFERENCE GLVND)
26+
find_package(OpenGL REQUIRED)
27+
28+
# -- Dear ImGui static library (from 3rdparty submodule) ---------------------
29+
#
30+
# The submodule lives at: <repo_root>/3rdparty/imgui (docking branch)
31+
# The helper CMakeLists that builds it as a static lib lives at:
32+
# 3rdparty/imgui_static/CMakeLists.txt
33+
#
34+
add_subdirectory(3rdparty/imgui_static imgui_static_build)
35+
# After this, the target imgui::imgui is available.
36+
37+
# -- Module sources -----------------------------------------------------------
38+
set(LIB_SRCS
39+
src/MolaVizImGui_handlers.cpp
40+
src/MolaVizImGui.cpp
41+
src/MolaVizImGui_widgets.cpp
42+
)
43+
set(LIB_PUBLIC_HDRS
44+
include/mola_viz_imgui/MolaVizImGui.h
45+
)
46+
47+
mola_add_library(
48+
TARGET ${PROJECT_NAME}
49+
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
50+
PUBLIC_LINK_LIBRARIES
51+
mola::mola_kernel
52+
mrpt::opengl
53+
mrpt::maps
54+
mrpt::obs
55+
OpenGL::GL
56+
PRIVATE_LINK_LIBRARIES
57+
imgui::imgui # Dear ImGui static lib (includes GLFW + OpenGL3 backends)
58+
# mrpt::gui # only needed for mrpt type helpers, not the nanogui window
59+
CMAKE_DEPENDENCIES
60+
mola_kernel
61+
mrpt-opengl
62+
mrpt-maps
63+
mrpt-obs
64+
)
65+
66+
# -- Compiler options ---------------------------------------------------------
67+
# C++17 required for std::visit, if_constexpr, structured bindings. Already req by MRPT anyway.
68+
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

mola_viz_imgui/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# mola_viz_imgui
2+
GUI for MOLA based on Dear ImGui
3+
4+
Provides the C++ library `libmola_viz_imgui` with a flexible API for any other module
5+
to display windows, controls, etc.
6+
7+
## Build and install
8+
Refer to the [root MOLA repository](https://github.com/MOLAorg/mola).
9+
10+
## Docs and examples
11+
See this package page [in the documentation](https://docs.mola-slam.org/latest/modules.html).
12+
13+
## License
14+
This package is released under the GNU GPL v3 license. Other options available upon request.

0 commit comments

Comments
 (0)