Lagrange
viewport.h
1/*
2 * Copyright 2021 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/ui/api.h>
15#include <lagrange/ui/components/Viewport.h>
16#include <lagrange/ui/panels/ViewportPanel.h>
17
18namespace lagrange {
19namespace ui {
20
22LA_UI_API Entity add_viewport(Registry& registry, Entity camera_entity, bool srgb = false);
23
24LA_UI_API void instance_camera_to_viewports(Registry& registry, Entity source_viewport);
25LA_UI_API void copy_camera_to_viewports(Registry& registry, Entity source_viewport);
26
27/*
28 Focused Viewport
29*/
30
33LA_UI_API ViewportPanel* get_focused_viewport_panel(Registry& registry);
34
37LA_UI_API Entity get_focused_viewport_entity(Registry& registry);
38
41LA_UI_API ViewportComponent* get_focused_viewport(Registry& registry);
42
43
44/*
45 Focused Camera
46*/
47// Focused Camera (entity)
49LA_UI_API Entity get_focused_camera_entity(Registry& registry);
50
51// Focused Camera (component reference)
53LA_UI_API Camera* get_focused_camera(Registry& registry);
54
55// Camera component of entity e
56LA_UI_API Camera& get_camera(Registry& registry, Entity e);
57
58/*
59 Hovered Viewport
60*/
61
62// Hovered Viewport UI Panel (entity)
64LA_UI_API Entity get_hovered_viewport_panel_entity(Registry& registry);
65
66// Hovered Viewport (entity)
68LA_UI_API Entity get_hovered_viewport_entity(Registry& registry);
69
70
71
72
82LA_UI_API bool camera_focus_and_fit(
83 Registry& registry,
84 Entity camera,
85 bool focus = true,
86 bool fit = true,
87 float duration_seconds = 1.0f,
88 const std::function<bool(Registry& r, Entity e)>& filter = nullptr);
89
91LA_UI_API void camera_focus_and_fit(Registry& registry);
92
93/*
94 Internal offscreen viewport utilities
95*/
96LA_UI_API Entity get_selection_viewport_entity(const Registry& registry);
97LA_UI_API Entity get_objectid_viewport_entity(const Registry& registry);
98LA_UI_API void add_selection_outline_post_process(
99 Registry& registry,
100 Entity viewport_entity,
101 const Color& selection_color);
102
103
104} // namespace ui
105} // namespace lagrange
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
LA_UI_API ViewportPanel * get_focused_viewport_panel(Registry &registry)
Focused Viewport UI Panel Returns nullptr if there is no focused viewport.
Definition: viewport.cpp:62
LA_UI_API bool camera_focus_and_fit(Registry &registry, Entity camera, bool focus=true, bool fit=true, float duration_seconds=1.0f, const std::function< bool(Registry &r, Entity e)> &filter=nullptr)
Adjusts camera to fit the scene bounding box over the next several frames.
Definition: viewport.cpp:124
LA_UI_API Entity get_hovered_viewport_panel_entity(Registry &registry)
Returns NullEntity if there is no hovered viewport.
Definition: viewport.cpp:91
LA_UI_API Entity get_focused_viewport_entity(Registry &registry)
Focused Viewport (entity) Returns NullEntity if there is no focused viewport.
Definition: viewport.cpp:69
LA_UI_API ViewportComponent * get_focused_viewport(Registry &registry)
Focused Viewport (component reference) Returns nullptr if there is no focused viewport.
Definition: viewport.cpp:76
LA_UI_API Entity get_hovered_viewport_entity(Registry &registry)
Returns NullEntity if there is no hovered viewport.
Definition: viewport.cpp:102
LA_UI_API Entity add_viewport(Registry &registry, Entity camera_entity, bool srgb=false)
Creates an offscreen viewport with given camera. Create ViewportPanel to show it on screen.
Definition: viewport.cpp:179
LA_UI_API Entity get_focused_camera_entity(Registry &registry)
Returns NullEntity if there is no focused viewport.
Definition: viewport.cpp:83
LA_UI_API Camera * get_focused_camera(Registry &registry)
Returns nullptr if there is no focused viewport.
Definition: viewport.cpp:116
Main namespace for Lagrange.
Definition: AABBIGL.h:30