Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "3rdparty/robin-map"]
path = mola_metric_maps/3rdparty/robin-map
url = https://github.com/Tessil/robin-map.git
[submodule "mola_viz_imgui/3rdparty/imgui"]
path = mola_viz_imgui/3rdparty/imgui
url = https://github.com/ocornut/imgui.git
branch = docking
2 changes: 1 addition & 1 deletion mola_demos/mola-cli-launchs/kitti360_just_replay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ modules:
# MolaViz
# =====================
- name: viz
type: mola::MolaViz
type: mola::MolaVizImGui
#verbosity_level: DEBUG
params: ~ # none
2 changes: 1 addition & 1 deletion mola_demos/mola-cli-launchs/kitti_just_replay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ modules:
# MolaViz
# =====================
- name: viz
type: mola::MolaViz
type: mola::MolaVizImGui
#verbosity_level: DEBUG
params: ~ # none
4 changes: 2 additions & 2 deletions mola_viz/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# mola_viz
GUI for MOLA
GUI for MOLA based on nanogui

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

## Build and install
Expand Down
2 changes: 1 addition & 1 deletion mola_viz/src/MolaViz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ void MolaViz::spinOnce()
}

// ---------------------------------------------------------------------------
// Dataset UI - ported to create_subwindow_from_description
// Dataset UI
// ---------------------------------------------------------------------------

void MolaViz::dataset_ui_check_new_modules()
Expand Down
2 changes: 2 additions & 0 deletions mola_viz_imgui/3rdparty/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions mola_viz_imgui/3rdparty/imgui
Submodule imgui added at 934c6a
68 changes: 68 additions & 0 deletions mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ------------------------------------------------------------------------------
# Static library target wrapping Dear ImGui (docking branch).
#
# Expected layout:
# <this file's parent>/../../3rdparty/imgui/ ← git submodule
#
# The submodule must be the "docking" branch of
# https://github.com/ocornut/imgui
# ------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.5)
project(imgui_static LANGUAGES CXX)

# Locate the submodule root relative to this file
get_filename_component(_IMGUI_ROOT
"${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/imgui" ABSOLUTE)

if(NOT EXISTS "${_IMGUI_ROOT}/imgui.h")
message(FATAL_ERROR
"Dear ImGui submodule not found at ${_IMGUI_ROOT}.\n"
"Run: git submodule update --init --recursive")
endif()

# Find GLFW (already required by mrpt-gui, so it will be present)
find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)

set(_IMGUI_SRCS
${_IMGUI_ROOT}/imgui.cpp
${_IMGUI_ROOT}/imgui_draw.cpp
${_IMGUI_ROOT}/imgui_tables.cpp
${_IMGUI_ROOT}/imgui_widgets.cpp
# ${_IMGUI_ROOT}/imgui_demo.cpp # can be excluded in release builds
${_IMGUI_ROOT}/misc/cpp/imgui_stdlib.cpp # std::string InputText support
${_IMGUI_ROOT}/backends/imgui_impl_glfw.cpp
${_IMGUI_ROOT}/backends/imgui_impl_opengl3.cpp
)

add_library(imgui_static STATIC ${_IMGUI_SRCS})
set_target_properties(imgui_static PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

target_include_directories(imgui_static
PUBLIC
${_IMGUI_ROOT}
${_IMGUI_ROOT}/backends
${_IMGUI_ROOT}/misc/cpp
)

# Enable the docking branch feature set:
target_compile_definitions(imgui_static
PUBLIC
IMGUI_ENABLE_DOCKING # activates docking API
IMGUI_IMPL_OPENGL_LOADER_GLEW # or GLAD — adjust to whatever mrpt uses
)
Comment on lines +50 to +54
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# First, verify the loader macro is set at lines 50-54
echo "=== Checking CMakeLists.txt at specified lines ==="
nl -ba mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt | sed -n '48,60p'

echo ""
echo "=== Searching for OpenGL loader macros and GLEW declarations ==="
rg -n "IMGUI_IMPL_OPENGL_LOADER_GLEW|find_package\(GLEW|GLEW::|libglew|glew" \
  -g 'CMakeLists.txt' -g 'package.xml' 2>/dev/null || echo "No matches found"

echo ""
echo "=== Broader search for GLEW in CMakeLists files ==="
rg -i "glew" -g 'CMakeLists.txt' -n || echo "No GLEW mentions found"

Repository: MOLAorg/mola

Length of output: 166


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check if the file exists and read specified lines
echo "=== Checking CMakeLists.txt at specified lines ==="
if [ -f "mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt" ]; then
  sed -n '48,60p' mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt | cat -n
else
  echo "File not found: mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt"
  echo "Checking available structure:"
  fd -t f "CMakeLists.txt" | head -20
fi

echo ""
echo "=== Searching for OpenGL loader macros and GLEW declarations ==="
rg -n "IMGUI_IMPL_OPENGL_LOADER_GLEW|find_package.*GLEW|GLEW::|libglew" \
  -g 'CMakeLists.txt' -g 'package.xml' 2>/dev/null || echo "No direct GLEW matches found"

echo ""
echo "=== Broader case-insensitive search for GLEW in CMakeLists files ==="
rg -i "glew" -g 'CMakeLists.txt' -n || echo "No GLEW mentions found"

echo ""
echo "=== Search for target_link_libraries in imgui CMakeLists ==="
rg -A 5 "target_link_libraries.*imgui_static" mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt || echo "No target_link_libraries found"

Repository: MOLAorg/mola

Length of output: 1023


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Parent directory structure ==="
ls -la mola_viz_imgui/3rdparty/imgui_static/ | head -20

echo ""
echo "=== Full CMakeLists.txt for imgui_static ==="
cat mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt

echo ""
echo "=== Check parent CMakeLists for GLEW ==="
if [ -f "mola_viz_imgui/CMakeLists.txt" ]; then
  echo "Found mola_viz_imgui/CMakeLists.txt:"
  rg -i "glew|IMGUI_IMPL_OPENGL" mola_viz_imgui/CMakeLists.txt -n || echo "No GLEW or IMGUI_IMPL in parent"
fi

echo ""
echo "=== Search for imgui backend implementation files ==="
find mola_viz_imgui -name "*imgui_impl*" -type f 2>/dev/null | head -10

Repository: MOLAorg/mola

Length of output: 2607


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check for GLEW usage in entire project ==="
rg -i "glew" --type cmake -n | head -20 || echo "No GLEW in CMake files"

echo ""
echo "=== Check for other OpenGL loaders (GLAD, GL3W) ==="
rg -i "IMGUI_IMPL_OPENGL_LOADER_GLAD|IMGUI_IMPL_OPENGL_LOADER_GL3W|GLAD|GL3W" --type cmake -n | head -20

echo ""
echo "=== Check for MRPT or mrpt references ==="
rg -i "mrpt" mola_viz_imgui --type cmake -n

echo ""
echo "=== Check top-level CMakeLists or package.xml for dependencies ==="
if [ -f "CMakeLists.txt" ]; then
  echo "Top-level CMakeLists.txt snippet:"
  head -50 CMakeLists.txt
fi

echo ""
echo "=== Check for package.xml ==="
if [ -f "package.xml" ]; then
  cat package.xml | head -40
fi

Repository: MOLAorg/mola

Length of output: 1551


OpenGL loader macro is inconsistent with declared dependencies.

IMGUI_IMPL_OPENGL_LOADER_GLEW is enabled, but GLEW is neither found via find_package() nor linked in target_link_libraries(). The imgui OpenGL3 backend requires this dependency to compile. This will fail unless GLEW is provided by a parent project or the macro is changed to match an available loader.

Fix: Use GLAD or remove to use default

If GLEW is unavailable, either switch to GLAD (if available) or remove the macro line to use the imgui default loader selection:

 target_compile_definitions(imgui_static
   PUBLIC
     IMGUI_ENABLE_DOCKING       # activates docking API
-    IMGUI_IMPL_OPENGL_LOADER_GLEW  # or GLAD — adjust to whatever mrpt uses
 )

Alternatively, add GLEW dependency if it's required by MRPT or another dependency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mola_viz_imgui/3rdparty/imgui_static/CMakeLists.txt` around lines 50 - 54,
The CMakeLists sets the compile definition IMGUI_IMPL_OPENGL_LOADER_GLEW for the
target imgui_static but never finds or links GLEW; either remove that definition
so imgui uses its default loader or switch it to a loader you actually provide
(e.g., IMGUI_IMPL_OPENGL_LOADER_GLAD) and then add the corresponding
find_package() and target_link_libraries(imgui_static ...) entries (or add
find_package(GLEW) and link GLEW) to ensure the declared loader macro matches an
available dependency.


target_link_libraries(imgui_static
PUBLIC
glfw
OpenGL::GL
)

# Suppress warnings from third-party code
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(imgui_static PRIVATE -w)
endif()

# Export as an alias so parent CMake can use it as imgui::imgui
add_library(imgui::imgui ALIAS imgui_static)
68 changes: 68 additions & 0 deletions mola_viz_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ------------------------------------------------------------------------------
# A Modular Optimization framework for Localization and mApping
# (MOLA)
#
# Copyright (C) 2018-2026, Jose Luis Blanco-Claraco, contributors (AUTHORS.md)
# All rights reserved.
# Released under GNU GPL v3. See LICENSE file
# ------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.5)
project(mola_viz_imgui LANGUAGES CXX)

# MOLA CMake scripts: "mola_xxx()"
find_package(mola_common REQUIRED)

# -- External dependencies ----------------------------------------------------
find_package(mrpt-maps REQUIRED)
find_package(mrpt-opengl REQUIRED)
find_package(mrpt-obs REQUIRED)
find_mola_package(mola_kernel)

# GLFW is needed explicitly for our own GLFW window management.
find_package(glfw3 REQUIRED)

set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)

# -- Dear ImGui static library (from 3rdparty submodule) ---------------------
#
# The submodule lives at: <repo_root>/3rdparty/imgui (docking branch)
# The helper CMakeLists that builds it as a static lib lives at:
# 3rdparty/imgui_static/CMakeLists.txt
#
add_subdirectory(3rdparty/imgui_static imgui_static_build)
# After this, the target imgui::imgui is available.

# -- Module sources -----------------------------------------------------------
set(LIB_SRCS
src/MolaVizImGui_handlers.cpp
src/MolaVizImGui.cpp
src/MolaVizImGui_widgets.cpp
)
set(LIB_PUBLIC_HDRS
include/mola_viz_imgui/MolaVizImGui.h
)

mola_add_library(
TARGET ${PROJECT_NAME}
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
PUBLIC_LINK_LIBRARIES
mola::mola_kernel
mrpt::opengl
mrpt::maps
mrpt::obs
OpenGL::GL
PRIVATE_LINK_LIBRARIES
imgui::imgui # Dear ImGui static lib (includes GLFW + OpenGL3 backends)
# mrpt::gui # only needed for mrpt type helpers, not the nanogui window
CMAKE_DEPENDENCIES
mola_kernel
mrpt-opengl
mrpt-maps
mrpt-obs
)

# -- Compiler options ---------------------------------------------------------
# C++17 required for std::visit, if_constexpr, structured bindings. Already req by MRPT anyway.
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
14 changes: 14 additions & 0 deletions mola_viz_imgui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# mola_viz_imgui
GUI for MOLA based on Dear ImGui

Provides the C++ library `libmola_viz_imgui` with a flexible API for any other module
to display windows, controls, etc.

## Build and install
Refer to the [root MOLA repository](https://github.com/MOLAorg/mola).

## Docs and examples
See this package page [in the documentation](https://docs.mola-slam.org/latest/modules.html).

## License
This package is released under the GNU GPL v3 license. Other options available upon request.
Loading
Loading