![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <Application.h>
Classes | |
| class | EnvUnlocker |
| struct | Impl |
Public Member Functions | |
| virtual | ~Application () |
| void | Initialize () |
| void | Initialize (int argc, const char *argv[]) |
| void | Initialize (const char *resource_path) |
| Initializes the application, with a specific path to the resources. More... | |
| FontId | AddFont (const FontDescription &fd) |
| void | SetFont (FontId id, const FontDescription &fd) |
| void | Run () |
| Does not return until the UI is completely finished. More... | |
| void | Quit () |
| Closes all the windows, which exits as a result. More... | |
| void | RunInThread (std::function< void()> f) |
| void | PostToMainThread (Window *window, std::function< void()> f) |
| std::shared_ptr< Menu > | GetMenubar () const |
| void | SetMenubar (std::shared_ptr< Menu > menubar) |
| void | AddWindow (std::shared_ptr< Window > window) |
| Must be called on the same thread that calls Run() More... | |
| void | RemoveWindow (Window *window) |
| void | ShowMessageBox (const char *title, const char *message) |
| WindowSystem & | GetWindowSystem () const |
| const char * | GetResourcePath () const |
| const Theme & | GetTheme () const |
| double | Now () const |
| void | OnMenuItemSelected (Menu::ItemId itemId) |
| Delivers the itemId to the active window. Used internally. More... | |
| void | OnTerminate () |
| bool | RunOneTick (EnvUnlocker &unlocker, bool cleanup_if_no_windows=true) |
| void | SetWindowSystem (std::shared_ptr< WindowSystem > ws) |
| bool | UsingNativeWindows () const |
| void | VerifyIsInitialized () |
| const std::vector< FontDescription > & | GetFontDescriptions () const |
| std::shared_ptr< geometry::Image > | RenderToImage (rendering::Renderer &renderer, rendering::View *view, rendering::Scene *scene, int width, int height) |
| std::shared_ptr< geometry::Image > | RenderToDepthImage (rendering::Renderer &renderer, rendering::View *view, rendering::Scene *scene, int width, int height, bool z_in_view_space=false) |
Static Public Member Functions | |
| static Application & | GetInstance () |
Static Public Attributes | |
| static constexpr FontId | DEFAULT_FONT_ID = 0 |
| Identifier for font used by default for all UI elements. More... | |
Definition at line 39 of file Application.h.
|
virtual |
Definition at line 265 of file Application.cpp.
| FontId cloudViewer::visualization::gui::Application::AddFont | ( | const FontDescription & | fd | ) |
Adds a font. Must be called after Initialize() and before a window is created.
Definition at line 357 of file Application.cpp.
References SetFont().
Referenced by Initialize(), and cloudViewer::visualization::gui::pybind_gui_classes().
| void cloudViewer::visualization::gui::Application::AddWindow | ( | std::shared_ptr< Window > | window | ) |
Must be called on the same thread that calls Run()
Definition at line 457 of file Application.cpp.
Referenced by cloudViewer::visualization::Draw(), cloudViewer::visualization::GuiVisualizer::OnDragDropped(), cloudViewer::visualization::gui::pybind_gui_classes(), cloudViewer::visualization::app::RunViewer(), and ShowMessageBox().
| const std::vector< FontDescription > & cloudViewer::visualization::gui::Application::GetFontDescriptions | ( | ) | const |
Definition at line 423 of file Application.cpp.
|
static |
Definition at line 179 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::cleanup_filament_atexit(), cloudViewer::visualization::gui::Window::Close(), cloudViewer::visualization::gui::Window::DestroyWindow(), cloudViewer::visualization::Draw(), cloudViewer::visualization::webrtc_server::WebRTCWindowSystem::EnableWebRTC(), cloudViewer::visualization::gui::Window::GetContentRect(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::GetListOfIBLs(), cloudViewer::visualization::gui::Window::GetOSFrame(), cloudViewer::visualization::gui::Window::GetScaling(), cloudViewer::visualization::gui::Window::GetSize(), cloudViewer::visualization::gui::Window::GetWebRTCUID(), cloudViewer::visualization::gui::Window::GlobalToWindowCoord(), cloudViewer::visualization::gui::ImguiFilamentBridge::ImguiFilamentBridge(), cloudViewer::visualization::gui::InitializeForPython(), cloudViewer::visualization::gui::Window::IsActiveWindow(), cloudViewer::visualization::gui::Window::IsVisible(), cloudViewer::visualization::GuiVisualizer::LoadGeometry(), cloudViewer::visualization::gui::Menu::Menu(), cloudViewer::visualization::gui::SceneWidget::Mouse(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::OnAnimationTick(), cloudViewer::visualization::GuiVisualizer::OnDragDropped(), cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), cloudViewer::visualization::gui::Window::OnResize(), cloudViewer::visualization::gui::Window::PostRedraw(), cloudViewer::visualization::gui::pybind_gui_classes(), cloudViewer::visualization::gui::Window::RaiseToTop(), cloudViewer::visualization::gui::RenderToDepthImageWithoutWindow(), cloudViewer::visualization::gui::RenderToImageWithoutWindow(), cloudViewer::visualization::app::RunViewer(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::SetAnimating(), cloudViewer::visualization::GuiVisualizer::Impl::SetIBL(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::SetIBL(), cloudViewer::visualization::rendering::CloudViewerScene::SetLighting(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::SetOnAnimationTick(), cloudViewer::visualization::gui::Window::SetOSFrame(), cloudViewer::visualization::gui::Window::SetSize(), cloudViewer::visualization::gui::Window::SetTitle(), cloudViewer::visualization::gui::Window::Show(), ShowMessageBox(), cloudViewer::visualization::gui::ShowNativeAlert(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::ShowSettings(), cloudViewer::visualization::webrtc_server::WebRTCWindowSystem::StartWebRTCServer(), cloudViewer::visualization::gui::SceneWidget::Tick(), and cloudViewer::visualization::gui::Window::Window().
| std::shared_ptr< Menu > cloudViewer::visualization::gui::Application::GetMenubar | ( | ) | const |
Definition at line 434 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::Window::GetContentRect(), cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), cloudViewer::visualization::gui::pybind_gui_classes(), and cloudViewer::visualization::visualizer::O3DVisualizer::Impl::ShowSettings().
| const char * cloudViewer::visualization::gui::Application::GetResourcePath | ( | ) | const |
Definition at line 675 of file Application.cpp.
References cloudViewer::visualization::rendering::EngineInstance::GetResourcePath().
Referenced by cloudViewer::visualization::visualizer::O3DVisualizer::Impl::GetListOfIBLs(), cloudViewer::visualization::gui::ImguiFilamentBridge::ImguiFilamentBridge(), cloudViewer::visualization::gui::pybind_gui_classes(), and cloudViewer::visualization::rendering::CloudViewerScene::SetLighting().
| const Theme & cloudViewer::visualization::gui::Application::GetTheme | ( | ) | const |
This is primarily intended for use by the Window class. Any size-related fields (for example, fontSize) should be accessed through Window::GetTheme() as they are updated to reflect the pixel scaling on the monitor where the Window is displayed.
Definition at line 679 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::Window::Window().
| WindowSystem & cloudViewer::visualization::gui::Application::GetWindowSystem | ( | ) | const |
Definition at line 345 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::Window::Close(), cloudViewer::visualization::gui::Window::DestroyWindow(), cloudViewer::visualization::gui::Window::GetOSFrame(), cloudViewer::visualization::gui::Window::GetScaling(), cloudViewer::visualization::gui::Window::GetSize(), cloudViewer::visualization::gui::Window::GlobalToWindowCoord(), cloudViewer::visualization::gui::Window::IsActiveWindow(), cloudViewer::visualization::gui::Window::IsVisible(), cloudViewer::visualization::gui::Window::OnResize(), cloudViewer::visualization::gui::Window::PostRedraw(), cloudViewer::visualization::gui::Window::RaiseToTop(), cloudViewer::visualization::gui::Window::SetOSFrame(), cloudViewer::visualization::gui::Window::SetSize(), cloudViewer::visualization::gui::Window::SetTitle(), cloudViewer::visualization::gui::Window::Show(), and cloudViewer::visualization::gui::Window::Window().
| void cloudViewer::visualization::gui::Application::Initialize | ( | ) |
Initializes the application, and in particular, finds the path for the resources. If you can provide the argc/argv arguments it is more reliable.
Definition at line 267 of file Application.cpp.
References cloudViewer::utility::filesystem::GetWorkingDirectory(), and cloudViewer::t::geometry::path.
Referenced by cloudViewer::visualization::Draw(), Initialize(), and cloudViewer::visualization::gui::InitializeForPython().
| void cloudViewer::visualization::gui::Application::Initialize | ( | const char * | resource_path | ) |
Initializes the application, with a specific path to the resources.
Definition at line 283 of file Application.cpp.
References AddFont(), cloudViewer::utility::filesystem::FileExists(), LogError, cloudViewer::visualization::gui::NORMAL, cloudViewer::visualization::gui::FontDescription::SANS_SERIF, and cloudViewer::visualization::rendering::EngineInstance::SetResourcePath().
| void cloudViewer::visualization::gui::Application::Initialize | ( | int | argc, |
| const char * | argv[] | ||
| ) |
Initializes the application, and in particular, finds the path for the resources. If you can provide the argc/argv arguments it is more reliable.
Definition at line 279 of file Application.cpp.
References Initialize().
| double cloudViewer::visualization::gui::Application::Now | ( | ) | const |
Returns high-resolution counter value (in seconds). Not valid until Initialize() is called.
Definition at line 427 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::SceneWidget::Mouse(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::OnAnimationTick(), cloudViewer::visualization::gui::pybind_gui_classes(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::SetAnimating(), cloudViewer::visualization::visualizer::O3DVisualizer::Impl::SetOnAnimationTick(), and cloudViewer::visualization::gui::SceneWidget::Tick().
| void cloudViewer::visualization::gui::Application::OnMenuItemSelected | ( | Menu::ItemId | itemId | ) |
Delivers the itemId to the active window. Used internally.
Definition at line 513 of file Application.cpp.
| void cloudViewer::visualization::gui::Application::OnTerminate | ( | ) |
Cleanup everything right now. An example of usage is Cocoa's -applicationWillTermiate: AppDelegate message. Using Quit would result in a crash (and an unsightly message from macOS) due to destructing the windows at the wrong time.
Definition at line 487 of file Application.cpp.
References Quit().
Referenced by cloudViewer::visualization::gui::cleanup_filament_atexit().
| void cloudViewer::visualization::gui::Application::PostToMainThread | ( | Window * | window, |
| std::function< void()> | f | ||
| ) |
Runs f on the main thread at some point in the near future. Proper context will be setup for window. f will block the UI, so it should run quickly. If you need to do something slow (e.g. load a file) consider using RunInThread() and have the function pass off UI calls to PostToMainThread().
Definition at line 670 of file Application.cpp.
Referenced by cloudViewer::visualization::GuiVisualizer::LoadGeometry(), and cloudViewer::visualization::gui::pybind_gui_classes().
| void cloudViewer::visualization::gui::Application::Quit | ( | ) |
Closes all the windows, which exits as a result.
Definition at line 481 of file Application.cpp.
References RemoveWindow().
Referenced by cloudViewer::visualization::GuiVisualizer::OnMenuItemSelected(), OnTerminate(), and cloudViewer::visualization::gui::pybind_gui_classes().
| void cloudViewer::visualization::gui::Application::RemoveWindow | ( | Window * | window | ) |
Must be called on the same thread that calls Run(). This is normally called from Window::Close() and should not need to be called in user code.
Definition at line 463 of file Application.cpp.
References cloudViewer::visualization::gui::Window::Show().
Referenced by cloudViewer::visualization::gui::Window::Close(), and Quit().
| std::shared_ptr< geometry::Image > cloudViewer::visualization::gui::Application::RenderToDepthImage | ( | rendering::Renderer & | renderer, |
| rendering::View * | view, | ||
| rendering::Scene * | scene, | ||
| int | width, | ||
| int | height, | ||
| bool | z_in_view_space = false |
||
| ) |
Definition at line 705 of file Application.cpp.
References cloudViewer::visualization::rendering::Renderer::BeginFrame(), callback, cloudViewer::visualization::rendering::Renderer::EndFrame(), height, cloudViewer::visualization::rendering::Renderer::RenderToDepthImage(), cloudViewer::visualization::rendering::View::SetViewport(), and width.
Referenced by cloudViewer::visualization::gui::RenderToDepthImageWithoutWindow().
| std::shared_ptr< geometry::Image > cloudViewer::visualization::gui::Application::RenderToImage | ( | rendering::Renderer & | renderer, |
| rendering::View * | view, | ||
| rendering::Scene * | scene, | ||
| int | width, | ||
| int | height | ||
| ) |
Returns the scene rendered to an image. This MUST NOT be called while in Run(). It is intended for use when no windows are shown. If you need to render from a GUI, use Scene::RenderToImage().
Definition at line 681 of file Application.cpp.
References cloudViewer::visualization::rendering::Renderer::BeginFrame(), callback, cloudViewer::visualization::rendering::Renderer::EndFrame(), height, cloudViewer::visualization::rendering::Renderer::RenderToImage(), cloudViewer::visualization::rendering::View::SetViewport(), and width.
Referenced by cloudViewer::visualization::gui::RenderToImageWithoutWindow().
| void cloudViewer::visualization::gui::Application::Run | ( | ) |
Does not return until the UI is completely finished.
Definition at line 530 of file Application.cpp.
References RunOneTick().
Referenced by cloudViewer::visualization::Draw().
| void cloudViewer::visualization::gui::Application::RunInThread | ( | std::function< void()> | f | ) |
Runs
| f | in a separate thread. Do NOT call UI functions in f; if you have a long running function that needs to call UI functions (e.g. updating a progress bar), have your function call PostToMainThread() with code that will do the UI (note: your function may finish before the code given to PostToMainThread will run, so if using lambdas, capture by copy and make sure whatever you use will still be alive). |
Definition at line 664 of file Application.cpp.
Referenced by cloudViewer::visualization::GuiVisualizer::LoadGeometry(), and cloudViewer::visualization::gui::pybind_gui_classes().
| bool cloudViewer::visualization::gui::Application::RunOneTick | ( | EnvUnlocker & | unlocker, |
| bool | cleanup_if_no_windows = true |
||
| ) |
For internal use. Returns true if the run loop has not finished, and false if the last window has closed or Quit() has been called. EnvUnlocker allows an external environment to provide a way to unlock the environment while we wait for the next event. This is useful to release the Python GIL, for example. Callers of of CloudViewer's GUI from languages such as scripting languages which do not expect the author to need to clean up after themselves may want to write their own Run() function that calls RunOneTick() with cleanup_if_no_windows=false and schedule a call to OnTerminate() with atexit().
Definition at line 535 of file Application.cpp.
References cloudViewer::utility::filesystem::DirectoryExists(), cloudViewer::utility::filesystem::FileExists(), cloudViewer::visualization::rendering::EngineInstance::GetResourcePath(), and cloudViewer::visualization::gui::ShowNativeAlert().
Referenced by cloudViewer::visualization::gui::pybind_gui_classes(), and Run().
| void cloudViewer::visualization::gui::Application::SetFont | ( | FontId | id, |
| const FontDescription & | fd | ||
| ) |
Replaces font. Must be called after Initialize() and before a window is created.
Definition at line 364 of file Application.cpp.
References cloudViewer::visualization::gui::BOLD, cloudViewer::visualization::gui::BOLD_ITALIC, DEFAULT_FONT_ID, cloudViewer::visualization::gui::FindFontPath(), cloudViewer::visualization::gui::ITALIC, LogWarning, cloudViewer::visualization::gui::FontDescription::MONOSPACE, cloudViewer::visualization::gui::NORMAL, cloudViewer::t::geometry::path, cloudViewer::visualization::gui::FontDescription::point_size_, and cloudViewer::visualization::gui::FontDescription::SANS_SERIF.
Referenced by AddFont(), and cloudViewer::visualization::gui::pybind_gui_classes().
| void cloudViewer::visualization::gui::Application::SetMenubar | ( | std::shared_ptr< Menu > | menubar | ) |
Definition at line 438 of file Application.cpp.
Referenced by cloudViewer::visualization::gui::pybind_gui_classes().
| void cloudViewer::visualization::gui::Application::SetWindowSystem | ( | std::shared_ptr< WindowSystem > | ws | ) |
Sets the WindowSystem to given object. Can be used to override the default GLFWWindowSystem (e.g. BitmapWindowSystem). Must be called before creating any Windows.
Definition at line 349 of file Application.cpp.
References LogError.
Referenced by cloudViewer::visualization::webrtc_server::WebRTCWindowSystem::EnableWebRTC().
| void cloudViewer::visualization::gui::Application::ShowMessageBox | ( | const char * | title, |
| const char * | message | ||
| ) |
Creates a message box window the next time the event loop processes. This message box will be a separate window and not associated with any of the other windows shown with AddWindow(). THIS FUNCTION SHOULD BE USED ONLY AS A LAST RESORT! If you have a window, you should use Window::ShowMessageBox() so that the message box will be modal to that window. If you do not have a window it is better to use ShowNativeAlert(). If the platform does not have an alert (like Linux), then this can be used as a last resort.
Definition at line 184 of file Application.cpp.
References AddWindow(), cloudViewer::visualization::gui::Window::FLAG_TOPMOST, GetInstance(), LogInfo, and cloudViewer::visualization::gui::Horiz::MakeCentered().
Referenced by cloudViewer::visualization::gui::ShowNativeAlert().
| bool cloudViewer::visualization::gui::Application::UsingNativeWindows | ( | ) | const |
Returns true if using the native OS window system, false otherwise. This is useful for choosing to display some features that are only useful with native windows. For instance, when embedded in a Jupyter notebook, a "Close Window" menu item is not necessary.
Definition at line 339 of file Application.cpp.
| void cloudViewer::visualization::gui::Application::VerifyIsInitialized | ( | ) |
Verifies that Initialize() has been called, printing out an error and exiting if not.
Definition at line 322 of file Application.cpp.
References LogError, and LogWarning.
Referenced by cloudViewer::visualization::gui::Window::Window().
|
staticconstexpr |
Identifier for font used by default for all UI elements.
Definition at line 57 of file Application.h.
Referenced by cloudViewer::visualization::gui::Window::OnResize(), cloudViewer::visualization::gui::pybind_gui_classes(), and SetFont().