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
ab86fe42
Commit
ab86fe42
authored
Nov 22, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
somehow working tree display?!
parent
bcc14a79
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
83 additions
and
15 deletions
+83
-15
mainwindow.cpp
helloqube/mainwindow.cpp
+6
-0
mainwindow.h
helloqube/mainwindow.h
+2
-0
myitemmodel.cpp
helloqube/myitemmodel.cpp
+37
-0
myitemmodel.h
helloqube/myitemmodel.h
+4
-0
primitive.cpp
helloqube/primitive.cpp
+10
-2
primitive.h
helloqube/primitive.h
+3
-1
rigidbodytransformation.cpp
helloqube/rigidbodytransformation.cpp
+9
-4
rigidbodytransformation.h
helloqube/rigidbodytransformation.h
+3
-1
scenegraph.cpp
helloqube/scenegraph.cpp
+8
-6
treeitem.h
helloqube/treeitem.h
+1
-1
No files found.
helloqube/mainwindow.cpp
View file @
ab86fe42
...
...
@@ -244,10 +244,16 @@ MainWindow::MainWindow(QWidget *parent)
deletePrimitive
->
setShortcut
(
QKeySequence
(
Qt
::
Key_Delete
));
dockWidget
=
new
QDockWidget
(
tr
(
"Scenegraph"
),
this
);
dockWidget
->
setAllowedAreas
(
Qt
::
LeftDockWidgetArea
|
Qt
::
RightDockWidgetArea
);
treeView
=
new
QTreeView
(
this
);
treeView
->
setModel
(
controller
->
getSceneGraph
()
->
getModel
());
treeView
->
expandAll
();
dockWidget
->
setWidget
(
treeView
);
addDockWidget
(
Qt
::
RightDockWidgetArea
,
dockWidget
);
}
...
...
helloqube/mainwindow.h
View file @
ab86fe42
...
...
@@ -19,6 +19,7 @@
#include <QTreeView>
#include <scenegraph.h>
#include <myitemmodel.h>
#include <QDockWidget>
class
MainWindow
:
public
QMainWindow
{
Q_OBJECT
...
...
@@ -89,6 +90,7 @@ private:
QAction
*
deletePrimitive
;
QDockWidget
*
dockWidget
;
QTreeView
*
treeView
;
public
slots
:
...
...
helloqube/myitemmodel.cpp
View file @
ab86fe42
...
...
@@ -31,6 +31,7 @@ QVariant MyItemModel::data(const QModelIndex &index, int role) const{
return
item
->
data
(
index
.
column
());
}
QVariant
MyItemModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
//Im tutorial stand mehr. erstmal ignorieren.
return
root
->
data
(
section
);
...
...
@@ -89,3 +90,39 @@ TreeItem* MyItemModel::getItem(const QModelIndex& index) const{
}
return
root
;
}
bool
MyItemModel
::
insertRows
(
int
position
,
int
rows
,
const
QModelIndex
&
parent
)
{
beginInsertRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
TreeItem
*
p
=
getItem
(
parent
);
for
(
int
row
=
0
;
row
<
rows
;
++
row
)
{
qDebug
(
"Add Child to item"
);
p
->
addChild
(
new
TreeItem
());
}
endInsertRows
();
return
true
;
}
void
MyItemModel
::
addChildToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
){
beginInsertRows
(
QModelIndex
(),
0
,
0
);
qDebug
()
<<
"Add child "
<<
rbt
->
data
(
0
);
root
->
addChild
(
rbt
);
endInsertRows
();
QModelIndex
i
=
index
(
0
,
0
,
QModelIndex
());
beginInsertRows
(
i
,
0
,
0
);
qDebug
()
<<
"Add primitive "
<<
prim
->
data
(
0
)
<<
" at "
<<
i
;
rbt
->
addChild
(
prim
);
endInsertRows
();
// return true;
}
helloqube/myitemmodel.h
View file @
ab86fe42
...
...
@@ -22,6 +22,10 @@ public:
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
Q_DECL_OVERRIDE
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
Q_DECL_OVERRIDE
;
void
addChildToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
);
bool
insertRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
);
private
:
TreeItem
*
root
;
...
...
helloqube/primitive.cpp
View file @
ab86fe42
...
...
@@ -14,9 +14,9 @@ QString Primitive::getName(){
return
name
;
}
Primitive
::
Primitive
(
int
ID
,
QString
name
,
int
tesselation
,
Type
t
){
this
->
ID
=
ID
;
Primitive
::
Primitive
(
QString
name
,
int
ID
,
int
tesselation
,
Type
t
){
this
->
name
=
name
;
this
->
ID
=
ID
;
this
->
tesselation
=
tesselation
;
this
->
type
=
t
;
}
...
...
@@ -28,3 +28,11 @@ int Primitive::getTesselation(){
Primitive
::
Type
Primitive
::
getType
(){
return
type
;
}
QVariant
Primitive
::
data
(
int
column
){
if
(
column
==
0
)
return
QVariant
(
name
);
else
if
(
column
==
1
)
return
QVariant
(
ID
);
else
if
(
column
==
2
)
return
QVariant
(
tesselation
);
else
if
(
column
==
4
)
return
QVariant
(
type
);
else
return
QVariant
();
}
helloqube/primitive.h
View file @
ab86fe42
...
...
@@ -14,13 +14,15 @@ public:
Primitive
();
~
Primitive
();
Primitive
(
int
ID
,
QString
name
,
int
tesselation
,
Type
t
);
Primitive
(
QString
name
,
int
ID
,
int
tesselation
,
Type
t
);
int
getTesselation
();
Primitive
::
Type
getType
();
QString
getName
();
QVariant
data
(
int
column
)
override
;
protected
:
int
ID
;
int
tesselation
;
...
...
helloqube/rigidbodytransformation.cpp
View file @
ab86fe42
#include "rigidbodytransformation.h"
#include "primitive.h"
RigidBodyTransformation
::
RigidBodyTransformation
(
Primitive
*
child
)
RigidBodyTransformation
::
RigidBodyTransformation
()
{
translation
=
QVector3D
(
0
,
0
,
0
);
rotation
=
QQuaternion
();
// this->child = child;
children
.
append
(
child
);
name
=
""
;
// qDebug() << "new rbt " << tx << "," << ty << "," << tz << ", rot " << rotation;
}
...
...
@@ -16,6 +13,14 @@ RigidBodyTransformation::~RigidBodyTransformation(){
//apparently I do not need to call the baseclass destructor.
}
//0 = name, 1 = translation, 2=rotation
QVariant
RigidBodyTransformation
::
data
(
int
column
){
if
(
column
==
0
)
return
QVariant
(
name
);
else
if
(
column
==
1
)
return
QVariant
(
translation
);
else
if
(
column
==
2
)
return
QVariant
(
rotation
);
else
return
QVariant
();
}
void
RigidBodyTransformation
::
addTranslation
(
QVector3D
diff
){
translation
+=
diff
;
...
...
helloqube/rigidbodytransformation.h
View file @
ab86fe42
...
...
@@ -9,7 +9,7 @@ class Primitive;
class
RigidBodyTransformation
:
public
TreeItem
{
public
:
RigidBodyTransformation
(
Primitive
*
child
);
RigidBodyTransformation
();
~
RigidBodyTransformation
();
void
addTranslation
(
QVector3D
diff
);
...
...
@@ -22,6 +22,8 @@ public:
void
drawChild
();
QVariant
data
(
int
column
)
override
;
private
:
//translation
QVector3D
translation
;
...
...
helloqube/scenegraph.cpp
View file @
ab86fe42
...
...
@@ -32,7 +32,7 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
//tesselation < 3 makes no sense (except for box)
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextSphereName
,
t
,
Primitive
::
Type
::
SPHERE
);
Primitive
*
p
=
new
Primitive
(
nextSphereName
,
idCounter
,
t
,
Primitive
::
Type
::
SPHERE
);
idCounter
++
;
sphereIndex
++
;
...
...
@@ -45,7 +45,7 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
nextBoxName
=
"Box "
;
nextBoxName
.
append
(
QString
::
number
(
boxIndex
));
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextBoxName
,
tesselation
,
Primitive
::
Type
::
BOX
);
Primitive
*
p
=
new
Primitive
(
nextBoxName
,
idCounter
,
tesselation
,
Primitive
::
Type
::
BOX
);
idCounter
++
;
boxIndex
++
;
...
...
@@ -59,7 +59,7 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
nextCylName
.
append
(
QString
::
number
(
cylIndex
));
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextCylName
,
t
,
Primitive
::
Type
::
CYLINDER
);
Primitive
*
p
=
new
Primitive
(
nextCylName
,
idCounter
,
t
,
Primitive
::
Type
::
CYLINDER
);
idCounter
++
;
cylIndex
++
;
qDebug
(
"added Cylinder to scenegraph"
);
...
...
@@ -72,7 +72,7 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
nextConeName
.
append
(
QString
::
number
(
coneIndex
));
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextConeName
,
t
,
Primitive
::
Type
::
CONE
);
Primitive
*
p
=
new
Primitive
(
nextConeName
,
idCounter
,
t
,
Primitive
::
Type
::
CONE
);
idCounter
++
;
coneIndex
++
;
return
addPrimitive
(
p
);
...
...
@@ -84,15 +84,17 @@ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
nextTorusName
.
append
(
QString
::
number
(
torusIndex
));
int
t
=
tesselation
;
if
(
t
<
3
)
t
=
3
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextTorusName
,
t
,
Primitive
::
Type
::
TORUS
);
Primitive
*
p
=
new
Primitive
(
nextTorusName
,
idCounter
,
t
,
Primitive
::
Type
::
TORUS
);
idCounter
++
;
torusIndex
++
;
return
addPrimitive
(
p
);
}
RigidBodyTransformation
*
SceneGraph
::
addPrimitive
(
Primitive
*
p
){
RigidBodyTransformation
*
r
=
new
RigidBodyTransformation
(
p
);
RigidBodyTransformation
*
r
=
new
RigidBodyTransformation
();
nodes
.
append
(
r
);
model
->
addChildToRoot
(
r
,
p
);
// model->insertRows(1,1,QModelIndex());
notifyViews
();
return
r
;
}
...
...
helloqube/treeitem.h
View file @
ab86fe42
...
...
@@ -16,7 +16,7 @@ public:
int
getChildrenCount
();
int
columnCount
();
QVariant
data
(
int
column
);
//returns QVariant for name string
virtual
QVariant
data
(
int
column
);
//returns QVariant for name string
void
addChild
(
TreeItem
*
item
);
bool
removeChild
(
TreeItem
*
item
);
...
...
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