Lagrange
SelectionContext.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/Entity.h>
15#include <lagrange/ui/components/Selection.h>
16#include <lagrange/ui/types/Camera.h>
17#include <lagrange/ui/types/Frustum.h>
18#include <Eigen/Eigen>
19
20namespace lagrange {
21namespace ui {
22
25{
26 // Registered element type using register_tool_type
27 entt::id_type element_type;
28
31 Entity active_viewport = NullEntity;
32
34 bool active = false;
35
37 bool marquee_active = false;
38
39 /*
40 Screen space
41 */
42
44 Eigen::Vector2f screen_begin;
45
47 Eigen::Vector2f screen_end;
48
50 Eigen::Vector2f screen_position;
51
52 /*
53 Viewport space (clipped)
54 */
55
57 Eigen::Vector2i viewport_min;
58
60 Eigen::Vector2i viewport_max;
61
63 Eigen::Vector2i viewport_position;
64
65
67 Eigen::Vector3f ray_origin;
68
70 Eigen::Vector3f ray_dir;
71
74
77 float neighbourhood_frustum_radius = 10.0f; // px
78
81
84
86 SelectionBehavior behavior = SelectionBehavior::SET;
87
89 bool select_backfacing = false;
90};
91
92
93} // namespace ui
94} // namespace lagrange
Camera class.
Definition: Camera.h:38
Frustum defined using 6 planes.
Definition: Frustum.h:43
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Global component with information about current viewport selection.
Definition: SelectionContext.h:25
bool active
Is selection active (are the selection keys down?)
Definition: SelectionContext.h:34
Frustum onepx_frustum
Frustum in one pixel diameter.
Definition: SelectionContext.h:80
Camera camera
Copy of current camera.
Definition: SelectionContext.h:83
bool marquee_active
Is marquee (rectangle) selection active.
Definition: SelectionContext.h:37
Eigen::Vector2i viewport_position
Current selection position.
Definition: SelectionContext.h:63
Eigen::Vector2i viewport_min
Beginning of selection rectangle (always lower coordinate than end)
Definition: SelectionContext.h:57
bool select_backfacing
Select backfacing objects/elements.
Definition: SelectionContext.h:89
Eigen::Vector3f ray_origin
Current mouse position induced ray origin.
Definition: SelectionContext.h:67
Eigen::Vector2i viewport_max
End of selection rectangle (always greater coordinate than begin)
Definition: SelectionContext.h:60
Eigen::Vector2f screen_end
End of selection rectangle (coordinates can be lower than begin)
Definition: SelectionContext.h:47
Frustum neighbourhood_frustum
Frustum in a radius.
Definition: SelectionContext.h:76
Eigen::Vector2f screen_begin
Beginning of selection rectangle (coordinates can be greater than end)
Definition: SelectionContext.h:44
Frustum frustum
Frustum, set if marquee is active.
Definition: SelectionContext.h:73
Entity active_viewport
In which viewport is the selection happening Can be null or invalid if no viewport is hovered.
Definition: SelectionContext.h:31
Eigen::Vector2f screen_position
Current selection position.
Definition: SelectionContext.h:50
Eigen::Vector3f ray_dir
Current mouse position induced ray direction.
Definition: SelectionContext.h:70
SelectionBehavior behavior
Selection behavior.
Definition: SelectionContext.h:86