#ifndef UI_TVR_MATCH_VIEWER_H_
#define UI_TVR_MATCH_VIEWER_H_
#if _WIN32
#define NOMINMAX
#endif
#include <vector>
#include <QGLWidget>
#include "ui/tvr/tvr_document.h"
#include "ui/tvr/gl_texture.h"
struct OnScreenImage {
float posx, posy;
float scale;
OnScreenImage() {}
};
class MatchViewer : public QGLWidget {
Q_OBJECT
public:
MatchViewer(QGLWidget *share, GLTexture *, QWidget *parent);
~MatchViewer();
QSize minimumSizeHint() const;
QSize sizeHint() const;
public slots:
void SetDocument(TvrDocument *doc);
void SetTransformation(float tx_, float ty_, float zoom_);
void GLUpdate() { updateGL(); }
void TextureChange() { InitTextures(); }
protected:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
void SetUpGlCamera();
void DrawImage(int i);
void DrawFeatures(int image_index);
void DrawCandidateMatches();
bool TexturesInited();
void InitTextures();
void InitTexture(int index);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
int ImageUnderPointer(QMouseEvent *event);
void PlaneFromScreen(float xw, float yw, float *xi, float *yi);
void ScreenFromPlane(float xi, float yi, float *xw, float *yw);
private:
TvrDocument *document_;
GLTexture *textures_;
OnScreenImage screen_images_[2];
enum MouseDragBehavior {
NONE, MOVE_VIEW, MOVE_IMAGE
} mouse_drag_behavior_;
int dragging_image_;
float tx, ty; float zoom;
QPoint lastPos;
};
#endif