Commit e2c4da19 by Alisa Jung

toolbar stuff: switch mode and viewport mode

parent d5b0a410
......@@ -17,13 +17,15 @@ SOURCES += main.cpp\
myglwidget.cpp \
scenegraph.cpp \
primitive.cpp \
rigidbodytransformation.cpp
rigidbodytransformation.cpp \
widgetfront.cpp
HEADERS += mainwindow.h \
myglwidget.h \
scenegraph.h \
primitive.h \
rigidbodytransformation.h
rigidbodytransformation.h \
widgetfront.h
RESOURCES += \
helloqube.qrc
......
......@@ -7,5 +7,15 @@
<file>img/wireframe.png</file>
<file>phong.frag</file>
<file>phong.vert</file>
<file>grapa-a2-iconset/box.png</file>
<file>grapa-a2-iconset/camera.png</file>
<file>grapa-a2-iconset/cone.png</file>
<file>grapa-a2-iconset/cylinder.png</file>
<file>grapa-a2-iconset/select.png</file>
<file>grapa-a2-iconset/sphere.png</file>
<file>grapa-a2-iconset/torus.png</file>
<file>grapa-a2-iconset/view-dual.png</file>
<file>grapa-a2-iconset/viewports.png</file>
<file>grapa-a2-iconset/view-single.png</file>
</qresource>
</RCC>
......@@ -101,6 +101,68 @@ MainWindow::MainWindow(QWidget *parent)
resetCameraAction->setIcon(QIcon(":/img/cam_home.png"));
connect(resetCameraAction,SIGNAL(triggered(bool)),myGLWidget,SLOT(resetCamera()));
toolBar->addAction(resetCameraAction);
toolBar->insertSeparator(resetCameraAction);
/* Assignment 2*/
//2 Camera Mode, Object Manipulation Mode
modeCameraAction = new QAction("Camera Mode",toolBar);
modeCameraAction->setIcon(QIcon(":/grapa-a2-iconset/camera.png"));
modeCameraAction->setCheckable(true);
modeCameraAction->setChecked(true);
//TODO connect slot
toolBar->addAction(modeCameraAction);
toolBar->insertSeparator(modeCameraAction);
modeManipulateAction = new QAction("Manipulation Mode", toolBar);
modeManipulateAction->setIcon(QIcon(":/grapa-a2-iconset/select.png"));
modeManipulateAction->setCheckable(true);
//TODO connect slot
toolBar->addAction(modeManipulateAction);
modeSwitchGroup = new QActionGroup(toolBar);
modeSwitchGroup->addAction(modeCameraAction);
modeSwitchGroup->addAction(modeManipulateAction);
//2 Switch view modes
viewButton = new QToolButton(toolBar);
viewButton->setIcon(QIcon(":/grapa-a2-iconset/viewports.png"));
viewMenu = new QMenu(viewButton);
viewButton->setMenu(viewMenu);
viewButton->setPopupMode(QToolButton::MenuButtonPopup);
toolBar->addWidget(viewButton);
viewGroup = new QActionGroup(viewMenu);
singleViewAction = new QAction("Single View",viewMenu);
singleViewAction->setIcon(QIcon(":/grapa-a2-iconset/view-single.png"));
singleViewAction->setCheckable(true);
singleViewAction->setChecked(true);
singleViewAction->setShortcut(QKeySequence(Qt::Key_1));
//TODO connect slot
viewMenu->addAction(singleViewAction);
viewMenu->setDefaultAction(singleViewAction);
viewGroup->addAction(singleViewAction);
dualViewAction = new QAction("Dual View",viewMenu);
dualViewAction->setIcon(QIcon(":/grapa-a2-iconset/view-dual.png"));
dualViewAction->setCheckable(true);
dualViewAction->setShortcut(QKeySequence(Qt::Key_2));
//TODO connect slot
viewMenu->addAction(dualViewAction);
viewGroup->addAction(dualViewAction);
quadViewAction = new QAction("Quad View",viewMenu);
quadViewAction->setIcon(QIcon(":/grapa-a2-iconset/viewports.png"));
quadViewAction->setCheckable(true);
quadViewAction->setShortcut(QKeySequence(Qt::Key_4));
//TODO connect slot
viewMenu->addAction(quadViewAction);
viewGroup->addAction(quadViewAction);
}
......
......@@ -12,6 +12,7 @@
#include <QStatusBar>
#include <myglwidget.h>
#include <QSlider>
#include <QToolButton>
class MainWindow : public QMainWindow
{
......@@ -49,6 +50,17 @@ private:
QAction *resetCameraAction;
QAction *modeCameraAction;
QAction *modeManipulateAction;
QActionGroup *modeSwitchGroup;
QAction *singleViewAction;
QAction *dualViewAction;
QAction *quadViewAction;
QActionGroup *viewGroup;
QToolButton* viewButton;
QMenu* viewMenu;
//Widgets
MyGLWidget *myGLWidget;
......
......@@ -117,15 +117,14 @@ void MyGLWidget::paintGL(){
double dist = qubeWidth/(double)tesselation;
//for cube rotation
//for cube translation
QMatrix4x4 translateRot1 = QMatrix4x4(1,0,0,translatex,0,1,0,translatey,0,0,1,0,0,0,0,1);
QMatrix4x4 translateRot2 = QMatrix4x4(1,0,0,-translatex,0,1,0,-translatey,0,0,1,0,0,0,0,1);
QMatrix4x4 translateText = QMatrix4x4(1,0,0,2,0,1,0,0,0,0,1,0,0,0,0,1);
//for cube rotation
QMatrix4x4 m = QMatrix4x4();
m.rotate(qubeRotationQuaternion);
//stack matrices
glMultMatrixf(translateRot1.data());//Punkte zurück schieben damit rotation um qube zentrum ist
glMultMatrixf(m.data());
......@@ -152,11 +151,6 @@ void MyGLWidget::paintGL(){
}
}
glEnd();
//reference for previous front
// glVertex3f(0.5, 0.5, 0.5);//4
// glVertex3f(-0.5, 0.5, 0.5);//3
// glVertex3f(-0.5, -0.5, 0.5);//2
// glVertex3f(0.5, -0.5, 0.5);//1
//oben // y-Achse
GLfloat green[] = {0,1,0};
......
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
#include <gl/GLU.h>
#include <QDebug>
#include <QWheelEvent>
#include <QQuaternion>
#include <QMatrix4x4>
#include <math.h>
#include <QVector3D>
#include <QGLShaderProgram>
#include <QGLShader>
class WidgetFront : public QGLWidget
{
Q_OBJECT //from HelloGL Example
public:
WidgetFront(QWidget *parent = 0);
~WidgetFront();
//From HelloGL example.
QSize minimumSizeHint() const;
QSize sizeHint() const;
protected:
//4.1 Core Functionality
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
private:
//tesselation slider
int tesselation;
//zoom camera
const double cameraZoomDefault = -5;
double cameraZoom;
double cameraX, cameraY;
//translate camera
QPoint clickStartPosition;
bool rightButtonPressed;
double translatex, translatey;
//rotate cube
bool leftButtonPressed;
QQuaternion qubeRotationQuaternion;
QPoint screenCenter;//Center of screen in pixel coordinates
//Phong Shader
QGLShaderProgram *phongShader;
public slots:
//4.1.1 slots for shading modes
void shadeWireframeSlot();
void shadeFlatSlot();
void shadeGouraudSlot();
void shadePhongSlot();
void setTessellation(int t);
void resetCamera();
};
#endif // GLWIDGET_H
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