Open3D (C++ API)  0.15.1
UIImage.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 
31 
32 namespace open3d {
33 
34 namespace t {
35 namespace geometry {
36 class Image;
37 }
38 }
39 
40 namespace geometry {
41 class Image;
42 } // namespace geometry
43 
44 namespace visualization {
45 
46 namespace rendering {
47 class Renderer;
48 }
49 
50 namespace gui {
51 
52 class UIImage {
53 public:
54  explicit UIImage(const char* image_path);
55  explicit UIImage(std::shared_ptr<geometry::Image> image);
56  explicit UIImage(std::shared_ptr<t::geometry::Image> image);
61  float u0 = 0.0f,
62  float v0 = 0.0f,
63  float u1 = 1.0f,
64  float v1 = 1.0f);
65  ~UIImage();
66 
69  void UpdateImage(std::shared_ptr<geometry::Image> image);
70 
73  void UpdateImage(std::shared_ptr<t::geometry::Image> image);
74 
75  enum class Scaling {
76  NONE,
77  ANY,
78  ASPECT
79  };
81  Scaling GetScaling() const;
82 
84  const Widget::Constraints& constraints) const;
85 
86  struct DrawParams {
87  // Default values are to make GCC happy and contented,
88  // pos and size don't have reasonable defaults.
89  float pos_x = 0.0f;
90  float pos_y = 0.0f;
91  float width = 0.0f;
92  float height = 0.0f;
93  float u0 = 0.0f;
94  float v0 = 0.0f;
95  float u1 = 1.0f;
96  float v1 = 1.0f;
98  bool image_size_changed = false;
99  };
101  const Rect& frame) const;
102 
103 private:
104  struct Impl;
105  std::unique_ptr<Impl> impl_;
106 };
107 
108 } // namespace gui
109 } // namespace visualization
110 } // namespace open3d
Rect frame
Definition: BitmapWindowSystem.cpp:49
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:228
float scaling
Definition: Window.cpp:97
ImGuiContext * context
Definition: Window.cpp:95
Definition: UIImage.h:52
UIImage(const char *image_path)
Definition: UIImage.cpp:75
Scaling GetScaling() const
Definition: UIImage.cpp:171
~UIImage()
Definition: UIImage.cpp:153
Size CalcPreferredSize(const LayoutContext &context, const Widget::Constraints &constraints) const
Definition: UIImage.cpp:173
void SetScaling(Scaling scaling)
Definition: UIImage.cpp:169
Scaling
Definition: UIImage.h:75
@ ASPECT
Scales to any size and aspect ratio.
void UpdateImage(std::shared_ptr< geometry::Image > image)
Definition: UIImage.cpp:159
DrawParams CalcDrawParams(visualization::rendering::Renderer &renderer, const Rect &frame) const
Definition: UIImage.cpp:196
Definition: PinholeCameraIntrinsic.cpp:35
visualization::rendering::TextureHandle texture
Definition: UIImage.h:97
bool image_size_changed
Definition: UIImage.h:98