Skip to content

Commit 23fac49

Browse files
committed
Feat(UI): ImPlot3D integration
1 parent afba14c commit 23fac49

File tree

6 files changed

+47
-2
lines changed

6 files changed

+47
-2
lines changed

src/atta/ui/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ add_library(atta_ui_module STATIC
4141
${ATTA_UI_MODULE_SOURCE}
4242
)
4343

44-
target_link_libraries(atta_ui_module PRIVATE atta_graphics_module atta_io_module atta_component_module ${ATTA_IMGUIZMO_TARGETS} ${ATTA_IMPLOT_TARGETS})
44+
target_link_libraries(atta_ui_module PRIVATE atta_graphics_module atta_io_module atta_component_module ${ATTA_IMGUIZMO_TARGETS} ${ATTA_IMPLOT_TARGETS} ${ATTA_IMPLOT3D_TARGETS})
4545
atta_target_common(atta_ui_module)
4646
atta_add_libs(atta_ui_module)

src/atta/ui/editor/editor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <atta/ui/editor/editor.h>
1111
#include <imgui_internal.h>
1212
#include <implot.h>
13+
#include <implot3d.h>
1314

1415
#include <atta/ui/editor/moduleWindows/graphicsModuleWindow.h>
1516
#include <atta/ui/editor/moduleWindows/ioModuleWindow.h>
@@ -33,6 +34,7 @@ void Editor::render() {
3334
bool demo = true;
3435
ImGui::ShowDemoWindow(&demo);
3536
// ImPlot::ShowDemoWindow(&demo);
37+
// ImPlot3D::ShowDemoWindow(&demo);
3638

3739
// Top interface
3840
_topBar.render();

src/atta/ui/manager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#endif
2020
#include <ImGuizmo.h>
2121
#include <implot.h>
22+
#include <implot3d.h>
2223
// clang-format on
2324

2425
namespace atta::ui {
@@ -32,6 +33,7 @@ void Manager::startUpImpl() {
3233
IMGUI_CHECKVERSION();
3334
ImGui::CreateContext();
3435
ImPlot::CreateContext();
36+
ImPlot3D::CreateContext();
3537

3638
ImGuiIO& io = ImGui::GetIO();
3739
(void)io;
@@ -72,6 +74,11 @@ void Manager::shutDownImpl() {
7274
// Make sure all rendering operations are done
7375
gfx::getGraphicsAPI()->waitDevice();
7476

77+
// Destroy plotting contexts
78+
ImPlot3D::DestroyContext();
79+
ImPlot::DestroyContext();
80+
81+
// Destroy ImGui context
7582
switch (gfx::getGraphicsAPI()->getType()) {
7683
case gfx::GraphicsAPI::OPENGL:
7784
ImGui_ImplOpenGL3_Shutdown();

src/extern/extern.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include(solveAssimp)
2626
include(solveStbImage)
2727
include(solveImguizmo)
2828
include(solveImplot)
29+
include(solveImplot3d)
2930
include(solveBox2d)
3031
include(solveBullet)
3132
include(solveSystemd)

src/extern/solveImgui.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828
add_library(imgui STATIC
2929
${IMGUI_SOURCE}
3030
)
31-
target_include_directories(imgui PUBLIC
31+
target_include_directories(imgui PUBLIC
3232
$<BUILD_INTERFACE:${FETCHCONTENT_BASE_DIR}/imgui-src>
3333
$<INSTALL_INTERFACE:include/${ATTA_VERSION_SAFE}/extern/imgui>
3434
)

src/extern/solveImplot3d.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set(ATTA_IMPLOT3D_SUPPORT FALSE)
2+
set(ATTA_IMPLOT3D_TARGETS "")
3+
4+
FetchContent_Declare(
5+
implot3d
6+
GIT_REPOSITORY "https://github.com/brenocq/implot3d"
7+
GIT_TAG "v0.1"
8+
GIT_PROGRESS TRUE
9+
GIT_SHALLOW TRUE
10+
)
11+
12+
atta_log(Info Extern "Fetching ImPlot3D...")
13+
FetchContent_MakeAvailable(implot3d)
14+
15+
set(IMPLOT3D_SOURCE
16+
${FETCHCONTENT_BASE_DIR}/implot3d-src/implot3d.cpp
17+
${FETCHCONTENT_BASE_DIR}/implot3d-src/implot3d_demo.cpp
18+
${FETCHCONTENT_BASE_DIR}/implot3d-src/implot3d_items.cpp
19+
${FETCHCONTENT_BASE_DIR}/implot3d-src/implot3d_meshes.cpp
20+
)
21+
add_library(implot3d STATIC
22+
${IMPLOT3D_SOURCE}
23+
)
24+
target_include_directories(implot3d PUBLIC
25+
$<BUILD_INTERFACE:${FETCHCONTENT_BASE_DIR}/implot3d-src>
26+
$<INSTALL_INTERFACE:include/${ATTA_VERSION_SAFE}/extern/implot3d>
27+
)
28+
target_link_libraries(implot3d PRIVATE glfw imgui)
29+
30+
atta_add_include_dirs(${FETCHCONTENT_BASE_DIR}/implot3d-src)
31+
atta_add_libs(implot3d)
32+
33+
atta_log(Success Extern "ImPlot support (source)")
34+
set(ATTA_IMPLOT3D_SUPPORT TRUE)
35+
set(ATTA_IMPLOT3D_TARGETS implot3d)

0 commit comments

Comments
 (0)