2009-12-09 17:23:22 +03:00
|
|
|
#ifndef GLVIEW_H_
|
|
|
|
#define GLVIEW_H_
|
|
|
|
|
2011-10-01 03:36:30 +04:00
|
|
|
#include "system-gl.h"
|
2009-12-09 17:23:22 +03:00
|
|
|
#include <QGLWidget>
|
|
|
|
#include <QLabel>
|
|
|
|
|
2013-02-21 05:56:30 +04:00
|
|
|
#include <Eigen/Core>
|
|
|
|
#include <Eigen/Geometry>
|
|
|
|
|
|
|
|
class QGLView : public QGLWidget
|
2009-12-09 17:23:22 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2011-07-30 23:29:40 +04:00
|
|
|
Q_PROPERTY(bool showFaces READ showFaces WRITE setShowFaces);
|
|
|
|
Q_PROPERTY(bool showEdges READ showEdges WRITE setShowEdges);
|
2010-01-15 16:03:42 +03:00
|
|
|
Q_PROPERTY(bool showAxes READ showAxes WRITE setShowAxes);
|
|
|
|
Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs);
|
|
|
|
Q_PROPERTY(bool orthoMode READ orthoMode WRITE setOrthoMode);
|
2009-12-09 17:23:22 +03:00
|
|
|
|
|
|
|
public:
|
2013-02-21 05:56:30 +04:00
|
|
|
QGLView(QWidget *parent = NULL);
|
|
|
|
QGLView(const QGLFormat & format, QWidget *parent = NULL);
|
2011-07-30 23:29:40 +04:00
|
|
|
void setRenderer(class Renderer* r);
|
2010-01-15 16:03:42 +03:00
|
|
|
#ifdef ENABLE_OPENCSG
|
|
|
|
bool hasOpenCSGSupport() { return this->opencsg_support; }
|
|
|
|
#endif
|
|
|
|
// Properties
|
2011-07-30 23:29:40 +04:00
|
|
|
bool showFaces() const { return this->showfaces; }
|
|
|
|
void setShowFaces(bool enabled) { this->showfaces = enabled; }
|
|
|
|
bool showEdges() const { return this->showedges; }
|
|
|
|
void setShowEdges(bool enabled) { this->showedges = enabled; }
|
2010-01-15 16:03:42 +03:00
|
|
|
bool showAxes() const { return this->showaxes; }
|
|
|
|
void setShowAxes(bool enabled) { this->showaxes = enabled; }
|
|
|
|
bool showCrosshairs() const { return this->showcrosshairs; }
|
|
|
|
void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; }
|
|
|
|
bool orthoMode() const { return this->orthomode; }
|
|
|
|
void setOrthoMode(bool enabled) { this->orthomode = enabled; }
|
2013-02-21 15:49:19 +04:00
|
|
|
std::string getRendererInfo() const { return this->rendererInfo; }
|
|
|
|
bool save(const char *filename);
|
2011-12-09 06:43:06 +04:00
|
|
|
|
2011-07-30 23:29:40 +04:00
|
|
|
public:
|
2010-01-15 16:03:42 +03:00
|
|
|
QLabel *statusLabel;
|
2013-02-21 05:56:30 +04:00
|
|
|
|
|
|
|
Eigen::Vector3d object_rot;
|
|
|
|
Eigen::Vector3d object_trans;
|
|
|
|
Eigen::Vector3d camera_eye;
|
|
|
|
Eigen::Vector3d camera_center;
|
|
|
|
|
2010-01-15 16:03:42 +03:00
|
|
|
GLint shaderinfo[11];
|
|
|
|
|
2010-02-09 09:06:37 +03:00
|
|
|
#ifdef ENABLE_OPENCSG
|
|
|
|
bool opencsg_support;
|
|
|
|
int opencsg_id;
|
|
|
|
#endif
|
|
|
|
|
2010-01-15 16:03:42 +03:00
|
|
|
private:
|
2010-11-17 09:27:03 +03:00
|
|
|
void init();
|
2011-07-30 23:29:40 +04:00
|
|
|
Renderer *renderer;
|
2010-11-17 09:27:03 +03:00
|
|
|
|
2013-02-21 05:56:30 +04:00
|
|
|
std::string rendererInfo;
|
2011-12-09 06:43:06 +04:00
|
|
|
|
2011-07-30 23:29:40 +04:00
|
|
|
bool showfaces;
|
|
|
|
bool showedges;
|
2010-01-15 16:03:42 +03:00
|
|
|
bool showaxes;
|
|
|
|
bool showcrosshairs;
|
|
|
|
bool orthomode;
|
|
|
|
|
|
|
|
double viewer_distance;
|
2009-12-09 17:23:22 +03:00
|
|
|
|
|
|
|
double w_h_ratio;
|
|
|
|
|
|
|
|
bool mouse_drag_active;
|
2011-05-15 01:29:45 +04:00
|
|
|
QPoint last_mouse;
|
2009-12-09 17:23:22 +03:00
|
|
|
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
void wheelEvent(QWheelEvent *event);
|
|
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event);
|
|
|
|
|
|
|
|
void initializeGL();
|
|
|
|
void resizeGL(int w, int h);
|
2013-02-21 16:31:18 +04:00
|
|
|
|
2013-02-21 16:43:26 +04:00
|
|
|
void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance);
|
2013-02-21 16:31:18 +04:00
|
|
|
void setupGimbalPerspective();
|
|
|
|
void setupGimbalOrtho(double distance,bool offset=false);
|
|
|
|
|
2013-02-21 16:43:26 +04:00
|
|
|
void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er);
|
2011-05-14 22:57:12 +04:00
|
|
|
void setupPerspective();
|
2013-02-21 16:31:18 +04:00
|
|
|
void setupOrtho(bool offset=false);
|
|
|
|
|
2009-12-09 17:23:22 +03:00
|
|
|
void paintGL();
|
2011-05-14 22:57:12 +04:00
|
|
|
void normalizeAngle(GLdouble& angle);
|
2009-12-09 17:23:22 +03:00
|
|
|
|
|
|
|
#ifdef ENABLE_OPENCSG
|
2011-11-28 01:52:28 +04:00
|
|
|
bool is_opencsg_capable;
|
|
|
|
bool has_shaders;
|
2009-12-09 17:23:22 +03:00
|
|
|
private slots:
|
2011-11-28 02:02:38 +04:00
|
|
|
void display_opencsg_warning();
|
2009-12-09 17:23:22 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void doAnimateUpdate();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|