23 #ifndef __QTTRACKBALLWIDGET__ 24 #define __QTTRACKBALLWIDGET__ 35 #include <QMouseEvent> 36 #include <QFileDialog> 101 QGLFormat glCurrentFormat = this->format();
102 cout <<
"QT GL version : " << glCurrentFormat.majorVersion() <<
" , " << glCurrentFormat.minorVersion() << endl;
111 camera.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
113 light_trackball.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
124 camera.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
127 light_trackball.
setViewport(Eigen::Vector2f ((
float)this->width(), (
float)this->height()));
139 QString str (filename.c_str());
140 QStringList strlist = str.split(
".");
141 QString extension = strlist[strlist.size()-1];
143 if (extension.compare(
"ply") != 0 && extension.compare(
"obj") != 0)
145 cerr <<
"file format [" << extension.toStdString() <<
"] not supported" << endl;
151 if (extension.compare(
"ply") == 0)
155 if (extension.compare(
"obj") == 0)
171 if (event->key() == Qt::Key_O)
173 QString filename = QFileDialog::getOpenFileName(
this, tr(
"Open File"),
"", tr(
"Mesh Files (*.obj *.ply)"));
174 if (!filename.isEmpty())
176 openMesh (filename.toStdString());
192 Eigen::Vector2f screen_pos (event->x(),
event->y());
193 if (event->modifiers() & Qt::ShiftModifier)
195 if (event->button() == Qt::LeftButton)
202 if (event->button() == Qt::LeftButton)
206 if (event->button() == Qt::RightButton)
222 Eigen::Vector2f screen_pos (event->x(),
event->y());
223 if (event->modifiers() & Qt::ShiftModifier &&
event->buttons() & Qt::LeftButton)
229 if (event->buttons() & Qt::LeftButton)
233 if (event->buttons() & Qt::RightButton)
251 if (event->button() == Qt::LeftButton)
256 if (event->button() == Qt::RightButton)
272 const int WHEEL_STEP = 120;
274 float pos =
event->delta () / float (WHEEL_STEP);
276 if (event->modifiers() & Qt::ShiftModifier)
void endTranslation(void)
Indicates that a translation has ended. Disable the translating flag, indicating that the mouse callb...
Definition: trackball.hpp:288
virtual Eigen::Quaternion< float > rotateCamera(const Eigen::Vector2f &pos)
Computes and applies the rotation transformations to the trackball given new position.
Definition: trackball.hpp:455
Definition: bufferobject.hpp:34
Trackball class for manipulating a camera.
Definition: trackball.hpp:79
virtual Eigen::Vector3f translateCamera(const Eigen::Vector2f &pos)
Computes and applies the translation transformations to the trackball given new position.
Definition: trackball.hpp:481
void setViewport(const Eigen::Vector4f &vp)
Sets the viewport coordinates.
Definition: camera.hpp:274
static void loadObjFile(Mesh *mesh, string filename) __attribute__((unused))
Loads a mesh from an OBJ file.
Definition: objimporter.hpp:50
void incrementFov(float inc)
Increases the fov of the perspective matrix by a given increment.
Definition: camera.hpp:477
This class is just to make sure that GLEW is initialized before anything else, so the constructor of ...
Definition: qttrackballwidget.hpp:49
QtGlewInitializer(QWidget *parent)
Definition: qttrackballwidget.hpp:52
Eigen::Matrix4f setPerspectiveMatrix(float fy, float in_aspect_ratio, float in_near_plane, float in_far_plane)
Sets the projection matrix as a perspective matrix.
Definition: camera.hpp:405
void setRenderFlag(bool flag)
Returns wether the trackball representation should be drawn or not.
Definition: trackball.hpp:299
virtual void endRotation(void)
Indicates that a rotation has ended. Disables the rotating flag, indicating that the mouse callback f...
Definition: trackball.hpp:279
static bool loadPlyFile(Mesh *mesh, string filename) __attribute__((unused))
Loads a mesh from an PLY file.
Definition: plyimporter.hpp:150
float getFovy(void) const
Returns current field of view angle in y axis.
Definition: camera.hpp:344
void normalizeModelMatrix(void)
Normalize model matrix to center and scale model. The model matrix will include a translation to plac...
Definition: model.hpp:141
void increaseZoom(float scale)
Increases the zoom on the scene by appling a scale to the View Matrix. The current scale used in View...
Definition: trackball.hpp:506
A common Mesh, usually containing triagles or points.
Definition: mesh.hpp:194
void initGlew(void)
Initialize Glew.
Definition: misc.hpp:68