Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
01cbcb29
Commit
01cbcb29
authored
Dec 09, 2009
by
schurade
Browse files
[ADD] fill the HUD with pick result
parent
1ea58f7c
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
230 additions
and
115 deletions
+230
-115
src/graphicsEngine/WGEViewer.cpp
src/graphicsEngine/WGEViewer.cpp
+6
-4
src/graphicsEngine/WGEViewer.h
src/graphicsEngine/WGEViewer.h
+15
-0
src/graphicsEngine/WPickHandler.cpp
src/graphicsEngine/WPickHandler.cpp
+19
-34
src/graphicsEngine/WPickHandler.h
src/graphicsEngine/WPickHandler.h
+3
-4
src/gui/WGUI.h
src/gui/WGUI.h
+6
-2
src/gui/qt4/WMainWindow.cpp
src/gui/qt4/WMainWindow.cpp
+6
-1
src/gui/qt4/WMainWindow.h
src/gui/qt4/WMainWindow.h
+8
-3
src/gui/qt4/WQt4Gui.cpp
src/gui/qt4/WQt4Gui.cpp
+7
-1
src/gui/qt4/WQt4Gui.h
src/gui/qt4/WQt4Gui.h
+3
-1
src/gui/qt4/WQtGLWidget.cpp
src/gui/qt4/WQtGLWidget.cpp
+6
-0
src/gui/qt4/WQtGLWidget.h
src/gui/qt4/WQtGLWidget.h
+6
-0
src/modules/hud/WMHud.cpp
src/modules/hud/WMHud.cpp
+20
-0
src/modules/hud/WMHud.h
src/modules/hud/WMHud.h
+11
-0
src/modules/navSlices/WMNavSlices.cpp
src/modules/navSlices/WMNavSlices.cpp
+114
-65
No files found.
src/graphicsEngine/WGEViewer.cpp
View file @
01cbcb29
...
...
@@ -84,10 +84,8 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, i
m_View
->
setLightingMode
(
osg
::
View
::
HEADLIGHT
);
// this is the default anyway
osg
::
ref_ptr
<
osgText
::
Text
>
updateText
=
new
osgText
::
Text
;
m_View
->
addEventHandler
(
new
WPickHandler
(
updateText
.
get
()
)
);
keyEvent
(
WGEViewer
::
KEYPRESS
,
' '
);
m_pickHandler
=
osg
::
ref_ptr
<
WPickHandler
>
(
new
WPickHandler
()
);
m_View
->
addEventHandler
(
m_pickHandler
);
}
catch
(
...
)
{
...
...
@@ -162,3 +160,7 @@ std::string WGEViewer::getName() const
return
m_name
;
}
osg
::
ref_ptr
<
WPickHandler
>
WGEViewer
::
getPickHandler
()
{
return
m_pickHandler
;
}
src/graphicsEngine/WGEViewer.h
View file @
01cbcb29
...
...
@@ -44,6 +44,7 @@
#include "WGEGraphicsWindow.h"
#include "WGECamera.h"
#include "WPickHandler.h"
#include "WGEZoomTrackballManipulator.h"
...
...
@@ -142,6 +143,8 @@ public:
/**
* Returns the name of the viewer.
*
* \return the name
*/
std
::
string
getName
()
const
;
...
...
@@ -150,6 +153,13 @@ public:
*/
void
setBgColor
(
WColor
bgColor
);
/**
* Getter for the pick handler
*
* \return the pick handler
*/
osg
::
ref_ptr
<
WPickHandler
>
getPickHandler
();
protected:
/**
...
...
@@ -162,6 +172,11 @@ protected:
*/
std
::
string
m_name
;
/**
*
*/
osg
::
ref_ptr
<
WPickHandler
>
m_pickHandler
;
private:
};
...
...
src/graphicsEngine/WPickHandler.cpp
View file @
01cbcb29
...
...
@@ -27,8 +27,7 @@
#include "WPickHandler.h"
WPickHandler
::
WPickHandler
(
osgText
::
Text
*
updateText
)
:
m_updateText
(
updateText
)
WPickHandler
::
WPickHandler
()
{
}
...
...
@@ -36,14 +35,9 @@ WPickHandler::~WPickHandler()
{
}
void
WPickHandler
::
s
et
Label
(
const
std
::
string
&
name
)
std
::
string
WPickHandler
::
g
et
HitResult
(
)
{
//std::cout << name << std::endl;
if
(
m_updateText
.
get
()
)
{
m_updateText
->
setText
(
name
);
}
return
m_hitResult
;
}
bool
WPickHandler
::
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
)
...
...
@@ -81,37 +75,28 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
{
osgUtil
::
LineSegmentIntersector
::
Intersections
intersections
;
std
::
string
gdlis
t
=
""
;
m_hitResul
t
=
""
;
float
x
=
ea
.
getX
();
float
y
=
ea
.
getY
();
if
(
view
->
computeIntersections
(
x
,
y
,
intersections
)
)
{
for
(
osgUtil
::
LineSegmentIntersector
::
Intersections
::
iterator
hitr
=
intersections
.
begin
();
hitr
!=
intersections
.
end
();
++
hitr
)
osgUtil
::
LineSegmentIntersector
::
Intersections
::
iterator
hitr
=
intersections
.
begin
();
std
::
ostringstream
os
;
if
(
!
hitr
->
nodePath
.
empty
()
&&
!
(
hitr
->
nodePath
.
back
()
->
getName
().
empty
()
)
)
{
std
::
ostringstream
os
;
if
(
!
hitr
->
nodePath
.
empty
()
&&
!
(
hitr
->
nodePath
.
back
()
->
getName
().
empty
()
)
)
{
// the geodes are identified by name.
os
<<
"Object
\"
"
<<
hitr
->
nodePath
.
back
()
->
getName
()
<<
"
\"
"
<<
std
::
endl
;
}
else
if
(
hitr
->
drawable
.
valid
()
)
{
os
<<
"Object
\"
"
<<
hitr
->
drawable
->
className
()
<<
"
\"
"
<<
std
::
endl
;
}
os
<<
" local coords vertex("
<<
hitr
->
getLocalIntersectPoint
()
<<
")"
<<
" normal("
<<
hitr
->
getLocalIntersectNormal
()
<<
")"
<<
std
::
endl
;
os
<<
" world coords vertex("
<<
hitr
->
getWorldIntersectPoint
()
<<
")"
<<
" normal("
<<
hitr
->
getWorldIntersectNormal
()
<<
")"
<<
std
::
endl
;
const
osgUtil
::
LineSegmentIntersector
::
Intersection
::
IndexList
&
vil
=
hitr
->
indexList
;
for
(
unsigned
int
i
=
0
;
i
<
vil
.
size
();
++
i
)
{
os
<<
" vertex indices ["
<<
i
<<
"] = "
<<
vil
[
i
]
<<
std
::
endl
;
}
gdlist
+=
os
.
str
();
// the geodes are identified by name.
os
<<
"Object
\"
"
<<
hitr
->
nodePath
.
back
()
->
getName
()
<<
"
\"
"
<<
std
::
endl
;
}
else
if
(
hitr
->
drawable
.
valid
()
)
{
os
<<
"Object
\"
"
<<
hitr
->
drawable
->
className
()
<<
"
\"
"
<<
std
::
endl
;
}
os
<<
" local coords vertex("
<<
hitr
->
getLocalIntersectPoint
()
<<
")"
<<
" normal("
<<
hitr
->
getLocalIntersectNormal
()
<<
")"
<<
std
::
endl
;
os
<<
" world coords vertex("
<<
hitr
->
getWorldIntersectPoint
()
<<
")"
<<
" normal("
<<
hitr
->
getWorldIntersectNormal
()
<<
")"
<<
std
::
endl
;
m_hitResult
+=
os
.
str
();
}
setLabel
(
gdlist
);
}
src/graphicsEngine/WPickHandler.h
View file @
01cbcb29
...
...
@@ -52,7 +52,7 @@ class WPickHandler: public osgGA::GUIEventHandler
{
public:
explicit
WPickHandler
(
osgText
::
Text
*
updateText
);
WPickHandler
();
virtual
~
WPickHandler
();
...
...
@@ -60,11 +60,10 @@ public:
virtual
void
pick
(
osgViewer
::
View
*
view
,
const
osgGA
::
GUIEventAdapter
&
ea
);
void
setLabel
(
const
std
::
string
&
name
);
std
::
string
getHitResult
(
);
protected:
osg
::
ref_ptr
<
osgText
::
Text
>
m_updateText
;
std
::
string
m_hitResult
;
};
#endif // WPICKHANDLER_H
src/gui/WGUI.h
View file @
01cbcb29
...
...
@@ -29,11 +29,12 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include "boost/signals2/signal.hpp"
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.hpp"
#include "../kernel/WModule.h"
#include "qt4/signalslib.hpp"
/**
* \defgroup gui GUI
...
...
@@ -113,7 +114,10 @@ public:
/**
* getter functions for the signales proved by the gui
*/
virtual
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoadButtonSignal
()
=
0
;
virtual
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoadButtonSignal
()
=
0
;
virtual
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
()
=
0
;
/**
* this function allows modules to register their property object with the gui
...
...
src/gui/qt4/WMainWindow.cpp
View file @
01cbcb29
...
...
@@ -204,11 +204,16 @@ void WMainWindow::openLoadDialog()
m_loaderSignal
(
stdFileNames
);
}
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
WMainWindow
::
getLoaderSignal
()
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
WMainWindow
::
getLoaderSignal
()
{
return
&
m_loaderSignal
;
}
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
WMainWindow
::
getPickSignal
()
{
return
m_mainGLWidget
->
getPickSignal
();
}
WPropertyManager
*
WMainWindow
::
getPropertyManager
()
{
return
&
m_propertyManager
;
...
...
src/gui/qt4/WMainWindow.h
View file @
01cbcb29
...
...
@@ -31,6 +31,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/program_options.hpp>
#include "boost/signals2/signal.hpp"
#include <QtGui/QIcon>
#include <QtGui/QMainWindow>
...
...
@@ -38,7 +39,6 @@
#include <QtGui/QWidget>
#include <QtGui/QCloseEvent>
#include "signalslib.hpp"
#include "WQtNavGLWidget.h"
#include "ribbonMenu/WQtRibbonMenu.h"
...
...
@@ -94,7 +94,12 @@ public:
/**
*
*/
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoaderSignal
();
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoaderSignal
();
/**
*
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
();
protected:
...
...
@@ -128,7 +133,7 @@ private:
boost
::
shared_ptr
<
WQtNavGLWidget
>
m_navCoronal
;
boost
::
shared_ptr
<
WQtNavGLWidget
>
m_navSagittal
;
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>
m_loaderSignal
;
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>
m_loaderSignal
;
};
#endif // WMAINWINDOW_H
src/gui/qt4/WQt4Gui.cpp
View file @
01cbcb29
...
...
@@ -183,11 +183,17 @@ std::vector< boost::shared_ptr< WDataSet > > WQt4Gui::getDataSetList( int subjec
return
m_gui
->
getDatasetBrowser
()
->
getDataSetList
(
subjectId
,
onlyTextures
);
}
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
WQt4Gui
::
getLoadButtonSignal
()
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
WQt4Gui
::
getLoadButtonSignal
()
{
return
m_gui
->
getLoaderSignal
();
}
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
WQt4Gui
::
getPickSignal
()
{
return
m_gui
->
getPickSignal
();
}
void
WQt4Gui
::
connectProperties
(
boost
::
shared_ptr
<
WProperties
>
properties
)
{
m_gui
->
getPropertyManager
()
->
connectProperties
(
properties
);
...
...
src/gui/qt4/WQt4Gui.h
View file @
01cbcb29
...
...
@@ -92,7 +92,9 @@ public:
/**
* getter functions for the signales proved by the gui
*/
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoadButtonSignal
();
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoadButtonSignal
();
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
();
/**
* this function allows modules to register their property object with the gui
...
...
src/gui/qt4/WQtGLWidget.cpp
View file @
01cbcb29
...
...
@@ -220,6 +220,8 @@ void WQtGLWidget::keyReleaseEvent( QKeyEvent* event )
void
WQtGLWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{
m_Viewer
->
mouseEvent
(
WGEViewer
::
MOUSEPRESS
,
event
->
x
(),
event
->
y
(),
translateButton
(
event
)
);
std
::
cout
<<
m_Viewer
->
getPickHandler
()
->
getHitResult
()
<<
std
::
endl
;
m_pickSignal
(
m_Viewer
->
getPickHandler
()
->
getHitResult
()
);
}
void
WQtGLWidget
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
...
...
@@ -254,3 +256,7 @@ void WQtGLWidget::wheelEvent( QWheelEvent* event )
}
#endif
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
WQtGLWidget
::
getPickSignal
()
{
return
&
m_pickSignal
;
}
src/gui/qt4/WQtGLWidget.h
View file @
01cbcb29
...
...
@@ -31,6 +31,7 @@
#include <QtGui/QWidget>
#include <boost/shared_ptr.hpp>
#include "boost/signals2/signal.hpp"
#include "../../graphicsEngine/WGECamera.h"
#include "../../common/WFlag.hpp"
...
...
@@ -108,6 +109,8 @@ public:
*/
const
WBoolFlag
&
isInitialized
()
const
;
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
();
protected:
/**
* The viewer to the scene.
...
...
@@ -119,6 +122,7 @@ protected:
*/
std
::
string
m_nameOfViewer
;
// The GraphincsWindowWin32 implementation already takes care of message handling.
// We don't want to relay these on Windows, it will just cause duplicate messages
// with further problems downstream (i.e. not being able to throw the trackball
...
...
@@ -228,6 +232,8 @@ private:
* True when initialized.
*/
WBoolFlag
m_isInitialized
;
boost
::
signals2
::
signal1
<
void
,
std
::
string
>
m_pickSignal
;
};
#endif // WQTGLWIDGET_H
src/modules/hud/WMHud.cpp
View file @
01cbcb29
...
...
@@ -171,12 +171,32 @@ void WMHud::init()
// in numerical order so set bin number to 11
HUDStateSet
->
setRenderBinDetails
(
11
,
"RenderBin"
);
m_osgPickText
=
osg
::
ref_ptr
<
osgText
::
Text
>
(
new
osgText
::
Text
()
);
HUDGeode
->
addDrawable
(
m_osgPickText
);
m_osgPickText
->
setCharacterSize
(
20
);
//m_osgPickText->setFont("C:/WINDOWS/Fonts/impact.ttf");
m_osgPickText
->
setText
(
"nothing picked"
);
m_osgPickText
->
setAxisAlignment
(
osgText
::
Text
::
SCREEN
);
m_osgPickText
->
setPosition
(
osg
::
Vec3
(
620
,
80
,
-
1.5
)
);
m_osgPickText
->
setColor
(
osg
::
Vec4
(
0
,
0
,
0
,
1
)
);
m_rootNode
->
setUserData
(
this
);
m_rootNode
->
setUpdateCallback
(
new
HUDNodeCallback
);
WKernel
::
getRunningKernel
()
->
getGui
()
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMHud
::
updatePickText
,
this
,
_1
)
);
}
void
WMHud
::
updatePickText
(
std
::
string
text
)
{
m_pickText
=
text
;
std
::
cout
<<
text
<<
std
::
endl
;
}
void
WMHud
::
update
()
{
m_osgPickText
->
setText
(
m_pickText
.
c_str
()
);
}
void
WMHud
::
slotPropertyChanged
(
std
::
string
propertyName
)
...
...
src/modules/hud/WMHud.h
View file @
01cbcb29
...
...
@@ -70,6 +70,11 @@ public:
*/
void
connectToGui
();
/**
*
*/
void
updatePickText
(
std
::
string
text
);
protected:
/**
...
...
@@ -113,6 +118,12 @@ private:
osg
::
ref_ptr
<
osg
::
Group
>
m_HUDs
;
// Text instance that wil show up in the HUD:
osg
::
ref_ptr
<
osgText
::
Text
>
m_osgPickText
;
std
::
string
m_pickText
;
void
init
();
void
update
();
...
...
src/modules/navSlices/WMNavSlices.cpp
View file @
01cbcb29
...
...
@@ -145,8 +145,11 @@ void WMNavSlices::create()
m_rootNode
=
osg
::
ref_ptr
<
osg
::
Group
>
(
new
osg
::
Group
()
);
m_xSliceNode
=
osg
::
ref_ptr
<
osg
::
Geode
>
(
new
osg
::
Geode
()
);
m_xSliceNode
->
setName
(
"X-Slice"
);
m_ySliceNode
=
osg
::
ref_ptr
<
osg
::
Geode
>
(
new
osg
::
Geode
()
);
m_ySliceNode
->
setName
(
"Y-Slice"
);
m_zSliceNode
=
osg
::
ref_ptr
<
osg
::
Geode
>
(
new
osg
::
Geode
()
);
m_zSliceNode
->
setName
(
"Z-Slice"
);
m_xSliceNode
->
addDrawable
(
createGeometry
(
0
)
);
m_ySliceNode
->
addDrawable
(
createGeometry
(
1
)
);
...
...
@@ -167,37 +170,32 @@ void WMNavSlices::create()
osg
::
ref_ptr
<
osg
::
Geometry
>
WMNavSlices
::
createGeometry
(
int
slice
)
{
float
axialPos
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"axialPos"
)
)
+
0.5
f
;
float
coronalPos
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"coronalPos"
)
)
+
0.5
f
;
float
sagittalPos
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"sagittalPos"
)
)
+
0.5
f
;
float
maxDim
=
255.0
;
float
maxAxial
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"
maxAxial"
)
);
float
maxCoronal
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"
maxC
oronal
"
)
);
float
maxSagittal
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"
m
ax
Sagittal"
)
);
float
xSlice
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"
sagittalPos"
)
);
float
ySlice
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"
c
oronal
Pos"
)
);
float
zSlice
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"ax
ialPos"
)
);
m_properties
->
setMax
(
"axialPos"
,
maxAxial
);
m_properties
->
setMax
(
"coronalPos"
,
maxCoronal
);
m_properties
->
setMax
(
"sagittalPos"
,
maxSagittal
);
float
texAxial
=
axialPos
/
maxAxial
;
float
texCoronal
=
coronalPos
/
maxCoronal
;
float
texSagittal
=
sagittalPos
/
maxSagittal
;
float
xPos
=
xSlice
+
0.5
f
;
float
yPos
=
ySlice
+
0.5
f
;
float
zPos
=
zSlice
+
0.5
f
;
osg
::
ref_ptr
<
osg
::
Geometry
>
sliceGeometry
=
osg
::
ref_ptr
<
osg
::
Geometry
>
(
new
osg
::
Geometry
()
);
osg
::
Vec3Array
*
sliceVertices
=
new
osg
::
Vec3Array
;
std
::
vector
<
boost
::
shared_ptr
<
WDataSet
>
>
dsl
=
WKernel
::
getRunningKernel
()
->
getGui
()
->
getDataSetList
(
0
,
true
);
if
(
dsl
.
size
()
>
0
)
{
switch
(
slice
)
{
case
0
:
{
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
coronal
Pos
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
coronal
Pos
,
max
Sagittal
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Axial
,
coronalPos
,
maxSagittal
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Axial
,
coronal
Pos
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
y
Pos
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
y
Pos
,
max
Dim
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Dim
,
yPos
,
maxDim
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Dim
,
y
Pos
,
0
)
);
sliceGeometry
->
setVertexArray
(
sliceVertices
);
int
c
=
0
;
...
...
@@ -205,26 +203,35 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
{
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
boost
::
shared_dynamic_cast
<
WDataSetSingle
>
(
dsl
[
i
]
)
->
getGrid
()
);
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
texCoronal
,
0.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
texCoronal
,
1.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
1.0
,
texCoronal
,
1.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
1.0
,
texCoronal
,
0.0
)
)
);
sliceGeometry
->
setTexCoordArray
(
c
,
texCoords
);
++
c
;
}
float
maxX
=
(
float
)(
grid
->
getNbCoordsX
()
);
float
maxY
=
(
float
)(
grid
->
getNbCoordsY
()
);
float
maxZ
=
(
float
)(
grid
->
getNbCoordsZ
()
);
float
texX
=
xSlice
/
maxX
;
float
texY
=
ySlice
/
maxY
;
float
texZ
=
zSlice
/
maxZ
;
float
texXOff
=
255.0
/
maxX
;
float
texYOff
=
255.0
/
maxY
;
float
texZOff
=
255.0
/
maxZ
;
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
texY
,
0.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
texY
,
texZOff
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
texXOff
,
texY
,
texZOff
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
texXOff
,
texY
,
0.0
)
)
);
sliceGeometry
->
setTexCoordArray
(
c
,
texCoords
);
++
c
;
}
break
;
}
case
1
:
{
sliceVertices
->
push_back
(
osg
::
Vec3
(
sagittalPos
,
0
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
sagittalPos
,
0
,
maxSagittal
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
sagittalPos
,
maxCoronal
,
maxSagittal
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
sagittalPos
,
maxCoronal
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
xPos
,
0
,
0
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
xPos
,
0
,
maxDim
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
xPos
,
maxDim
,
maxDim
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
xPos
,
maxDim
,
0
)
);
sliceGeometry
->
setVertexArray
(
sliceVertices
);
int
c
=
0
;
...
...
@@ -232,11 +239,24 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
{
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
boost
::
shared_dynamic_cast
<
WDataSetSingle
>
(
dsl
[
i
]
)
->
getGrid
()
);
float
maxX
=
(
float
)(
grid
->
getNbCoordsX
()
);
float
maxY
=
(
float
)(
grid
->
getNbCoordsY
()
);
float
maxZ
=
(
float
)(
grid
->
getNbCoordsZ
()
);
float
texX
=
xSlice
/
maxX
;
float
texY
=
ySlice
/
maxY
;
float
texZ
=
zSlice
/
maxZ
;
float
texXOff
=
255.0
/
maxX
;
float
texYOff
=
255.0
/
maxY
;
float
texZOff
=
255.0
/
maxZ
;
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
Sagittal
,
0.0
,
0.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
Sagittal
,
0.0
,
1.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
Sagittal
,
1.0
,
1.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
Sagittal
,
1.0
,
0.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
X
,
0.0
,
0.0
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
X
,
0.0
,
texZOff
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
X
,
texYOff
,
texZOff
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
tex
X
,
texYOff
,
0.0
)
)
);
sliceGeometry
->
setTexCoordArray
(
c
,
texCoords
);
++
c
;
}
...
...
@@ -244,22 +264,35 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
}
case
2
:
{
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
0
,
axial
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
maxCoronal
,
axial
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Axial
,
maxCoronal
,
axial
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Axial
,
0
,
axial
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
0
,
z
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
0
,
maxDim
,
z
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Dim
,
maxDim
,
z
Pos
)
);
sliceVertices
->
push_back
(
osg
::
Vec3
(
max
Dim
,
0
,
z
Pos
)
);
sliceGeometry
->
setVertexArray
(
sliceVertices
);
int
c
=
0
;
for
(
size_t
i
=
0
;
i
<
dsl
.
size
();
++
i
)
{
boost
::
shared_ptr
<
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
boost
::
shared_dynamic_cast
<
WDataSetSingle
>
(
dsl
[
i
]
)
->
getGrid
()
);
float
maxX
=
(
float
)(
grid
->
getNbCoordsX
()
);
float
maxY
=
(
float
)(
grid
->
getNbCoordsY
()
);
float
maxZ
=
(
float
)(
grid
->
getNbCoordsZ
()
);
float
texX
=
xSlice
/
maxX
;
float
texY
=
ySlice
/
maxY
;
float
texZ
=
zSlice
/
maxZ
;
float
texXOff
=
255.0
/
maxX
;
float
texYOff
=
255.0
/
maxY
;
float
texZOff
=
255.0
/
maxZ
;
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
0.0
,
texAxial
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
1.0
,
texAxial
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
1.0
,
1.0
,
texAxial
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
1.0
,
0.0
,
texAxial
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
0.0
,
texZ
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
0.0
,
texYOff
,
texZ
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
texXOff
,
texYOff
,
texZ
)
)
);
texCoords
->
push_back
(
grid
->
transformTexCoord
(
osg
::
Vec3
(
texXOff
,
0.0
,
texZ
)
)
);
sliceGeometry
->
setTexCoordArray
(
c
,
texCoords
);
++
c
;
}
...
...
@@ -269,43 +302,59 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
}
else
{
float
maxX
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"maxSagittal"
)
);
float
maxY
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"maxCoronal"
)
);
float
maxZ
=
(
float
)(
m_properties
->
getValue
<
int
>
(
"maxAxial"
)
);
m_properties
->
setMax
(
"sagittalPos"
,
maxX
);
m_properties
->
setMax
(
"coronalPos"
,
maxY
);
m_properties
->
setMax
(
"axialPos"
,
maxZ
);
float
texX
=
xSlice
/
maxX
;
float
texY
=
ySlice
/
maxY
;
float
texZ
=
zSlice
/
maxZ
;
float
texXOff
=
255.0
/
maxX
;
float
texYOff
=
255.0
/
maxY
;
float
texZOff
=
255.0
/
maxZ
;
osg
::
Vec3Array
*
texCoords
=
new
osg
::
Vec3Array
;
switch
(
slice
)