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)
...
@@ -244,10 +244,16 @@ MainWindow::MainWindow(QWidget *parent)
deletePrimitive
->
setShortcut
(
QKeySequence
(
Qt
::
Key_Delete
));
deletePrimitive
->
setShortcut
(
QKeySequence
(
Qt
::
Key_Delete
));
dockWidget
=
new
QDockWidget
(
tr
(
"Scenegraph"
),
this
);
dockWidget
->
setAllowedAreas
(
Qt
::
LeftDockWidgetArea
|
Qt
::
RightDockWidgetArea
);
treeView
=
new
QTreeView
(
this
);
treeView
=
new
QTreeView
(
this
);
treeView
->
setModel
(
controller
->
getSceneGraph
()
->
getModel
());
treeView
->
setModel
(
controller
->
getSceneGraph
()
->
getModel
());
treeView
->
expandAll
();
treeView
->
expandAll
();
dockWidget
->
setWidget
(
treeView
);
addDockWidget
(
Qt
::
RightDockWidgetArea
,
dockWidget
);
}
}
...
...
helloqube/mainwindow.h
View file @
ab86fe42
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include <QTreeView>
#include <QTreeView>
#include <scenegraph.h>
#include <scenegraph.h>
#include <myitemmodel.h>
#include <myitemmodel.h>
#include <QDockWidget>
class
MainWindow
:
public
QMainWindow
class
MainWindow
:
public
QMainWindow
{
{
Q_OBJECT
Q_OBJECT
...
@@ -89,6 +90,7 @@ private:
...
@@ -89,6 +90,7 @@ private:
QAction
*
deletePrimitive
;
QAction
*
deletePrimitive
;
QDockWidget
*
dockWidget
;
QTreeView
*
treeView
;
QTreeView
*
treeView
;
public
slots
:
public
slots
:
...
...
helloqube/myitemmodel.cpp
View file @
ab86fe42
...
@@ -31,6 +31,7 @@ QVariant MyItemModel::data(const QModelIndex &index, int role) const{
...
@@ -31,6 +31,7 @@ QVariant MyItemModel::data(const QModelIndex &index, int role) const{
return
item
->
data
(
index
.
column
());
return
item
->
data
(
index
.
column
());
}
}
QVariant
MyItemModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
QVariant
MyItemModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
//Im tutorial stand mehr. erstmal ignorieren.
//Im tutorial stand mehr. erstmal ignorieren.
return
root
->
data
(
section
);
return
root
->
data
(
section
);
...
@@ -89,3 +90,39 @@ TreeItem* MyItemModel::getItem(const QModelIndex& index) const{
...
@@ -89,3 +90,39 @@ TreeItem* MyItemModel::getItem(const QModelIndex& index) const{
}
}
return
root
;
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:
...
@@ -22,6 +22,10 @@ public:
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
Q_DECL_OVERRIDE
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
Q_DECL_OVERRIDE
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
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
:
private
:
TreeItem
*
root
;
TreeItem
*
root
;
...
...
helloqube/primitive.cpp
View file @
ab86fe42
...
@@ -14,9 +14,9 @@ QString Primitive::getName(){
...
@@ -14,9 +14,9 @@ QString Primitive::getName(){
return
name
;
return
name
;
}
}
Primitive
::
Primitive
(
int
ID
,
QString
name
,
int
tesselation
,
Type
t
){
Primitive
::
Primitive
(
QString
name
,
int
ID
,
int
tesselation
,
Type
t
){
this
->
ID
=
ID
;
this
->
name
=
name
;
this
->
name
=
name
;
this
->
ID
=
ID
;
this
->
tesselation
=
tesselation
;
this
->
tesselation
=
tesselation
;
this
->
type
=
t
;
this
->
type
=
t
;
}
}
...
@@ -28,3 +28,11 @@ int Primitive::getTesselation(){
...
@@ -28,3 +28,11 @@ int Primitive::getTesselation(){
Primitive
::
Type
Primitive
::
getType
(){
Primitive
::
Type
Primitive
::
getType
(){
return
type
;
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:
...
@@ -14,13 +14,15 @@ public:
Primitive
();
Primitive
();
~
Primitive
();
~
Primitive
();
Primitive
(
int
ID
,
QString
name
,
int
tesselation
,
Type
t
);
Primitive
(
QString
name
,
int
ID
,
int
tesselation
,
Type
t
);
int
getTesselation
();
int
getTesselation
();
Primitive
::
Type
getType
();
Primitive
::
Type
getType
();
QString
getName
();
QString
getName
();
QVariant
data
(
int
column
)
override
;
protected
:
protected
:
int
ID
;
int
ID
;
int
tesselation
;
int
tesselation
;
...
...
helloqube/rigidbodytransformation.cpp
View file @
ab86fe42
#include "rigidbodytransformation.h"
#include "rigidbodytransformation.h"
#include "primitive.h"
#include "primitive.h"
RigidBodyTransformation
::
RigidBodyTransformation
(
Primitive
*
child
)
RigidBodyTransformation
::
RigidBodyTransformation
()
{
{
translation
=
QVector3D
(
0
,
0
,
0
);
translation
=
QVector3D
(
0
,
0
,
0
);
rotation
=
QQuaternion
();
rotation
=
QQuaternion
();
// this->child = child;
children
.
append
(
child
);
name
=
""
;
name
=
""
;
// qDebug() << "new rbt " << tx << "," << ty << "," << tz << ", rot " << rotation;
// qDebug() << "new rbt " << tx << "," << ty << "," << tz << ", rot " << rotation;
}
}
...
@@ -16,6 +13,14 @@ RigidBodyTransformation::~RigidBodyTransformation(){
...
@@ -16,6 +13,14 @@ RigidBodyTransformation::~RigidBodyTransformation(){
//apparently I do not need to call the baseclass destructor.
//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
){
void
RigidBodyTransformation
::
addTranslation
(
QVector3D
diff
){
translation
+=
diff
;
translation
+=
diff
;
...
...
helloqube/rigidbodytransformation.h
View file @
ab86fe42
...
@@ -9,7 +9,7 @@ class Primitive;
...
@@ -9,7 +9,7 @@ class Primitive;
class
RigidBodyTransformation
:
public
TreeItem
class
RigidBodyTransformation
:
public
TreeItem
{
{
public
:
public
:
RigidBodyTransformation
(
Primitive
*
child
);
RigidBodyTransformation
();
~
RigidBodyTransformation
();
~
RigidBodyTransformation
();
void
addTranslation
(
QVector3D
diff
);
void
addTranslation
(
QVector3D
diff
);
...
@@ -22,6 +22,8 @@ public:
...
@@ -22,6 +22,8 @@ public:
void
drawChild
();
void
drawChild
();
QVariant
data
(
int
column
)
override
;
private
:
private
:
//translation
//translation
QVector3D
translation
;
QVector3D
translation
;
...
...
helloqube/scenegraph.cpp
View file @
ab86fe42
...
@@ -32,7 +32,7 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
...
@@ -32,7 +32,7 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
//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
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextSphereName
,
t
,
Primitive
::
Type
::
SPHERE
);
Primitive
*
p
=
new
Primitive
(
nextSphereName
,
idCounter
,
t
,
Primitive
::
Type
::
SPHERE
);
idCounter
++
;
idCounter
++
;
sphereIndex
++
;
sphereIndex
++
;
...
@@ -45,7 +45,7 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
...
@@ -45,7 +45,7 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
nextBoxName
=
"Box "
;
nextBoxName
=
"Box "
;
nextBoxName
.
append
(
QString
::
number
(
boxIndex
));
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
++
;
idCounter
++
;
boxIndex
++
;
boxIndex
++
;
...
@@ -59,7 +59,7 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
...
@@ -59,7 +59,7 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
nextCylName
.
append
(
QString
::
number
(
cylIndex
));
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
(
nextCylName
,
idCounter
,
t
,
Primitive
::
Type
::
CYLINDER
);
idCounter
++
;
idCounter
++
;
cylIndex
++
;
cylIndex
++
;
qDebug
(
"added Cylinder to scenegraph"
);
qDebug
(
"added Cylinder to scenegraph"
);
...
@@ -72,7 +72,7 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
...
@@ -72,7 +72,7 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
nextConeName
.
append
(
QString
::
number
(
coneIndex
));
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
(
nextConeName
,
idCounter
,
t
,
Primitive
::
Type
::
CONE
);
idCounter
++
;
idCounter
++
;
coneIndex
++
;
coneIndex
++
;
return
addPrimitive
(
p
);
return
addPrimitive
(
p
);
...
@@ -84,15 +84,17 @@ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
...
@@ -84,15 +84,17 @@ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
nextTorusName
.
append
(
QString
::
number
(
torusIndex
));
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
(
nextTorusName
,
idCounter
,
t
,
Primitive
::
Type
::
TORUS
);
idCounter
++
;
idCounter
++
;
torusIndex
++
;
torusIndex
++
;
return
addPrimitive
(
p
);
return
addPrimitive
(
p
);
}
}
RigidBodyTransformation
*
SceneGraph
::
addPrimitive
(
Primitive
*
p
){
RigidBodyTransformation
*
SceneGraph
::
addPrimitive
(
Primitive
*
p
){
RigidBodyTransformation
*
r
=
new
RigidBodyTransformation
(
p
);
RigidBodyTransformation
*
r
=
new
RigidBodyTransformation
();
nodes
.
append
(
r
);
nodes
.
append
(
r
);
model
->
addChildToRoot
(
r
,
p
);
// model->insertRows(1,1,QModelIndex());
notifyViews
();
notifyViews
();
return
r
;
return
r
;
}
}
...
...
helloqube/treeitem.h
View file @
ab86fe42
...
@@ -16,7 +16,7 @@ public:
...
@@ -16,7 +16,7 @@ public:
int
getChildrenCount
();
int
getChildrenCount
();
int
columnCount
();
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
);
void
addChild
(
TreeItem
*
item
);
bool
removeChild
(
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