Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
GraPa
Commits
c0274af6
Commit
c0274af6
authored
Dec 07, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transfer functions
parent
9fa4f133
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
155 additions
and
23 deletions
+155
-23
camera.cpp
A3/camera.cpp
+1
-1
controler.cpp
A3/controler.cpp
+36
-5
cubewidget.cpp
A3/cubewidget.cpp
+0
-3
display.frag
A3/display.frag
+7
-7
glview.cpp
A3/glview.cpp
+9
-2
glview.h
A3/glview.h
+1
-0
hellocube.pro
A3/hellocube.pro
+7
-2
mainwindow.cpp
A3/mainwindow.cpp
+85
-0
mainwindow.h
A3/mainwindow.h
+6
-0
scene.cpp
A3/scene.cpp
+2
-2
sceneobject.cpp
A3/sceneobject.cpp
+1
-1
treedelegate.cpp
A3/treedelegate.cpp
+0
-0
No files found.
A3/camera.cpp
View file @
c0274af6
...
...
@@ -45,7 +45,7 @@ void Camera::setupCamera(GLdouble aspect )
if
(
persp
){
perspective
(
45.0
,
aspect
,
0.01
,
100.0
);
}
else
{
int
size
=
4
;
int
size
=
2
;
glOrtho
(
-
size
*
aspect
,
size
*
aspect
,
-
size
,
size
,
0.01
,
100.0
);
}
...
...
A3/controler.cpp
View file @
c0274af6
...
...
@@ -10,6 +10,7 @@ Controler::Controler(MainWindow *mainwindow,Scene *scene)
this
->
mainwindow
=
mainwindow
;
this
->
scene
=
scene
;
viewMode
=
CAMERA
;
}
void
Controler
::
mousePressed
(
GLView
*
view
,
QMouseEvent
*
event
)
...
...
@@ -37,7 +38,7 @@ void Controler::mouseMoveEvent(GLView* view, QMouseEvent *event)
}
}
void
Controler
::
wheelEvent
(
GLView
*
view
,
QWheelEvent
*
event
)
{
void
Controler
::
wheelEvent
(
GLView
*
view
,
QWheelEvent
*
event
)
{
activeView
=
view
;
mainwindow
->
setActiveView
(
view
);
...
...
@@ -59,7 +60,7 @@ void Controler::mouseMoveEvent(GLView* view, QMouseEvent *event)
}
mainwindow
->
updateGL
();
}
}
QVector3D
*
Controler
::
trackballPoint
(
int
x
,
int
y
){
...
...
@@ -173,6 +174,12 @@ void Controler::addVolume(QString filePath){
char
***
data
=
new
char
**
[
z
];
int
*
histogram
=
new
int
[
256
];
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
histogram
[
i
]
=
0
;
}
int
count
=
0
;
// std::cout<<std::hex;
...
...
@@ -187,9 +194,12 @@ void Controler::addVolume(QString filePath){
data
[
k
][
j
]
=
new
char
[
x
];
for
(
int
i
=
0
;
i
<
x
;
i
++
)
{
data
[
k
][
j
][
i
]
=
rawdata
.
at
(
count
++
);
uchar
value
=
rawdata
.
at
(
count
++
);
data
[
k
][
j
][
i
]
=
value
;
histogram
[
value
]
++
;
if
(
k
==
printLine
){
int
temp
=
((
uchar
)
data
[
k
][
j
][
i
])
*
9
/
256
;
int
temp
=
value
*
9
/
256
;
std
::
cout
<<
temp
;
}
}
...
...
@@ -199,6 +209,8 @@ void Controler::addVolume(QString filePath){
}
}
//qDebug()<<file.readData(data,file.size()-file.pos());
int
type
=
GL_UNSIGNED_BYTE
;
if
(
rawdata
.
size
()
>
x
*
y
*
z
)
...
...
@@ -211,8 +223,27 @@ void Controler::addVolume(QString filePath){
scene
->
addSceneObjectTaActive
(
volume
);
file
.
close
();
uchar
*
trans
=
new
uchar
[
4
*
256
];
for
(
int
i
=
0
;
i
<
256
;
i
+=
1
){
int
index
=
i
*
4
;
trans
[
index
]
=
i
;
trans
[
index
+
1
]
=
i
;
trans
[
index
+
2
]
=
i
;
trans
[
index
+
3
]
=
i
;
}
for
(
int
i
=
0
;
i
<
4
;
i
++
){
// mainwindow->getViews()[i]->loadTransfer(trans);
}
this
->
mainwindow
->
transEditor
->
setHistogram
(
histogram
);
// this->mainwindow->transEditor->setTransferFunction(trans);
qDebug
()
<<
"File Read finish"
;
...
...
A3/cubewidget.cpp
View file @
c0274af6
...
...
@@ -255,8 +255,6 @@ void CubeWidget::mousePressEvent(QMouseEvent *event )
lastSpeherePos
=
trackballPoint
(
event
->
pos
().
x
(),
event
->
pos
().
y
());
lastScreenPos
=
new
QPointF
(
event
->
screenPos
());
event
->
accept
();
}
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
...
...
@@ -312,7 +310,6 @@ QVector3D* CubeWidget::trackballPoint(int x, int y){
zo
=
qMax
(
qCos
(
M_PI_2
*
d
),
qreal
(
0.0
));
//qMin(d,1.0f)
QVector3D
*
pos
=
new
QVector3D
(
xo
,
yo
,
zo
);
pos
->
normalize
();
// qDebug()<<"x:"<< xo << " y:"<<yo<<" z:"<<zo;
...
...
A3/display.frag
View file @
c0274af6
...
...
@@ -17,9 +17,10 @@ float stepsize = 0.001;
vec4
transfer
(
float
scalar
){
float
pos
=
(
scalar
*
255
.
0
/
256
.
0
+
0
.
5
*
256
.
0
);
return
vec4
(
scalar
);
//return texture1D(transferData,pos);
float
pos
=
(
scalar
*
255
.
0
/
256
.
0
+
1
/
256
.
0
/
2
);
//return vec4(scalar);
//return vec4(pos);
return
texture1D
(
transferData
,
pos
);
}
vec3
phong
(
vec3
color
,
vec3
normal
){
...
...
@@ -101,10 +102,9 @@ void main(void)
}
// gl_FragColor = vec4(gl_TexCoord[0].xyz,1);
//gl_FragColor = vec4(vec3(count),1);
//gl_FragColor = vec4(normalize(step),1);
//gl_FragColor = vec4(normalize(gl_ModelViewProjectionMatrixInverse*vec4(0,1,0,0.0)));
//gl_FragColor = vec4(texture1D(transferData,front.x));
//gl_FragColor = vec4(gl_TexCoord[0].xyz,1);
//gl_FragColor = vec4(texture3D(volumeData,vec3(front.xy,0.5)).x);
}
}
...
...
A3/glview.cpp
View file @
c0274af6
...
...
@@ -12,6 +12,7 @@ GLView::GLView(Scene *scene,Camera * camera,Controler *controler )
gridStepSize
=
1
;
isGridEnabled
=
false
;
MIP
=
false
;
afterInit
=
false
;
}
QSize
GLView
::
minimumSizeHint
()
const
...
...
@@ -53,6 +54,7 @@ void GLView::initializeGL ( ) {
//Shader Setup
initShader
();
shader
->
bind
();
afterInit
=
true
;
}
void
GLView
::
initShader
()
...
...
@@ -432,18 +434,23 @@ void GLView::loadData(int width, int height, int depth, char* data, int type )
void
GLView
::
loadTransfer
(
uchar
*
data
)
{
// uchar *test = new uchar[4*256];
// for(int i = 0; i< 4*256;i++){
// test[i] = data[i];
// }
glGenTextures
(
1
,
&
transferFunction
);
glBindTexture
(
GL_TEXTURE_1D
,
transferFunction
);
// Filtering
glTexParameteri
(
GL_TEXTURE_1D
,
GL_TEXTURE_MIN_FILTER
,
GL_
LINEAR
);
glTexParameteri
(
GL_TEXTURE_1D
,
GL_TEXTURE_MAG_FILTER
,
GL_
LINEAR
);
glTexParameteri
(
GL_TEXTURE_1D
,
GL_TEXTURE_MIN_FILTER
,
GL_
NEAREST
);
glTexParameteri
(
GL_TEXTURE_1D
,
GL_TEXTURE_MAG_FILTER
,
GL_
NEAREST
);
// Wrap
glTexParameteri
(
GL_TEXTURE_1D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP
);
glTexImage1D
(
GL_TEXTURE_1D
,
0
,
GL_RGBA
,
256
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
data
);
if
(
afterInit
)
updateGL
();
}
...
...
A3/glview.h
View file @
c0274af6
...
...
@@ -44,6 +44,7 @@ public:
Camera
*
getCamera
();
private
:
bool
afterInit
;
QGLShaderProgram
*
shader
;
QGLShaderProgram
*
displayShader
;
Scene
*
scene
;
...
...
A3/hellocube.pro
View file @
c0274af6
...
...
@@ -25,7 +25,8 @@ SOURCES += main.cpp\
sceneobject
.
cpp
\
scenenode
.
cpp
\
treedelegate
.
cpp
\
scenevolume
.
cpp
scenevolume
.
cpp
\
transferfunctioneditor
.
cpp
HEADERS
+=
mainwindow
.
h
\
cubewidget
.
h
\
...
...
@@ -38,7 +39,8 @@ HEADERS += mainwindow.h \
scenenode
.
h
\
glut
.
h
\
treedelegate
.
h
\
scenevolume
.
h
scenevolume
.
h
\
transferfunctioneditor
.
h
RESOURCES
+=
\
hellocube
.
qrc
...
...
@@ -48,3 +50,6 @@ DISTFILES += \
phong
.
vert
\
display
.
frag
\
display
.
vert
FORMS
+=
\
transferui
.
ui
A3/mainwindow.cpp
View file @
c0274af6
...
...
@@ -279,6 +279,8 @@ MainWindow::MainWindow(QWidget *parent)
// Assemble Menus
fileMenu
->
addAction
(
exitAction
);
menuBar
->
addMenu
(
fileMenu
);
...
...
@@ -325,9 +327,92 @@ void MainWindow::initDoc()
dock
->
setWidget
(
sceneView
);
//Transfer Function Doc
QDockWidget
*
transferDock
=
new
QDockWidget
(
"Transfer Function Editor"
,
this
);
transferDock
->
setAllowedAreas
(
Qt
::
LeftDockWidgetArea
|
Qt
::
RightDockWidgetArea
);
transEditor
=
new
TransferFunctionEditor
(
this
);
connect
(
transEditor
,
SIGNAL
(
dataChanged
(
uchar
*
)),
perspectiveView
,
SLOT
(
loadTransfer
(
uchar
*
)));
connect
(
transEditor
,
SIGNAL
(
dataChanged
(
uchar
*
)),
frontView
,
SLOT
(
loadTransfer
(
uchar
*
)));
connect
(
transEditor
,
SIGNAL
(
dataChanged
(
uchar
*
)),
leftView
,
SLOT
(
loadTransfer
(
uchar
*
)));
connect
(
transEditor
,
SIGNAL
(
dataChanged
(
uchar
*
)),
topView
,
SLOT
(
loadTransfer
(
uchar
*
)));
QPushButton
*
save
=
new
QPushButton
(
"Save"
);
connect
(
save
,
SIGNAL
(
released
()),
transEditor
,
SLOT
(
save
()));
QPushButton
*
load
=
new
QPushButton
(
"Load"
);
connect
(
load
,
SIGNAL
(
released
()),
transEditor
,
SLOT
(
load
()));
QPushButton
*
reset
=
new
QPushButton
(
"Reset"
);
connect
(
reset
,
SIGNAL
(
released
()),
transEditor
,
SLOT
(
reset
()));
QPushButton
*
Smooth
=
new
QPushButton
(
"smooth"
);
connect
(
Smooth
,
SIGNAL
(
released
()),
transEditor
,
SLOT
(
smooth
()));
QCheckBox
*
red
=
new
QCheckBox
(
"red"
);
red
->
setChecked
(
true
);
connect
(
red
,
SIGNAL
(
clicked
(
bool
)),
transEditor
,
SLOT
(
paintRed
(
bool
)));
QCheckBox
*
green
=
new
QCheckBox
(
"green"
);
green
->
setChecked
(
true
);
connect
(
green
,
SIGNAL
(
clicked
(
bool
)),
transEditor
,
SLOT
(
paintGreen
(
bool
)));
QCheckBox
*
blue
=
new
QCheckBox
(
"blue"
);
blue
->
setChecked
(
true
);
connect
(
blue
,
SIGNAL
(
clicked
(
bool
)),
transEditor
,
SLOT
(
paintBlue
(
bool
)));
QCheckBox
*
alpha
=
new
QCheckBox
(
"alpha"
);
alpha
->
setChecked
(
true
);
connect
(
alpha
,
SIGNAL
(
clicked
(
bool
)),
transEditor
,
SLOT
(
paintAlpha
(
bool
)));
QWidget
*
all
=
new
QWidget
;
QWidget
*
buttons
=
new
QWidget
;
QWidget
*
left
=
new
QWidget
;
QWidget
*
right
=
new
QWidget
;
QVBoxLayout
*
checkLayout
=
new
QVBoxLayout
;
checkLayout
->
addWidget
(
red
);
checkLayout
->
addWidget
(
green
);
checkLayout
->
addWidget
(
blue
);
checkLayout
->
addWidget
(
alpha
);
right
->
setLayout
(
checkLayout
);
QGridLayout
*
butLayout
=
new
QGridLayout
;
butLayout
->
addWidget
(
save
,
0
,
0
);
butLayout
->
addWidget
(
load
,
0
,
1
);
butLayout
->
addWidget
(
reset
,
1
,
0
);
butLayout
->
addWidget
(
Smooth
,
1
,
1
);
left
->
setLayout
(
butLayout
);
QHBoxLayout
*
buttonsLayout
=
new
QHBoxLayout
;
buttonsLayout
->
addWidget
(
left
);
buttonsLayout
->
addWidget
(
right
);
buttons
->
setLayout
(
buttonsLayout
);
QVBoxLayout
*
allLayout
=
new
QVBoxLayout
;
allLayout
->
addWidget
(
transEditor
);
allLayout
->
addWidget
(
buttons
);
all
->
setLayout
(
allLayout
);
transferDock
->
setWidget
(
all
);
transferDock
->
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Maximum
);
addDockWidget
(
Qt
::
RightDockWidgetArea
,
transferDock
);
addDockWidget
(
Qt
::
RightDockWidgetArea
,
dock
);
}
void
MainWindow
::
updateStatusBar
()
...
...
A3/mainwindow.h
View file @
c0274af6
...
...
@@ -12,11 +12,13 @@
#include <QStatusBar>
#include <QSlider>
#include <QSplitter>
#include <QPushButton>
#include <glview.h>
#include <scene.h>
#include <camera.h>
#include <controler.h>
#include <transferfunctioneditor.h>
class
MainWindow
:
public
QMainWindow
{
...
...
@@ -80,6 +82,7 @@ private:
QTimer
*
timer
;
void
initDoc
();
void
initViews
();
...
...
@@ -99,6 +102,9 @@ public:
void
initPrimitivesMenu
();
TransferFunctionEditor
*
transEditor
;
public
slots
:
void
updateGL
();
void
updateStatusBar
();
...
...
A3/scene.cpp
View file @
c0274af6
...
...
@@ -122,9 +122,9 @@ void Scene::deletActive()
int
pos
=
active
->
childNumber
();
//qDebug()<<"Delet Active in Scene"<<parentIndex<<parent->childCount()<<pos;
foreach
(
SceneObject
*
t
,
parent
->
getChildren
())
{
//
foreach (SceneObject * t, parent->getChildren()) {
// qDebug()<<t->getName()<<t->childNumber();
}
//
}
beginRemoveRows
(
parentIndex
,
pos
,
pos
);
parent
->
remove
(
pos
);
...
...
A3/sceneobject.cpp
View file @
c0274af6
...
...
@@ -2,7 +2,7 @@
#include "scenenode.h"
int
Scene
Node
::
idCount
=
1
;
int
Scene
Object
::
idCount
=
1
;
SceneObject
::
SceneObject
()
{
...
...
A3/treedelegate.cpp
View file @
c0274af6
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