libigl v2.5.0
Loading...
Searching...
No Matches
SelectionWidget.h
Go to the documentation of this file.
1#ifndef IGL_OPENGL_GFLW_IMGUI_SELECTIONWIDGET_H
2#define IGL_OPENGL_GFLW_IMGUI_SELECTIONWIDGET_H
3#include "../../../igl_inline.h"
4#include "ImGuiWidget.h"
5#include <Eigen/Dense>
6#include <vector>
7#include <string>
8#include <functional>
9
10namespace igl{ namespace opengl{ namespace glfw{ namespace imgui{
11
14{
15public:
16 // customizable hotkeys
18 std::string MARQUEE_KEY = "Mm";
19 // leave 'L' for show_lines in viewer
21 std::string LASSO_KEY = "l";
23 std::string OFF_KEY = "Vv";
34 bool is_down = false;
36 bool is_drawing = false;
37 // min and max corners of 2D rectangular marquee
38 Eigen::Matrix<float,2,2> M = Eigen::Matrix<float,2,2>::Zero();
39 // list of points of 2D lasso marquee
40 std::vector<Eigen::RowVector2f> L;
41 // callback called when slection is completed (usually on mouse_up)
42 std::function<void(void)> callback;
43 // callback called after mode is changed
44 std::function<void(Mode)> callback_post_mode_change;
45 IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override;
46 IGL_INLINE virtual void draw() override;
47 IGL_INLINE virtual bool mouse_down(int button, int modifier) override;
48 IGL_INLINE virtual bool mouse_up(int button, int modifier) override;
49 IGL_INLINE virtual bool mouse_move(int mouse_x, int mouse_y) override;
50 IGL_INLINE virtual bool key_pressed(unsigned int key, int modifiers) override;
52 // helpers
53 IGL_INLINE static void circle(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L);
54 IGL_INLINE static void rect(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L);
55 IGL_INLINE static Eigen::RowVector2f xy(const Viewer * v);
56public:
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58};
59
60}}}}
61
62#ifndef IGL_STATIC_LIBRARY
63#include "SelectionWidget.cpp"
64#endif
65#endif
Definition Viewer.h:43
Plugin for the viewer to enable imgui widgets.
Definition ImGuiPlugin.h:32
Abstract class for imgui "widgets".
Definition ImGuiWidget.h:31
Widget for selecting a region of the screen.
Definition SelectionWidget.h:14
std::string LASSO_KEY
Hot key to start lasso.
Definition SelectionWidget.h:21
std::function< void(void)> callback
Definition SelectionWidget.h:42
bool is_drawing
Definition SelectionWidget.h:36
static Eigen::RowVector2f xy(const Viewer *v)
std::string MARQUEE_KEY
Hot key to start marquee.
Definition SelectionWidget.h:18
static void circle(const Eigen::Matrix< float, 2, 2 > &M, std::vector< Eigen::RowVector2f > &L)
std::vector< Eigen::RowVector2f > L
Definition SelectionWidget.h:40
virtual bool mouse_move(int mouse_x, int mouse_y) override
bool has_moved_since_down
Definition SelectionWidget.h:35
virtual bool key_pressed(unsigned int key, int modifiers) override
Mode
Selection modes.
Definition SelectionWidget.h:26
@ POLYGONAL_LASSO
Definition SelectionWidget.h:30
@ NUM_MODES
Definition SelectionWidget.h:32
@ RECTANGULAR_MARQUEE
Definition SelectionWidget.h:28
@ OFF
Definition SelectionWidget.h:27
@ LASSO
Definition SelectionWidget.h:31
@ ELLIPTICAL_MARQUEE
Definition SelectionWidget.h:29
std::function< void(Mode)> callback_post_mode_change
Definition SelectionWidget.h:44
std::string OFF_KEY
Hot key to stop selection.
Definition SelectionWidget.h:23
bool is_down
Definition SelectionWidget.h:34
virtual bool mouse_up(int button, int modifier) override
enum igl::opengl::glfw::imgui::SelectionWidget::Mode mode
virtual bool mouse_down(int button, int modifier) override
virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override
static void rect(const Eigen::Matrix< float, 2, 2 > &M, std::vector< Eigen::RowVector2f > &L)
Eigen::Matrix< float, 2, 2 > M
Definition SelectionWidget.h:38
#define IGL_INLINE
Definition igl_inline.h:15
Definition AABB.h:17