MRPT  2.0.4
NanoGUICanvasHeadless.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "gui-precomp.h" // Precompiled headers
11 
13 
14 using namespace mrpt::gui;
15 
16 #if MRPT_HAS_NANOGUI
17 
18 using namespace mrpt::gui::internal;
19 
21  const nanogui::Vector2i& p, const nanogui::Vector2i& rel, int button,
22  int modifiers)
23 {
24  const bool leftIsDown = button & (1 << GLFW_MOUSE_BUTTON_LEFT);
25  const bool rightIsDown = button & (1 << GLFW_MOUSE_BUTTON_RIGHT);
26 
27  const int X = p.x();
28  const int Y = p.y();
29  updateLastPos(X, Y);
30 
31  if (leftIsDown || rightIsDown)
32  {
33  // Proxy variables to cache the changes:
35 
36  if (leftIsDown)
37  {
38  if (modifiers & GLFW_MOD_SHIFT)
39  updateZoom(params, X, Y);
40  else if (modifiers & GLFW_MOD_CONTROL)
41  updateRotate(params, X, Y);
42  else
44  }
45  else
46  updatePan(params, X, Y);
47 
48  setMousePos(X, Y);
50 
51  // Refresh window: done automatically by parent
52  }
53 }
54 
56  const nanogui::Vector2i& p, int button, bool down, int modifiers)
57 {
58  setMousePos(p.x(), p.y());
59  setMouseClicked(down);
60 }
62  const nanogui::Vector2i& p, const nanogui::Vector2f& rel)
63 {
65  updateZoom(params, 125 * rel.y());
67 }
68 
69 #endif // MRPT_HAS_NANOGUI
void updateOrbitCamera(CamaraParams &params, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation...
CamaraParams cameraParams() const
Returns a copy of CamaraParams See also getRefCameraParams(), setCameraParams(const CamaraParams &) ...
void scrollEvent(const nanogui::Vector2i &p, const nanogui::Vector2f &rel)
mrpt::vision::TStereoCalibParams params
virtual void setCameraParams(const CamaraParams &params)
Sets the CamaraParams See also cameraParams(), getRefCameraParams()
void setMousePos(int x, int y)
Saves the click position of the mouse See also setMouseClicked(bool)
void mouseButtonEvent(const nanogui::Vector2i &p, int button, bool down, int modifiers)
void setMouseClicked(bool is)
Sets the property mouseClicked By default, this property is false.
void updateLastPos(int x, int y)
Sets the last mouse position.
void updateRotate(CamaraParams &params, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation...
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:14
void mouseMotionEvent(const nanogui::Vector2i &p, const nanogui::Vector2i &rel, int button, int modifiers)
void updatePan(CamaraParams &params, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the pointing ...
void updateZoom(CamaraParams &params, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the zoom of t...



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 5711e29ae Wed May 27 14:29:47 2020 +0200 at miƩ may 27 14:30:10 CEST 2020