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
11a73823
Commit
11a73823
authored
Nov 22, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display name of currently selected primitive in statusbar
parent
f000cfdd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
16 deletions
+36
-16
controller.cpp
helloqube/controller.cpp
+19
-8
controller.h
helloqube/controller.h
+5
-1
helloqube.pro.user
helloqube/helloqube.pro.user
+1
-1
mainwindow.cpp
helloqube/mainwindow.cpp
+1
-1
scenegraph.cpp
helloqube/scenegraph.cpp
+10
-5
No files found.
helloqube/controller.cpp
View file @
11a73823
...
@@ -2,13 +2,14 @@
...
@@ -2,13 +2,14 @@
#include "myglwidget.h"
#include "myglwidget.h"
#include "scenegraph.h"
#include "scenegraph.h"
Controller
::
Controller
()
Controller
::
Controller
(
QStatusBar
*
bar
)
{
{
statusBar
=
bar
;
modeCamera
=
true
;
modeCamera
=
true
;
currentWidgetIndex
=
0
;
currentWidgetIndex
=
0
;
scene
=
new
SceneGraph
();
scene
=
new
SceneGraph
();
currentTransform
=
0
;
tesselation
=
1
;
tesselation
=
1
;
selectTransform
(
0
);
}
}
Controller
::~
Controller
(){
Controller
::~
Controller
(){
...
@@ -225,27 +226,37 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
...
@@ -225,27 +226,37 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
}
}
void
Controller
::
addSphere
(){
void
Controller
::
addSphere
(){
currentTransform
=
scene
->
addSphere
(
tesselation
);
selectTransform
(
scene
->
addSphere
(
tesselation
)
);
}
}
void
Controller
::
addBox
(){
void
Controller
::
addBox
(){
currentTransform
=
scene
->
addBox
(
tesselation
);
selectTransform
(
scene
->
addBox
(
tesselation
)
);
}
}
void
Controller
::
addCylinder
(){
void
Controller
::
addCylinder
(){
currentTransform
=
scene
->
addCylinder
(
tesselation
);
selectTransform
(
scene
->
addCylinder
(
tesselation
)
);
}
}
void
Controller
::
addCone
(){
void
Controller
::
addCone
(){
currentTransform
=
scene
->
addCone
(
tesselation
);
selectTransform
(
scene
->
addCone
(
tesselation
)
);
}
}
void
Controller
::
addTorus
(){
void
Controller
::
addTorus
(){
currentTransform
=
scene
->
addTorus
(
tesselation
);
selectTransform
(
scene
->
addTorus
(
tesselation
)
);
}
}
void
Controller
::
deletePrimitive
(){
void
Controller
::
deletePrimitive
(){
qDebug
(
"try deleting"
);
qDebug
(
"try deleting"
);
if
(
currentTransform
)
currentTransform
=
scene
->
deleteNode
(
currentTransform
);
if
(
currentTransform
)
selectTransform
(
scene
->
deleteNode
(
currentTransform
)
);
else
qDebug
(
"nothing selected. Did not call delete on scenegraph"
);
else
qDebug
(
"nothing selected. Did not call delete on scenegraph"
);
}
}
void
Controller
::
selectTransform
(
RigidBodyTransformation
*
rbt
){
currentTransform
=
rbt
;
if
(
currentTransform
){
statusBar
->
showMessage
(
currentTransform
->
getChild
()
->
getName
());
}
else
{
statusBar
->
showMessage
(
"None selected"
);
}
}
helloqube/controller.h
View file @
11a73823
...
@@ -27,7 +27,7 @@ class Controller : public QObject
...
@@ -27,7 +27,7 @@ class Controller : public QObject
Q_OBJECT
Q_OBJECT
public
:
public
:
Controller
();
Controller
(
QStatusBar
*
bar
);
~
Controller
();
~
Controller
();
void
initActions
(
QAction
*
cam
,
QAction
*
manipulate
);
void
initActions
(
QAction
*
cam
,
QAction
*
manipulate
);
...
@@ -51,6 +51,8 @@ private:
...
@@ -51,6 +51,8 @@ private:
QAction
*
modeManipulateAction
;
QAction
*
modeManipulateAction
;
int
currentWidgetIndex
;
int
currentWidgetIndex
;
//Status Bar
QStatusBar
*
statusBar
;
QWidget
*
quadViewWidget
;
QWidget
*
quadViewWidget
;
QWidget
*
doubleViewWidget
;
QWidget
*
doubleViewWidget
;
...
@@ -72,6 +74,8 @@ private:
...
@@ -72,6 +74,8 @@ private:
SceneGraph
*
scene
;
SceneGraph
*
scene
;
void
selectTransform
(
RigidBodyTransformation
*
rbt
);
public
slots
:
public
slots
:
void
switchToModeCamera
();
void
switchToModeCamera
();
void
switchToModeManipulate
();
void
switchToModeManipulate
();
...
...
helloqube/helloqube.pro.user
View file @
11a73823
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-21T21:
01:34
. -->
<!-- Written by QtCreator 3.5.1, 2015-11-21T21:
18:46
. -->
<qtcreator>
<qtcreator>
<data>
<data>
<variable>
EnvironmentId
</variable>
<variable>
EnvironmentId
</variable>
...
...
helloqube/mainwindow.cpp
View file @
11a73823
...
@@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent)
//4.0 Widget //Assignment 2: Multiple Widgets.
//4.0 Widget //Assignment 2: Multiple Widgets.
qDebug
(
"widgets..."
);
qDebug
(
"widgets..."
);
{
{
controller
=
new
Controller
();
controller
=
new
Controller
(
statusBar
);
myGLWidget
=
new
MyGLWidget
(
0
,
controller
,
true
,
QQuaternion
(),
this
);
myGLWidget
=
new
MyGLWidget
(
0
,
controller
,
true
,
QQuaternion
(),
this
);
setCentralWidget
(
myGLWidget
);
setCentralWidget
(
myGLWidget
);
...
...
helloqube/scenegraph.cpp
View file @
11a73823
...
@@ -21,7 +21,8 @@ void SceneGraph::registerView(MyGLWidget* view){
...
@@ -21,7 +21,8 @@ void SceneGraph::registerView(MyGLWidget* view){
//add primitives to sceneGraph
//add primitives to sceneGraph
RigidBodyTransformation
*
SceneGraph
::
addSphere
(
int
tesselation
){
RigidBodyTransformation
*
SceneGraph
::
addSphere
(
int
tesselation
){
nextSphereName
=
"Sphere "
+
sphereIndex
;
nextSphereName
=
"Sphere "
;
nextSphereName
.
append
(
QString
::
number
(
sphereIndex
));
//tesselation < 3 makes no sense (except for box)
//tesselation < 3 makes no sense (except for box)
int
t
=
tesselation
;
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
if
(
t
<
3
)
t
=
3
;
...
@@ -36,7 +37,8 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
...
@@ -36,7 +37,8 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
RigidBodyTransformation
*
SceneGraph
::
addBox
(
int
tesselation
){
RigidBodyTransformation
*
SceneGraph
::
addBox
(
int
tesselation
){
nextBoxName
=
"Box "
+
boxIndex
;
nextBoxName
=
"Box "
;
nextBoxName
.
append
(
QString
::
number
(
boxIndex
));
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextBoxName
,
tesselation
,
Primitive
::
Type
::
BOX
);
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextBoxName
,
tesselation
,
Primitive
::
Type
::
BOX
);
idCounter
++
;
idCounter
++
;
boxIndex
++
;
boxIndex
++
;
...
@@ -47,7 +49,8 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
...
@@ -47,7 +49,8 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
}
}
RigidBodyTransformation
*
SceneGraph
::
addCylinder
(
int
tesselation
){
RigidBodyTransformation
*
SceneGraph
::
addCylinder
(
int
tesselation
){
nextCylName
=
"Cylinder "
+
cylIndex
;
nextCylName
=
"Cylinder "
;
nextCylName
.
append
(
QString
::
number
(
cylIndex
));
int
t
=
tesselation
;
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextCylName
,
t
,
Primitive
::
Type
::
CYLINDER
);
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextCylName
,
t
,
Primitive
::
Type
::
CYLINDER
);
...
@@ -59,7 +62,8 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
...
@@ -59,7 +62,8 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
RigidBodyTransformation
*
SceneGraph
::
addCone
(
int
tesselation
){
RigidBodyTransformation
*
SceneGraph
::
addCone
(
int
tesselation
){
nextConeName
=
"Cone "
+
coneIndex
;
nextConeName
=
"Cone "
;
nextConeName
.
append
(
QString
::
number
(
coneIndex
));
int
t
=
tesselation
;
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextConeName
,
t
,
Primitive
::
Type
::
CONE
);
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextConeName
,
t
,
Primitive
::
Type
::
CONE
);
...
@@ -70,7 +74,8 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
...
@@ -70,7 +74,8 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
RigidBodyTransformation
*
SceneGraph
::
addTorus
(
int
tesselation
){
RigidBodyTransformation
*
SceneGraph
::
addTorus
(
int
tesselation
){
nextTorusName
=
"Torus "
+
torusIndex
;
nextTorusName
=
"Torus "
;
nextTorusName
.
append
(
QString
::
number
(
torusIndex
));
int
t
=
tesselation
;
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextTorusName
,
t
,
Primitive
::
Type
::
TORUS
);
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextTorusName
,
t
,
Primitive
::
Type
::
TORUS
);
...
...
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