Open3D (C++ API)  0.13.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TreeView.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2020 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <functional>
30 
32 
33 namespace open3d {
34 namespace visualization {
35 namespace gui {
36 
37 class Checkbox;
38 class ColorEdit;
39 class Label;
40 class NumberEdit;
41 
47 class CheckableTextTreeCell : public Widget {
48 public:
49  CheckableTextTreeCell(const char* text,
50  bool is_checked,
51  std::function<void(bool)> on_toggled);
53 
54  std::shared_ptr<Checkbox> GetCheckbox();
55  std::shared_ptr<Label> GetLabel();
56 
58  const Constraints& constraints) const override;
59  void Layout(const LayoutContext& context) override;
60 
61 private:
62  struct Impl;
63  std::unique_ptr<Impl> impl_;
64 };
65 
66 class LUTTreeCell : public Widget {
67 public:
68  LUTTreeCell(const char* text,
69  bool is_checked,
70  const Color& color,
71  std::function<void(bool)> on_enabled,
72  std::function<void(const Color&)> on_color_changed);
73  ~LUTTreeCell();
74 
75  std::shared_ptr<Checkbox> GetCheckbox();
76  std::shared_ptr<Label> GetLabel();
77  std::shared_ptr<ColorEdit> GetColorEdit();
78 
80  const Constraints& constraints) const override;
81  void Layout(const LayoutContext& context) override;
82 
83 private:
84  struct Impl;
85  std::unique_ptr<Impl> impl_;
86 };
87 
88 class ColormapTreeCell : public Widget {
89 public:
90  ColormapTreeCell(double value,
91  const Color& color,
92  std::function<void(double)> on_value_changed,
93  std::function<void(const Color&)> on_color_changed);
95 
96  std::shared_ptr<NumberEdit> GetNumberEdit();
97  std::shared_ptr<ColorEdit> GetColorEdit();
98 
100  const Constraints& constraints) const override;
101  void Layout(const LayoutContext& context) override;
102 
103 private:
104  struct Impl;
105  std::unique_ptr<Impl> impl_;
106 };
107 
108 class TreeView : public Widget {
109  using Super = Widget;
110 
111 public:
112  using ItemId = int;
113 
114  TreeView();
115  ~TreeView();
116 
119  ItemId GetRootItem() const;
121  ItemId AddItem(ItemId parent_id, std::shared_ptr<Widget> item);
123  ItemId AddTextItem(ItemId parent_id, const char* text);
125  void RemoveItem(ItemId item_id);
127  void Clear();
129  std::shared_ptr<Widget> GetItem(ItemId item_id) const;
130  std::vector<ItemId> GetItemChildren(ItemId parent_id) const;
131 
132  bool GetCanSelectItemsWithChildren() const;
136  void SetCanSelectItemsWithChildren(bool can_select);
137 
139  ItemId GetSelectedItemId() const;
141  void SetSelectedItemId(ItemId item_id);
142 
144  const Constraints& constraints) const override;
145  Size CalcMinimumSize(const LayoutContext& context) const override;
146 
147  void Layout(const LayoutContext& context) override;
148 
149  DrawResult Draw(const DrawContext& context) override;
150 
153  void SetOnSelectionChanged(
154  std::function<void(ItemId)> on_selection_changed);
155 
156 private:
157  struct Impl;
158  std::unique_ptr<Impl> impl_;
159 };
160 
161 } // namespace gui
162 } // namespace visualization
163 } // namespace open3d
~CheckableTextTreeCell()
Definition: TreeView.cpp:66
int ItemId
Definition: TreeView.h:112
Definition: Widget.h:68
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:84
ImGuiContext * context
Definition: Window.cpp:95
math::float4 color
Definition: LineSetBuffers.cpp:64
Widget()
Definition: Widget.cpp:53
Definition: TreeView.cpp:222
virtual Size CalcMinimumSize(const LayoutContext &context) const
Definition: Widget.cpp:101
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:479
std::shared_ptr< Label > GetLabel()
Definition: TreeView.cpp:72
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:76
Definition: PinholeCameraIntrinsic.cpp:35
std::shared_ptr< Checkbox > GetCheckbox()
Definition: TreeView.cpp:68
CheckableTextTreeCell(const char *text, bool is_checked, std::function< void(bool)> on_toggled)
Definition: TreeView.cpp:52
virtual DrawResult Draw(const DrawContext &context)
Definition: Widget.cpp:111
DrawResult
Definition: Widget.h:114
Definition: Color.h:35
Definition: TreeView.h:108