This commit is contained in:
PodmogilnyjIvan
2021-12-03 03:34:31 -08:00
commit ff4acf84be
542 changed files with 136810 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/display/opengl_render_state.h>
#include <pangolin/handler/handler_enums.h>
#if defined(HAVE_EIGEN) && !defined(__CUDACC__) //prevent including Eigen in cuda files
#define USE_EIGEN
#endif
#ifdef USE_EIGEN
#include <Eigen/Core>
#endif
#ifdef _OSX_
#define PANGO_DFLT_HANDLER3D_ZF (1.0f/50.0f)
#else
#define PANGO_DFLT_HANDLER3D_ZF (1.0f/10.0f)
#endif
namespace pangolin
{
// Forward declarations
struct View;
/// Input Handler base class.
/// Virtual methods which recurse into sub-displays.
struct PANGOLIN_EXPORT Handler
{
virtual ~Handler() {}
virtual void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
virtual void Mouse(View&, MouseButton button, int x, int y, bool pressed, int button_state);
virtual void MouseMotion(View&, int x, int y, int button_state);
virtual void PassiveMouseMotion(View&, int x, int y, int button_state);
virtual void Special(View&, InputSpecial inType, float x, float y, float p1, float p2, float p3, float p4, int button_state);
};
struct PANGOLIN_EXPORT HandlerScroll : Handler
{
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int button_state);
void Special(View&, InputSpecial inType, float x, float y, float p1, float p2, float p3, float p4, int button_state);
};
struct PANGOLIN_EXPORT Handler3D : Handler
{
Handler3D(OpenGlRenderState& cam_state, AxisDirection enforce_up=AxisNone, float trans_scale=0.01f, float zoom_fraction= PANGO_DFLT_HANDLER3D_ZF);
virtual bool ValidWinDepth(GLprecision depth);
virtual void PixelUnproject( View& view, GLprecision winx, GLprecision winy, GLprecision winz, GLprecision Pc[3]);
virtual void GetPosNormal(View& view, int x, int y, GLprecision p[3], GLprecision Pw[3], GLprecision Pc[3], GLprecision nw[3], GLprecision default_z = 1.0);
void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int button_state);
void MouseMotion(View&, int x, int y, int button_state);
void Special(View&, InputSpecial inType, float x, float y, float p1, float p2, float p3, float p4, int button_state);
#ifdef USE_EIGEN
// Return selected point in world coordinates
inline Eigen::Vector3d Selected_P_w() const {
return Eigen::Map<const Eigen::Matrix<GLprecision,3,1>>(Pw).cast<double>();
}
#endif
inline int KeyState() const{
return funcKeyState;
}
protected:
OpenGlRenderState* cam_state;
const static int hwin = 8;
AxisDirection enforce_up;
float tf; // translation factor
float zf; // zoom fraction
CameraSpec cameraspec;
GLprecision last_z;
float last_pos[2];
GLprecision rot_center[3];
GLprecision p[3];
GLprecision Pw[3];
GLprecision Pc[3];
GLprecision n[3];
int funcKeyState;
};
static Handler StaticHandler;
static HandlerScroll StaticHandlerScroll;
}

View File

@@ -0,0 +1,94 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace pangolin
{
// Supported Key modifiers for GlobalKeyPressCallback.
// e.g. PANGO_CTRL + 'r', PANGO_SPECIAL + PANGO_KEY_RIGHT, etc.
const int PANGO_SPECIAL = 128;
const int PANGO_CTRL = -96;
const int PANGO_OPTN = 132;
// Ordinary keys
const int PANGO_KEY_TAB = 9;
const int PANGO_KEY_ESCAPE = 27;
// Special Keys (same as GLUT_ defines)
const int PANGO_KEY_F1 = 1;
const int PANGO_KEY_F2 = 2;
const int PANGO_KEY_F3 = 3;
const int PANGO_KEY_F4 = 4;
const int PANGO_KEY_F5 = 5;
const int PANGO_KEY_F6 = 6;
const int PANGO_KEY_F7 = 7;
const int PANGO_KEY_F8 = 8;
const int PANGO_KEY_F9 = 9;
const int PANGO_KEY_F10 = 10;
const int PANGO_KEY_F11 = 11;
const int PANGO_KEY_F12 = 12;
const int PANGO_KEY_LEFT = 100;
const int PANGO_KEY_UP = 101;
const int PANGO_KEY_RIGHT = 102;
const int PANGO_KEY_DOWN = 103;
const int PANGO_KEY_PAGE_UP = 104;
const int PANGO_KEY_PAGE_DOWN = 105;
const int PANGO_KEY_HOME = 106;
const int PANGO_KEY_END = 107;
const int PANGO_KEY_INSERT = 108;
enum MouseButton
{
MouseButtonLeft = 1,
MouseButtonMiddle = 2,
MouseButtonRight = 4,
MouseWheelUp = 8,
MouseWheelDown = 16,
MouseWheelRight = 32,
MouseWheelLeft = 64,
};
enum KeyModifier
{
KeyModifierShift = 1<<16,
KeyModifierCtrl = 1<<17,
KeyModifierAlt = 1<<18,
KeyModifierCmd = 1<<19,
KeyModifierFnc = 1<<20
};
enum InputSpecial
{
InputSpecialScroll,
InputSpecialZoom,
InputSpecialRotate,
InputSpecialTablet
};
}

View File

@@ -0,0 +1,48 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef HANDLER_GLBUFFER_H
#define HANDLER_GLBUFFER_H
#include <pangolin/handler/handler.h>
#include <pangolin/gl/gl.h>
namespace pangolin
{
struct Handler3DFramebuffer : public pangolin::Handler3D
{
Handler3DFramebuffer(GlFramebuffer& fb, pangolin::OpenGlRenderState& cam_state, pangolin::AxisDirection enforce_up=pangolin::AxisNone, float trans_scale=0.01f);
void GetPosNormal(pangolin::View& view, int x, int y, GLprecision p[3], GLprecision Pw[3], GLprecision Pc[3], GLprecision /*n*/[3], GLprecision default_z);
protected:
GlFramebuffer& fb;
};
}
#endif // HANDLER_GLBUFFER_H

View File

@@ -0,0 +1,162 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/image/image_utils.h>
#include <pangolin/display/viewport.h>
#include <pangolin/display/view.h>
#include <pangolin/handler/handler.h>
#include <pangolin/plot/range.h>
#include <pangolin/gl/gl.h>
#include <functional>
namespace pangolin
{
class ImageViewHandler : public Handler
{
public:
struct EventData {
EventData(View& v, ImageViewHandler& h) : view(v), handler(h) {}
View& view;
ImageViewHandler& handler;
};
struct OnSelectionEventData : public EventData {
OnSelectionEventData(View& v, ImageViewHandler& h, bool dragging)
: EventData(v,h), dragging(dragging) {}
bool dragging;
};
typedef std::function<void(OnSelectionEventData)> OnSelectionCallbackFn;
// Default constructor: User must call SetDimensions() once image dimensions are known.
// Default range is [0,1] in x and y.
ImageViewHandler();
// View ranges store extremes of image (boundary of pixels)
// in 'discrete' coords, where 0,0 is center of top-left pixel.
ImageViewHandler(size_t w, size_t h);
void SetDimensions(size_t w, size_t h);
void UpdateView();
void glSetViewOrtho();
void glRenderTexture(pangolin::GlTexture& tex);
void glRenderTexture(GLuint tex, GLint width, GLint height);
void glRenderOverlay();
void ScreenToImage(Viewport& v, float xpix, float ypix, float& ximg, float& yimg);
void ImageToScreen(Viewport& v, float ximg, float yimg, float& xpix, float& ypix);
bool UseNN() const;
bool& UseNN();
bool& FlipTextureX();
bool& FlipTextureY();
pangolin::XYRangef& GetViewToRender();
float GetViewScale();
pangolin::XYRangef& GetView();
pangolin::XYRangef& GetDefaultView();
pangolin::XYRangef& GetSelection();
void GetHover(float& x, float& y);
void SetView(const pangolin::XYRangef& range);
void SetViewSmooth(const pangolin::XYRangef& range);
void ScrollView(float x, float y);
void ScrollViewSmooth(float x, float y);
void ScaleView(float x, float y, float cx, float cy);
void ScaleViewSmooth(float x, float y, float cx, float cy);
void ResetView();
///////////////////////////////////////////////////////
/// pangolin::Handler
///////////////////////////////////////////////////////
void Keyboard(View&, unsigned char key, int /*x*/, int /*y*/, bool pressed) override;
void Mouse(View& view, pangolin::MouseButton button, int x, int y, bool pressed, int button_state) override;
void MouseMotion(View& view, int x, int y, int button_state) override;
void PassiveMouseMotion(View&, int /*x*/, int /*y*/, int /*button_state*/) override;
void Special(View& view, pangolin::InputSpecial inType, float x, float y, float p1, float p2, float /*p3*/, float /*p4*/, int /*button_state*/) override;
///////////////////////////////////////////////////////
/// Callbacks
///////////////////////////////////////////////////////
OnSelectionCallbackFn OnSelectionCallback;
protected:
void FixSelection(XYRangef& sel);
void AdjustScale();
void AdjustTranslation();
static ImageViewHandler* to_link;
static float animate_factor;
ImageViewHandler* linked_view_handler;
pangolin::XYRangef rview_default;
pangolin::XYRangef rview_max;
pangolin::XYRangef rview;
pangolin::XYRangef target;
pangolin::XYRangef selection;
float hover_img[2];
int last_mouse_pos[2];
bool use_nn;
bool flipTextureX;
bool flipTextureY;
};
}