libigl v2.5.0
Loading...
Searching...
No Matches
ImGuiPlugin.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
4// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
5//
6// This Source Code Form is subject to the terms of the Mozilla Public License
7// v. 2.0. If a copy of the MPL was not distributed with this file, You can
8// obtain one at http://mozilla.org/MPL/2.0/.
9#ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIPLUGIN_H
10#define IGL_OPENGL_GLFW_IMGUI_IMGUIPLUGIN_H
11
12#include "../Viewer.h"
13#include "../ViewerPlugin.h"
14#include "../../../igl_inline.h"
15#include "ImGuiWidget.h"
16
17// Forward declarations
18struct ImGuiContext;
19
20namespace igl
21{
22 namespace opengl
23 {
24 namespace glfw
25 {
26 namespace imgui
27 {
28 // Forward declaration of child widget abstract type
29 class ImGuiWidget;
32 {
33 protected:
34 // Hidpi scaling to be used for text rendering.
36 // Ratio between the framebuffer size and the window size.
37 // May be different from the hipdi scaling!
39 // ImGui Context
40 ImGuiContext * context_ = nullptr;
41 public:
42 // List of registered widgets
43 std::vector<ImGuiWidget*> widgets;
44 public:
45 IGL_INLINE virtual void init(igl::opengl::glfw::Viewer *_viewer) override;
47 IGL_INLINE virtual void reload_font(int font_size = 13);
48 IGL_INLINE virtual void shutdown() override;
49 IGL_INLINE virtual bool pre_draw() override;
50 IGL_INLINE virtual bool post_draw() override;
51 IGL_INLINE virtual void post_resize(int width, int height) override;
52 IGL_INLINE virtual bool mouse_down(int button, int modifier) override;
53 IGL_INLINE virtual bool mouse_up(int button, int modifier) override;
54 IGL_INLINE virtual bool mouse_move(int mouse_x, int mouse_y) override;
55 IGL_INLINE virtual bool mouse_scroll(float delta_y) override;
56 // Keyboard IO
57 IGL_INLINE virtual bool key_pressed(unsigned int key, int modifiers) override;
58 IGL_INLINE virtual bool key_down(int key, int modifiers) override;
59 IGL_INLINE virtual bool key_up(int key, int modifiers) override;
61 const Eigen::Vector3d pos,
62 const Eigen::Vector3d normal,
63 const std::string &text,
64 const Eigen::Vector4f color = Eigen::Vector4f(0,0,0.04,1)); // old default color
67 };
68 }
69 }
70 }
71}
72
73#ifndef IGL_STATIC_LIBRARY
74# include "ImGuiPlugin.cpp"
75#endif
76
77#endif
78
Abstract class for plugins All plugins MUST have this class as their parent and may implement any/all...
Definition ViewerPlugin.h:39
Definition Viewer.h:43
Plugin for the viewer to enable imgui widgets.
Definition ImGuiPlugin.h:32
virtual bool key_up(int key, int modifiers) override
virtual bool pre_draw() override
This function is called before the draw procedure of Viewer.
std::vector< ImGuiWidget * > widgets
Definition ImGuiPlugin.h:43
void draw_text(const Eigen::Vector3d pos, const Eigen::Vector3d normal, const std::string &text, const Eigen::Vector4f color=Eigen::Vector4f(0, 0, 0.04, 1))
virtual bool mouse_up(int button, int modifier) override
virtual bool key_down(int key, int modifiers) override
virtual void post_resize(int width, int height) override
This function is called after the window has been resized.
float pixel_ratio_
Definition ImGuiPlugin.h:38
virtual bool mouse_scroll(float delta_y) override
virtual void reload_font(int font_size=13)
float hidpi_scaling_
Definition ImGuiPlugin.h:35
virtual void init(igl::opengl::glfw::Viewer *_viewer) override
This function is called when the viewer is initialized (no mesh will be loaded at this stage)
virtual bool key_pressed(unsigned int key, int modifiers) override
virtual bool mouse_down(int button, int modifier) override
ImGuiContext * context_
Definition ImGuiPlugin.h:40
virtual bool mouse_move(int mouse_x, int mouse_y) override
virtual void shutdown() override
This function is called before shutdown.
virtual bool post_draw() override
This function is called after the draw procedure of Viewer.
#define IGL_INLINE
Definition igl_inline.h:15
Definition AABB.h:17