![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <Window.h>
Classes | |
| struct | Impl |
Public Member Functions | |
| Window (const std::string &title, int flags=0) | |
| Window (const std::string &title, int width, int height, int flags=0) | |
| Window (const std::string &title, int x, int y, int width, int height, int flags=0) | |
| virtual | ~Window () |
| const Theme & | GetTheme () const |
| visualization::rendering::Renderer & | GetRenderer () const |
| Rect | GetOSFrame () const |
| void | SetOSFrame (const Rect &r) |
| const char * | GetTitle () const |
| void | SetTitle (const char *title) |
| void | SizeToFit () |
| void | SetSize (const Size &size) |
| Sets the size of the window in pixels. Includes menubar on Linux. More... | |
| Size | GetSize () const |
| Rect | GetContentRect () const |
| float | GetScaling () const |
| Returns the scaling factor from OS pixels to device pixels. More... | |
| Point | GlobalToWindowCoord (int global_x, int global_y) |
| Returns the global point (in OS pixels) in window local coordinates. More... | |
| bool | IsVisible () const |
| void | Show (bool vis=true) |
| void | Close () |
| void | SetNeedsLayout () |
| Instructs the window to relayout before the next draw. More... | |
| void | PostRedraw () |
| void | SetTopmost (bool topmost) |
| void | RaiseToTop () const |
| bool | IsActiveWindow () const |
| void | SetFocusWidget (Widget *w) |
| Sets. More... | |
| void | AddChild (std::shared_ptr< Widget > w) |
| void | SetOnMenuItemActivated (Menu::ItemId item_id, std::function< void()> callback) |
| void | SetOnTickEvent (std::function< bool()> callback) |
| void | SetOnClose (std::function< bool()> callback) |
| void | SetOnKeyEvent (std::function< bool(const KeyEvent &)> callback) |
| void | ShowDialog (std::shared_ptr< Dialog > dlg) |
| void | CloseDialog () |
| Closes the dialog. More... | |
| void | ShowMessageBox (const char *title, const char *message) |
| void | DestroyWindow () |
| virtual void | OnMenuItemSelected (Menu::ItemId item_id) |
| virtual void | OnDragDropped (const char *path) |
| void | ShowMenu (bool show) |
| int | GetMouseMods () const |
| std::string | GetWebRTCUID () const |
| void | OnDraw () |
| void | OnResize () |
| void | OnMouseEvent (const MouseEvent &e) |
| void | OnKeyEvent (const KeyEvent &e) |
| void | OnTextInput (const TextInputEvent &e) |
| void | OnTickEvent (const TickEvent &e) |
| WindowSystem::OSWindow | GetOSWindow () const |
Static Public Attributes | |
| static const int | FLAG_HIDDEN = (1 << 0) |
| static const int | FLAG_TOPMOST = (1 << 1) |
Protected Member Functions | |
| virtual Size | CalcPreferredSize () |
| virtual void | Layout (const LayoutContext &context) |
| LayoutContext | GetLayoutContext () |
| const std::vector< std::shared_ptr< Widget > > & | GetChildren () const |
|
explicit |
Creates a Window that is auto-sized and centered. Window creation is NOT thread-safe. Window must be created on the same thread that calls Application::Run().
| Window::Window | ( | const std::string & | title, |
| int | width, | ||
| int | height, | ||
| int | flags = 0 |
||
| ) |
Creates a Window that is centered. Window creation is NOT thread-safe. Window must be created on the same thread that calls Application::Run().
| Window::Window | ( | const std::string & | title, |
| int | x, | ||
| int | y, | ||
| int | width, | ||
| int | height, | ||
| int | flags = 0 |
||
| ) |
Creates a Window. Window creation is NOT thread-safe. Window must be created on the same thread that calls Application::Run().
References cloudViewer::visualization::gui::colorToImgui(), FLAG_HIDDEN, cloudViewer::visualization::gui::WindowSystem::FLAG_HIDDEN, FLAG_TOPMOST, cloudViewer::visualization::gui::WindowSystem::FLAG_TOPMOST, float, cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetTheme(), cloudViewer::visualization::gui::Application::GetWindowSystem(), height, cloudViewer::visualization::gui::KEY_BACKSPACE, cloudViewer::visualization::gui::KEY_DELETE, cloudViewer::visualization::gui::KEY_DOWN, cloudViewer::visualization::gui::KEY_END, cloudViewer::visualization::gui::KEY_ENTER, cloudViewer::visualization::gui::KEY_ESCAPE, cloudViewer::visualization::gui::KEY_HOME, cloudViewer::visualization::gui::KEY_INSERT, cloudViewer::visualization::gui::KEY_LEFT, cloudViewer::visualization::gui::KEY_PAGEDOWN, cloudViewer::visualization::gui::KEY_PAGEUP, cloudViewer::visualization::gui::KEY_RIGHT, cloudViewer::visualization::gui::KEY_TAB, cloudViewer::visualization::gui::KEY_UP, scaling, theme, cloudViewer::visualization::gui::Application::VerifyIsInitialized(), width, x, and y.
|
virtual |
References DestroyWindow().
| void Window::AddChild | ( | std::shared_ptr< Widget > | w | ) |
|
protectedvirtual |
Returns the preferred size of the window. The window is not obligated to honor this size. If all children of the window are layouts, this function does not need to be overridden. This function can only be called after MakeDrawContextCurrent() has been called.
References cloudViewer::visualization::gui::Rect::GetBottom(), GetLayoutContext(), cloudViewer::visualization::gui::Rect::GetRight(), and cloudViewer::visualization::gui::Rect::UnionedWith().
Referenced by OnResize(), and SizeToFit().
| void Window::Close | ( | ) |
Closes the window and destroys it (unless the close callback cancels the close)
References cloudViewer::visualization::gui::WindowSystem::CancelUserClose(), cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetWindowSystem(), and cloudViewer::visualization::gui::Application::RemoveWindow().
Referenced by OnKeyEvent().
| void Window::CloseDialog | ( | ) |
Closes the dialog.
References PostRedraw(), and SetFocusWidget().
Referenced by cloudViewer::visualization::GuiVisualizer::LoadGeometry(), cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), ShowDialog(), and ShowMessageBox().
| void Window::DestroyWindow | ( | ) |
This is for internal use in rare circumstances when the destructor will not be called in a timely fashion.
References cloudViewer::visualization::gui::WindowSystem::DestroyWindow(), cloudViewer::visualization::gui::Application::GetInstance(), and cloudViewer::visualization::gui::Application::GetWindowSystem().
Referenced by ~Window().
|
protected |
| Rect Window::GetContentRect | ( | ) | const |
Returns the rectangle that is available to widgets to use; excludes the menubar.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetMenubar(), GetSize(), GetTheme(), and size.
Referenced by cloudViewer::visualization::GuiVisualizer::Layout(), Layout(), cloudViewer::visualization::visualizer::O3DVisualizer::Layout(), and ShowDialog().
|
protected |
References GetTheme().
Referenced by CalcPreferredSize(), and ShowDialog().
| int Window::GetMouseMods | ( | ) | const |
| Rect Window::GetOSFrame | ( | ) | const |
Gets the window's size and position in OS pixels, not actual device pixels.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::WindowSystem::GetWindowPos(), cloudViewer::visualization::gui::Application::GetWindowSystem(), and size.
Referenced by OnResize().
| WindowSystem::OSWindow Window::GetOSWindow | ( | ) | const |
| visualization::rendering::Renderer & Window::GetRenderer | ( | ) | const |
Referenced by cloudViewer::visualization::GuiVisualizer::SetIBL().
| float Window::GetScaling | ( | ) | const |
Returns the scaling factor from OS pixels to device pixels.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::WindowSystem::GetWindowScaleFactor(), and cloudViewer::visualization::gui::Application::GetWindowSystem().
Referenced by OnResize().
| Size Window::GetSize | ( | ) | const |
Returns the total interior size of window, in pixels. On Linux this includes the menubar.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::WindowSystem::GetWindowSizePixels(), and cloudViewer::visualization::gui::Application::GetWindowSystem().
Referenced by GetContentRect(), OnResize(), and cloudViewer::visualization::gui::ImguiFilamentBridge::OnWindowResized().
| const Theme & Window::GetTheme | ( | ) | const |
| const char * Window::GetTitle | ( | ) | const |
| std::string Window::GetWebRTCUID | ( | ) | const |
Returns the window's unique identifier when WebRTCWindowSystem is in use. Returns "window_undefined" if the window system is not WebRTCWindowSystem.
References cloudViewer::visualization::gui::Application::GetInstance().
| Point Window::GlobalToWindowCoord | ( | int | global_x, |
| int | global_y | ||
| ) |
Returns the global point (in OS pixels) in window local coordinates.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::WindowSystem::GetWindowPos(), and cloudViewer::visualization::gui::Application::GetWindowSystem().
| bool Window::IsActiveWindow | ( | ) | const |
| bool Window::IsVisible | ( | ) | const |
|
protectedvirtual |
Lays out all the widgets in the window. If all children of the window are layouts, this function does not need to be overridden.
Reimplemented in cloudViewer::visualization::GuiVisualizer, and cloudViewer::visualization::visualizer::O3DVisualizer.
References context, and GetContentRect().
Referenced by cloudViewer::visualization::GuiVisualizer::Layout(), and cloudViewer::visualization::visualizer::O3DVisualizer::Layout().
|
virtual |
Reimplemented in cloudViewer::visualization::GuiVisualizer.
| void Window::OnDraw | ( | ) |
| void Window::OnKeyEvent | ( | const KeyEvent & | e | ) |
References cloudViewer::visualization::gui::ALT, Close(), cloudViewer::visualization::gui::CTRL, cloudViewer::visualization::gui::KeyEvent::DOWN, e, cloudViewer::visualization::gui::KEY_ALT, cloudViewer::visualization::gui::KEY_ESCAPE, cloudViewer::visualization::gui::KEY_LCTRL, cloudViewer::visualization::gui::KEY_LSHIFT, cloudViewer::visualization::gui::KEY_META, cloudViewer::visualization::gui::KEY_RCTRL, cloudViewer::visualization::gui::KEY_RSHIFT, cloudViewer::visualization::gui::META, PostRedraw(), cloudViewer::visualization::gui::SHIFT, and cloudViewer::visualization::gui::KeyEvent::UP.
|
virtual |
Reimplemented in cloudViewer::visualization::GuiVisualizer.
References callback, and PostRedraw().
| void Window::OnMouseEvent | ( | const MouseEvent & | e | ) |
References cloudViewer::visualization::gui::SceneWidget::BEST, cloudViewer::visualization::gui::MouseEvent::BUTTON_DOWN, cloudViewer::visualization::gui::MouseEvent::BUTTON_UP, cloudViewer::visualization::gui::Widget::CONSUMED, cloudViewer::visualization::gui::Rect::Contains(), context, cloudViewer::visualization::gui::MouseEvent::DRAG, e, cloudViewer::visualization::gui::MouseEvent::MOVE, PostRedraw(), result, SetFocusWidget(), and cloudViewer::visualization::gui::MouseEvent::WHEEL.
| void Window::OnResize | ( | ) |
References CalcPreferredSize(), cloudViewer::visualization::gui::Application::DEFAULT_FONT_ID, cloudViewer::visualization::gui::SceneWidget::FAST, cloudViewer::visualization::gui::Application::GetInstance(), GetOSFrame(), GetScaling(), cloudViewer::visualization::gui::WindowSystem::GetScreenSize(), GetSize(), cloudViewer::visualization::gui::Application::GetWindowSystem(), cloudViewer::visualization::gui::Rect::height, PostRedraw(), cloudViewer::visualization::gui::WindowSystem::ResizeRenderer(), scaling, size, cloudViewer::visualization::gui::Rect::width, x, and y.
| void Window::OnTextInput | ( | const TextInputEvent & | e | ) |
References e, and PostRedraw().
| void Window::OnTickEvent | ( | const TickEvent & | e | ) |
References e, PostRedraw(), and cloudViewer::visualization::gui::Widget::REDRAW.
| void Window::PostRedraw | ( | ) |
Sends a draw event to the window through the operating system's event queue.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetWindowSystem(), and cloudViewer::visualization::gui::WindowSystem::PostRedrawEvent().
Referenced by CloseDialog(), OnDraw(), OnKeyEvent(), OnMenuItemSelected(), OnMouseEvent(), OnResize(), OnTextInput(), OnTickEvent(), and cloudViewer::visualization::GuiVisualizer::SetIBL().
| void Window::RaiseToTop | ( | ) | const |
| void Window::SetFocusWidget | ( | Widget * | w | ) |
Sets.
| w | as widget with text focus. |
Referenced by CloseDialog(), OnMouseEvent(), and cloudViewer::visualization::GuiVisualizer::Impl::SetMouseControls().
| void Window::SetNeedsLayout | ( | ) |
Instructs the window to relayout before the next draw.
Referenced by cloudViewer::visualization::visualizer::O3DVisualizer::AddAction(), cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), and ShowMenu().
| void Window::SetOnClose | ( | std::function< bool()> | callback | ) |
Sets a callback that will be called immediately before the window is closed. Callback should return true if the window should continue closing or false to cancel the close.
References callback.
| void Window::SetOnKeyEvent | ( | std::function< bool(const KeyEvent &)> | callback | ) |
Sets a callback that will intercept key event dispatching to focused widget. Callback should return true to stop more dispatching or false to dispatch to focused widget.
References callback.
| void Window::SetOnMenuItemActivated | ( | Menu::ItemId | item_id, |
| std::function< void()> | callback | ||
| ) |
Sets a callback for menu items. If you inherit from Window you can also override OnMenuItemSelected(); however, you should choose one or the other, but don't use both.
References callback.
Referenced by cloudViewer::visualization::visualizer::O3DVisualizer::AddAction(), and cloudViewer::visualization::visualizer::O3DVisualizer::O3DVisualizer().
| void Window::SetOnTickEvent | ( | std::function< bool()> | callback | ) |
Sets a callback that will be called on every UI tick (about 10 msec). Callback should return true if a redraw is required (i.e. the UI or a 3D scene has changed), false otherwise.
References callback.
| void Window::SetOSFrame | ( | const Rect & | r | ) |
Sets the window's size and position in OS pixels, not actual device pixels.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetWindowSystem(), cloudViewer::visualization::gui::Rect::height, cloudViewer::visualization::gui::WindowSystem::SetWindowPos(), cloudViewer::visualization::gui::Rect::width, cloudViewer::visualization::gui::Rect::x, and cloudViewer::visualization::gui::Rect::y.
| void Window::SetSize | ( | const Size & | size | ) |
Sets the size of the window in pixels. Includes menubar on Linux.
References cloudViewer::visualization::gui::Application::GetInstance(), cloudViewer::visualization::gui::Application::GetWindowSystem(), height, scaling, cloudViewer::visualization::gui::WindowSystem::SetWindowSize(), size, and width.
Referenced by SizeToFit().
| void Window::SetTitle | ( | const char * | title | ) |
| void cloudViewer::visualization::gui::Window::SetTopmost | ( | bool | topmost | ) |
| void Window::Show | ( | bool | vis = true | ) |
| void Window::ShowDialog | ( | std::shared_ptr< Dialog > | dlg | ) |
Shows the dialog. If a dialog is currently being shown it will be closed.
References CloseDialog(), context, GetContentRect(), and GetLayoutContext().
Referenced by cloudViewer::visualization::GuiVisualizer::LoadGeometry(), cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), and ShowMessageBox().
| void Window::ShowMenu | ( | bool | show | ) |
References SetNeedsLayout().
| void Window::ShowMessageBox | ( | const char * | title, |
| const char * | message | ||
| ) |
References CloseDialog(), cloudViewer::visualization::gui::Theme::font_size, GetTheme(), cloudViewer::visualization::gui::Horiz::MakeCentered(), and ShowDialog().
Referenced by cloudViewer::visualization::GuiVisualizer::ExportCurrentImage(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::ExportCurrentImage(), and cloudViewer::visualization::GuiVisualizer::LoadGeometry().
| void Window::SizeToFit | ( | ) |
Auto-sizes the window to the results of CalcPreferredSize(), which by default is the size that the layouts of the window want.
References CalcPreferredSize(), and SetSize().
|
static |
Referenced by Window().
|
static |
Referenced by cloudViewer::visualization::gui::Application::ShowMessageBox(), and Window().