Commit 5ae10114 authored by Stefan Pfeifer's avatar Stefan Pfeifer

Attempt to add anti-aliasing to the limb view

parent 840a4b6d
......@@ -10,6 +10,10 @@ LimbView::LimbView()
: legend(new LayerLegend()),
shader_program(nullptr)
{
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSamples(32);
setFormat(format);
auto button0 = new QToolButton();
QObject::connect(button0, &QPushButton::clicked, this, &LimbView::viewProfile);
button0->setIcon(QIcon(":/icons/limb-view/view-profile"));
......@@ -87,7 +91,7 @@ void LimbView::viewProfile()
void LimbView::viewTop()
{
rot_x = 90.0f;
rot_x = -90.0f;
rot_y = 0.0f;
viewFit();
}
......@@ -208,6 +212,7 @@ void LimbView::paintGL()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_MULTISAMPLE);
m_world.setToIdentity();
m_world.rotate(rot_x, 1.0f, 0.0f, 0.0f);
......
#pragma once
#include "bow/input/InputData.hpp"
#include "LimbMesh.hpp"
#include "LayerLegend.hpp"
#include <QtWidgets>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QMatrix4x4>
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
// Based on Qt's "Hello GL2" example, http://doc.qt.io/qt-5/qtopengl-hellogl2-example.html
class LimbView: public QOpenGLWidget, protected QOpenGLFunctions
{
private:
const float DEFAULT_ROT_X = -20.0f; // Magic number
const float DEFAULT_ROT_Y = 30.0f; // Magic number
const float DEFAULT_ZOOM = 1.1f; // Magic number
const float ZOOM_SPEED = 0.2f; // Magic number
const float ROT_SPEED = 0.15f; // Magic number
public:
LimbView();
~LimbView() override;
void setData(const InputData& data);
void viewProfile();
void viewTop();
void view3D();
void viewSymmetric(bool checked);
void viewFit();
private:
void cleanup();
void initializeGL() override;
void paintGL() override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent* event) override;
LayerLegend* legend;
LimbMesh limb_mesh;
QOpenGLBuffer limb_mesh_vbo;
QOpenGLShaderProgram* shader_program;
int loc_projectionMatrix;
int loc_modelViewMatrix;
int loc_normalMatrix;
int loc_lightPosition;
QMatrix4x4 m_projection;
QMatrix4x4 m_camera;
QMatrix4x4 m_world;
QPoint mouse_pos;
float shift_x;
float shift_y;
float rot_x;
float rot_y;
float zoom;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment