Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
4025ac5d
Commit
4025ac5d
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature/zoom' into 'master'
Zoom and pan in GUI See merge request nicolas.pope/ftl!164
parents
9ba605f7
5040c08a
No related branches found
No related tags found
1 merge request
!164
Zoom and pan in GUI
Pipeline
#16310
passed
5 years ago
Stage: all
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/gui/src/screen.cpp
+40
-5
40 additions, 5 deletions
applications/gui/src/screen.cpp
applications/gui/src/screen.hpp
+4
-0
4 additions, 0 deletions
applications/gui/src/screen.hpp
with
44 additions
and
5 deletions
applications/gui/src/screen.cpp
+
40
−
5
View file @
4025ac5d
...
...
@@ -72,6 +72,20 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl
has_vr_
=
vr
::
VR_IsHmdPresent
();
#endif
zoom_
=
root_
->
value
(
"zoom"
,
1.0
f
);
root_
->
on
(
"zoom"
,
[
this
](
const
ftl
::
config
::
Event
&
e
)
{
zoom_
=
root_
->
value
(
"zoom"
,
1.0
f
);
});
pos_x_
=
root_
->
value
(
"position_x"
,
0.0
f
);
root_
->
on
(
"position_x"
,
[
this
](
const
ftl
::
config
::
Event
&
e
)
{
pos_x_
=
root_
->
value
(
"position_x"
,
0.0
f
);
});
pos_y_
=
root_
->
value
(
"position_y"
,
0.0
f
);
root_
->
on
(
"position_y"
,
[
this
](
const
ftl
::
config
::
Event
&
e
)
{
pos_y_
=
root_
->
value
(
"position_y"
,
0.0
f
);
});
setSize
(
Vector2i
(
1280
,
720
));
toolbuttheme
=
new
Theme
(
*
theme
());
...
...
@@ -354,11 +368,27 @@ void ftl::gui::Screen::setActiveCamera(ftl::gui::Camera *cam) {
}
}
bool
ftl
::
gui
::
Screen
::
scrollEvent
(
const
Eigen
::
Vector2i
&
p
,
const
Eigen
::
Vector2f
&
rel
)
{
if
(
nanogui
::
Screen
::
scrollEvent
(
p
,
rel
))
{
return
true
;
}
else
{
zoom_
+=
zoom_
*
0.1
f
*
rel
[
1
];
return
true
;
}
}
bool
ftl
::
gui
::
Screen
::
mouseMotionEvent
(
const
Eigen
::
Vector2i
&
p
,
const
Eigen
::
Vector2i
&
rel
,
int
button
,
int
modifiers
)
{
if
(
nanogui
::
Screen
::
mouseMotionEvent
(
p
,
rel
,
button
,
modifiers
))
{
return
true
;
}
else
{
if
(
camera_
)
camera_
->
mouseMovement
(
rel
[
0
],
rel
[
1
],
button
);
if
(
camera_
)
{
if
(
button
==
1
)
{
camera_
->
mouseMovement
(
rel
[
0
],
rel
[
1
],
button
);
}
else
if
(
button
==
2
)
{
pos_x_
+=
rel
[
0
];
pos_y_
+=
-
rel
[
1
];
}
}
}
return
true
;
// TODO: return statement was missing; is true correct?
}
...
...
@@ -367,7 +397,10 @@ bool ftl::gui::Screen::mouseButtonEvent(const nanogui::Vector2i &p, int button,
if
(
nanogui
::
Screen
::
mouseButtonEvent
(
p
,
button
,
down
,
modifiers
))
{
return
true
;
}
else
{
if
(
camera_
&&
down
)
{
if
(
!
camera_
)
return
false
;
//ol movable = camera_->source()->hasCapabilities(ftl::rgbd::kCapMovable);
if
(
button
==
0
&&
down
)
{
Eigen
::
Vector2f
screenSize
=
size
().
cast
<
float
>
();
auto
mScale
=
(
screenSize
.
cwiseQuotient
(
imageSize
).
minCoeff
());
Eigen
::
Vector2f
scaleFactor
=
mScale
*
imageSize
.
cwiseQuotient
(
screenSize
);
...
...
@@ -391,8 +424,10 @@ bool ftl::gui::Screen::mouseButtonEvent(const nanogui::Vector2i &p, int button,
//lookPoint_ = Eigen::Vector3f(worldPos[0],worldPos[1],worldPos[2]);
//LOG(INFO) << "Depth at click = " << -camPos[2];
return
true
;
}
else
{
}
return
false
;
return
false
;
}
}
...
...
@@ -446,9 +481,9 @@ void ftl::gui::Screen::draw(NVGcontext *ctx) {
#endif
if
(
mImageID
<
std
::
numeric_limits
<
unsigned
int
>::
max
()
&&
imageSize
[
0
]
>
0
)
{
auto
mScale
=
(
screenSize
.
cwiseQuotient
(
imageSize
).
minCoeff
());
auto
mScale
=
(
screenSize
.
cwiseQuotient
(
imageSize
).
minCoeff
())
*
zoom_
;
Vector2f
scaleFactor
=
mScale
*
imageSize
.
cwiseQuotient
(
screenSize
);
Vector2f
positionInScreen
(
0.0
f
,
0.0
f
);
Vector2f
positionInScreen
(
pos_x_
,
pos_y_
);
auto
mOffset
=
(
screenSize
-
(
screenSize
.
cwiseProduct
(
scaleFactor
)))
/
2
;
Vector2f
positionAfterOffset
=
positionInScreen
+
mOffset
;
Vector2f
imagePosition
=
positionAfterOffset
.
cwiseQuotient
(
screenSize
);
...
...
This diff is collapsed.
Click to expand it.
applications/gui/src/screen.hpp
+
4
−
0
View file @
4025ac5d
...
...
@@ -29,6 +29,7 @@ class Screen : public nanogui::Screen {
~
Screen
();
bool
mouseMotionEvent
(
const
Eigen
::
Vector2i
&
p
,
const
Eigen
::
Vector2i
&
rel
,
int
button
,
int
modifiers
);
bool
scrollEvent
(
const
Eigen
::
Vector2i
&
p
,
const
Eigen
::
Vector2f
&
rel
);
bool
mouseButtonEvent
(
const
nanogui
::
Vector2i
&
p
,
int
button
,
bool
down
,
int
modifiers
);
bool
keyboardEvent
(
int
key
,
int
scancode
,
int
action
,
int
modifiers
);
...
...
@@ -92,6 +93,9 @@ class Screen : public nanogui::Screen {
ftl
::
Configurable
*
root_
;
std
::
string
status_
;
ftl
::
gui
::
Camera
*
camera_
;
float
zoom_
;
float
pos_x_
;
float
pos_y_
;
GLuint
leftEye_
;
GLuint
rightEye_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment