Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
grapa_alisa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alisa Jung
grapa_alisa
Commits
b06d9373
Commit
b06d9373
authored
Nov 15, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
layout and splitter. fuck this.
parent
4e889a03
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
17 deletions
+50
-17
mainwindow.cpp
helloqube/mainwindow.cpp
+30
-2
mainwindow.h
helloqube/mainwindow.h
+9
-0
myglwidget.cpp
helloqube/myglwidget.cpp
+8
-13
myglwidget.h
helloqube/myglwidget.h
+3
-2
No files found.
helloqube/mainwindow.cpp
View file @
b06d9373
...
...
@@ -75,11 +75,39 @@ MainWindow::MainWindow(QWidget *parent)
statusBar
->
showMessage
(
"test status message"
);
setStatusBar
(
statusBar
);
//4.0 Widget
//4.0 Widget
//Assignment 2: Multiple Widgets.
controller
=
new
Controller
();
myGLWidget
=
new
MyGLWidget
(
controller
,
this
);
myGLWidget
=
new
MyGLWidget
(
controller
,
true
,
QQuaternion
(),
this
);
setCentralWidget
(
myGLWidget
);
viewFront
=
new
MyGLWidget
(
controller
,
false
,
QQuaternion
(
0
,
1
,
0
,
0
),
this
);
double
costhetahalf
=
cos
(
45
);
viewLeft
=
new
MyGLWidget
(
controller
,
true
,
QQuaternion
(
costhetahalf
,
1
,
0
,
0
),
this
);
//TODO check rotations.
viewTop
=
new
MyGLWidget
(
controller
,
false
,
QQuaternion
(
costhetahalf
,
0
,
1
,
0
),
this
);
viewLayout
=
new
QGridLayout
(
this
);
viewSplitter1
=
new
QSplitter
;
viewSplitter1
->
addWidget
(
myGLWidget
);
viewSplitter1
->
addWidget
(
viewFront
);
viewSplitter2
=
new
QSplitter
;
viewSplitter2
->
addWidget
(
viewLeft
);
viewSplitter2
->
addWidget
(
viewTop
);
viewSplitter3
->
setOrientation
(
Qt
::
Vertical
);
viewSplitter3
->
addWidget
(
viewSplitter1
);
viewSplitter3
->
addWidget
(
viewSplitter2
);
viewSplitter3
=
new
QSplitter
;
viewLayout
->
addWidget
(
viewSplitter3
);
QWidget
*
central_widget
=
new
QWidget
(
this
);
central_widget
->
setLayout
(
viewLayout
);
setCentralWidget
(
central_widget
);
//4.1.1 connect shading actions to slot
connect
(
shadeWireframeAction
,
SIGNAL
(
triggered
(
bool
)),
myGLWidget
,
SLOT
(
shadeWireframeSlot
()));
connect
(
shadeFlatAction
,
SIGNAL
(
triggered
(
bool
)),
myGLWidget
,
SLOT
(
shadeFlatSlot
()));
...
...
helloqube/mainwindow.h
View file @
b06d9373
...
...
@@ -14,6 +14,8 @@
#include <QSlider>
#include <QToolButton>
#include <controller.h>
#include <QLayout>
#include <QSplitter>
class
MainWindow
:
public
QMainWindow
{
...
...
@@ -64,6 +66,13 @@ private:
//Widgets
MyGLWidget
*
myGLWidget
;
MyGLWidget
*
viewFront
;
MyGLWidget
*
viewLeft
;
MyGLWidget
*
viewTop
;
QGridLayout
*
viewLayout
;
QSplitter
*
viewSplitter1
;
QSplitter
*
viewSplitter2
;
QSplitter
*
viewSplitter3
;
//4.1.1 Slider
QSlider
*
tesselationSlider
;
...
...
helloqube/myglwidget.cpp
View file @
b06d9373
#include "myglwidget.h"
#include "controller.h"
MyGLWidget
::
MyGLWidget
(
Controller
*
c
,
QWidget
*
parent
)
MyGLWidget
::
MyGLWidget
(
Controller
*
c
,
bool
isPerspective
,
QQuaternion
initialRotation
,
QWidget
*
parent
)
:
QGLWidget
(
QGLFormat
(
QGL
::
SampleBuffers
),
parent
)
{
MyGLWidget
::
modeCamera
=
true
;
tesselation
=
1
;
qubeRotation
=
QQuaternion
();
cameraRotation
=
QQuaternion
()
;
cameraRotation
=
initialRotation
;
translatex
=
0
;
translatey
=
0
;
cameraX
=
0
;
cameraY
=
0
;
cameraZ
=
0
;
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
cameraZoom
=
cameraZoomDefault
;
clickStartPosition
=
QPoint
(
0
,
0
);
rightButtonPressed
=
false
;
controller
=
c
;
this
->
isPerspective
=
isPerspective
;
}
MyGLWidget
::~
MyGLWidget
()
...
...
@@ -128,8 +126,6 @@ void MyGLWidget::paintGL(){
//for cube translation
QMatrix4x4
translateRot1
=
QMatrix4x4
(
1
,
0
,
0
,
translatex
,
0
,
1
,
0
,
translatey
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
QMatrix4x4
translateCamera
=
QMatrix4x4
(
1
,
0
,
0
,
cameraX
,
0
,
1
,
0
,
cameraY
,
0
,
0
,
1
,
cameraZ
,
0
,
0
,
0
,
1
);
QMatrix4x4
zoomCameraMatrix
=
QMatrix4x4
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
cameraZoom
,
0
,
0
,
0
,
1
);
...
...
@@ -314,9 +310,11 @@ void MyGLWidget::rotateQube(QQuaternion diff){
}
void
MyGLWidget
::
rotateCamera
(
QQuaternion
diff
){
cameraRotation
=
diff
*
cameraRotation
;
cameraRotation
.
normalize
();
updateGL
();
if
(
isPerspective
){
cameraRotation
=
diff
*
cameraRotation
;
cameraRotation
.
normalize
();
updateGL
();
}
}
//4.1.2 User Input: Zooming
...
...
@@ -372,9 +370,6 @@ void MyGLWidget::resetCamera(){
qubeRotation
=
QQuaternion
();
translatex
=
0
;
translatey
=
0
;
cameraX
=
0
;
cameraY
=
0
;
cameraZ
=
0
;
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
cameraZoom
=
cameraZoomDefault
;
cameraRotation
=
QQuaternion
();
...
...
helloqube/myglwidget.h
View file @
b06d9373
...
...
@@ -19,7 +19,8 @@ class MyGLWidget : public QGLWidget
Q_OBJECT
//from HelloGL Example
public
:
MyGLWidget
(
Controller
*
c
,
QWidget
*
parent
=
0
);
//Pass initial camera rotation and isPerspective = false for fixed views
MyGLWidget
(
Controller
*
c
,
bool
isPerspective
,
QQuaternion
initalRotation
,
QWidget
*
parent
=
0
);
~
MyGLWidget
();
//From HelloGL example.
...
...
@@ -48,10 +49,10 @@ protected:
private
:
//tesselation slider
int
tesselation
;
bool
isPerspective
;
//zoom camera
const
double
cameraZoomDefault
=
-
5
;
double
cameraX
,
cameraY
,
cameraZ
;
double
cameraZoom
;
QQuaternion
cameraRotation
;
QVector3D
camRotCenter
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment