Open3D (C++ API)  0.18.0+252c867
TreeView.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <functional>
11 
13 
14 namespace open3d {
15 namespace visualization {
16 namespace gui {
17 
18 class Checkbox;
19 class ColorEdit;
20 class Label;
21 class NumberEdit;
22 
28 class CheckableTextTreeCell : public Widget {
29 public:
30  CheckableTextTreeCell(const char* text,
31  bool is_checked,
32  std::function<void(bool)> on_toggled);
34 
35  std::shared_ptr<Checkbox> GetCheckbox();
36  std::shared_ptr<Label> GetLabel();
37 
39  const Constraints& constraints) const override;
40  void Layout(const LayoutContext& context) override;
41 
42 private:
43  struct Impl;
44  std::unique_ptr<Impl> impl_;
45 };
46 
47 class LUTTreeCell : public Widget {
48 public:
49  LUTTreeCell(const char* text,
50  bool is_checked,
51  const Color& color,
52  std::function<void(bool)> on_enabled,
53  std::function<void(const Color&)> on_color_changed);
54  ~LUTTreeCell();
55 
56  std::shared_ptr<Checkbox> GetCheckbox();
57  std::shared_ptr<Label> GetLabel();
58  std::shared_ptr<ColorEdit> GetColorEdit();
59 
61  const Constraints& constraints) const override;
62  void Layout(const LayoutContext& context) override;
63 
64 private:
65  struct Impl;
66  std::unique_ptr<Impl> impl_;
67 };
68 
69 class ColormapTreeCell : public Widget {
70 public:
71  ColormapTreeCell(double value,
72  const Color& color,
73  std::function<void(double)> on_value_changed,
74  std::function<void(const Color&)> on_color_changed);
76 
77  std::shared_ptr<NumberEdit> GetNumberEdit();
78  std::shared_ptr<ColorEdit> GetColorEdit();
79 
81  const Constraints& constraints) const override;
82  void Layout(const LayoutContext& context) override;
83 
84 private:
85  struct Impl;
86  std::unique_ptr<Impl> impl_;
87 };
88 
89 class TreeView : public Widget {
90  using Super = Widget;
91 
92 public:
93  using ItemId = int;
94 
95  TreeView();
96  ~TreeView();
97 
100  ItemId GetRootItem() const;
102  ItemId AddItem(ItemId parent_id, std::shared_ptr<Widget> item);
104  ItemId AddTextItem(ItemId parent_id, const char* text);
106  void RemoveItem(ItemId item_id);
108  void Clear();
110  std::shared_ptr<Widget> GetItem(ItemId item_id) const;
111  std::vector<ItemId> GetItemChildren(ItemId parent_id) const;
112 
113  bool GetCanSelectItemsWithChildren() const;
117  void SetCanSelectItemsWithChildren(bool can_select);
118 
120  ItemId GetSelectedItemId() const;
122  void SetSelectedItemId(ItemId item_id);
123 
125  const Constraints& constraints) const override;
126  Size CalcMinimumSize(const LayoutContext& context) const override;
127 
128  void Layout(const LayoutContext& context) override;
129 
130  DrawResult Draw(const DrawContext& context) override;
131 
135  std::function<void(ItemId)> on_selection_changed);
136 
137 private:
138  struct Impl;
139  std::unique_ptr<Impl> impl_;
140 };
141 
142 } // namespace gui
143 } // namespace visualization
144 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
ImGuiContext * context
Definition: Window.cpp:76
~CheckableTextTreeCell()
Definition: TreeView.cpp:47
std::shared_ptr< Checkbox > GetCheckbox()
Definition: TreeView.cpp:49
std::shared_ptr< Label > GetLabel()
Definition: TreeView.cpp:53
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:65
CheckableTextTreeCell(const char *text, bool is_checked, std::function< void(bool)> on_toggled)
Definition: TreeView.cpp:33
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:57
Definition: Color.h:16
std::shared_ptr< NumberEdit > GetNumberEdit()
Definition: TreeView.cpp:172
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:180
std::shared_ptr< ColorEdit > GetColorEdit()
Definition: TreeView.cpp:176
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:188
ColormapTreeCell(double value, const Color &color, std::function< void(double)> on_value_changed, std::function< void(const Color &)> on_color_changed)
Definition: TreeView.cpp:152
~ColormapTreeCell()
Definition: TreeView.cpp:170
std::shared_ptr< Checkbox > GetCheckbox()
Definition: TreeView.cpp:107
std::shared_ptr< ColorEdit > GetColorEdit()
Definition: TreeView.cpp:113
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:125
std::shared_ptr< Label > GetLabel()
Definition: TreeView.cpp:111
LUTTreeCell(const char *text, bool is_checked, const Color &color, std::function< void(bool)> on_enabled, std::function< void(const Color &)> on_color_changed)
Definition: TreeView.cpp:84
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:115
~LUTTreeCell()
Definition: TreeView.cpp:105
Definition: TreeView.h:89
Size CalcMinimumSize(const LayoutContext &context) const override
Definition: TreeView.cpp:354
std::vector< ItemId > GetItemChildren(ItemId parent_id) const
Definition: TreeView.cpp:308
ItemId AddTextItem(ItemId parent_id, const char *text)
Adds a text item to the tree.
Definition: TreeView.cpp:258
int ItemId
Definition: TreeView.h:93
void Clear()
Clears all the items.
Definition: TreeView.cpp:294
DrawResult Draw(const DrawContext &context) override
Definition: TreeView.cpp:364
ItemId AddItem(ItemId parent_id, std::shared_ptr< Widget > item)
Adds an item to the tree.
Definition: TreeView.cpp:236
void SetCanSelectItemsWithChildren(bool can_select)
Definition: TreeView.cpp:328
void RemoveItem(ItemId item_id)
Removes an item an all its children (if any) from the tree.
Definition: TreeView.cpp:263
ItemId GetRootItem() const
Definition: TreeView.cpp:234
~TreeView()
Definition: TreeView.cpp:232
ItemId GetSelectedItemId() const
Returns the currently selected item id in the tree.
Definition: TreeView.cpp:332
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:358
std::shared_ptr< Widget > GetItem(ItemId item_id) const
Returns item, or nullptr if item_id cannot be found.
Definition: TreeView.cpp:300
TreeView()
Definition: TreeView.cpp:226
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:349
void SetSelectedItemId(ItemId item_id)
Selects the indicated item of the list. Does not call onValueChanged.
Definition: TreeView.cpp:340
bool GetCanSelectItemsWithChildren() const
Definition: TreeView.cpp:324
void SetOnSelectionChanged(std::function< void(ItemId)> on_selection_changed)
Definition: TreeView.cpp:344
Definition: Widget.h:49
Widget()
Definition: Widget.cpp:34
DrawResult
Definition: Widget.h:95
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:474
Definition: PinholeCameraIntrinsic.cpp:16
Definition: TreeView.cpp:203