Open3D (C++ API)  0.16.0
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) 2018-2021 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
33namespace open3d {
34namespace visualization {
35namespace gui {
36
37class Checkbox;
38class ColorEdit;
39class Label;
40class NumberEdit;
41
48public:
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
61private:
62 struct Impl;
63 std::unique_ptr<Impl> impl_;
64};
65
66class LUTTreeCell : public Widget {
67public:
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);
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
83private:
84 struct Impl;
85 std::unique_ptr<Impl> impl_;
86};
87
88class ColormapTreeCell : public Widget {
89public:
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
103private:
104 struct Impl;
105 std::unique_ptr<Impl> impl_;
106};
107
108class TreeView : public Widget {
109 using Super = Widget;
110
111public:
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
136 void SetCanSelectItemsWithChildren(bool can_select);
137
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
154 std::function<void(ItemId)> on_selection_changed);
155
156private:
157 struct Impl;
158 std::unique_ptr<Impl> impl_;
159};
160
161} // namespace gui
162} // namespace visualization
163} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
ImGuiContext * context
Definition: Window.cpp:95
~CheckableTextTreeCell()
Definition: TreeView.cpp:66
std::shared_ptr< Checkbox > GetCheckbox()
Definition: TreeView.cpp:68
std::shared_ptr< Label > GetLabel()
Definition: TreeView.cpp:72
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:84
CheckableTextTreeCell(const char *text, bool is_checked, std::function< void(bool)> on_toggled)
Definition: TreeView.cpp:52
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:76
Definition: Color.h:35
std::shared_ptr< NumberEdit > GetNumberEdit()
Definition: TreeView.cpp:191
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:199
std::shared_ptr< ColorEdit > GetColorEdit()
Definition: TreeView.cpp:195
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:207
ColormapTreeCell(double value, const Color &color, std::function< void(double)> on_value_changed, std::function< void(const Color &)> on_color_changed)
Definition: TreeView.cpp:171
~ColormapTreeCell()
Definition: TreeView.cpp:189
std::shared_ptr< Checkbox > GetCheckbox()
Definition: TreeView.cpp:126
std::shared_ptr< ColorEdit > GetColorEdit()
Definition: TreeView.cpp:132
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:144
std::shared_ptr< Label > GetLabel()
Definition: TreeView.cpp:130
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:103
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:134
~LUTTreeCell()
Definition: TreeView.cpp:124
Definition: TreeView.h:108
Size CalcMinimumSize(const LayoutContext &context) const override
Definition: TreeView.cpp:373
std::vector< ItemId > GetItemChildren(ItemId parent_id) const
Definition: TreeView.cpp:327
ItemId AddTextItem(ItemId parent_id, const char *text)
Adds a text item to the tree.
Definition: TreeView.cpp:277
int ItemId
Definition: TreeView.h:112
void Clear()
Clears all the items.
Definition: TreeView.cpp:313
DrawResult Draw(const DrawContext &context) override
Definition: TreeView.cpp:383
ItemId AddItem(ItemId parent_id, std::shared_ptr< Widget > item)
Adds an item to the tree.
Definition: TreeView.cpp:255
void SetCanSelectItemsWithChildren(bool can_select)
Definition: TreeView.cpp:347
void RemoveItem(ItemId item_id)
Removes an item an all its children (if any) from the tree.
Definition: TreeView.cpp:282
ItemId GetRootItem() const
Definition: TreeView.cpp:253
~TreeView()
Definition: TreeView.cpp:251
ItemId GetSelectedItemId() const
Returns the currently selected item id in the tree.
Definition: TreeView.cpp:351
void Layout(const LayoutContext &context) override
Definition: TreeView.cpp:377
std::shared_ptr< Widget > GetItem(ItemId item_id) const
Returns item, or nullptr if item_id cannot be found.
Definition: TreeView.cpp:319
TreeView()
Definition: TreeView.cpp:245
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: TreeView.cpp:368
void SetSelectedItemId(ItemId item_id)
Selects the indicated item of the list. Does not call onValueChanged.
Definition: TreeView.cpp:359
bool GetCanSelectItemsWithChildren() const
Definition: TreeView.cpp:343
void SetOnSelectionChanged(std::function< void(ItemId)> on_selection_changed)
Definition: TreeView.cpp:363
Definition: Widget.h:68
Widget()
Definition: Widget.cpp:53
DrawResult
Definition: Widget.h:114
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:493
Definition: PinholeCameraIntrinsic.cpp:35
Definition: TreeView.cpp:222