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
e5df103a
Commit
e5df103a
authored
Feb 11, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - texture changes now get properly propagated to the nav slices
parent
312af7d3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
23 deletions
+109
-23
src/dataHandler/WDataTexture3D.cpp
src/dataHandler/WDataTexture3D.cpp
+21
-1
src/dataHandler/WDataTexture3D.h
src/dataHandler/WDataTexture3D.h
+27
-1
src/dataHandler/WSubject.cpp
src/dataHandler/WSubject.cpp
+24
-1
src/dataHandler/WSubject.h
src/dataHandler/WSubject.h
+9
-0
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
+0
-4
src/kernel/WModuleFactory.cpp
src/kernel/WModuleFactory.cpp
+0
-2
src/modules/data/WMData.cpp
src/modules/data/WMData.cpp
+7
-0
src/modules/navSlices/WMNavSlices.cpp
src/modules/navSlices/WMNavSlices.cpp
+21
-14
No files found.
src/dataHandler/WDataTexture3D.cpp
View file @
e5df103a
...
...
@@ -36,7 +36,8 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr<WValueSetBase> valueSet, boost
m_texture
(
osg
::
ref_ptr
<
osg
::
Texture3D
>
()
),
m_valueSet
(
valueSet
),
m_grid
(
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
grid
)
),
m_changeCondition
(
new
WCondition
()
)
m_changeCondition
(
new
WCondition
()
),
m_globalActive
(
true
)
{
// initialize members
}
...
...
@@ -79,6 +80,20 @@ void WDataTexture3D::setThreshold( float threshold )
notifyChange
();
}
bool
WDataTexture3D
::
isGloballyActive
()
{
return
m_globalActive
;
}
void
WDataTexture3D
::
setGloballyActive
(
bool
active
)
{
if
(
active
!=
m_globalActive
)
{
m_globalActive
=
active
;
notifyChange
();
}
}
osg
::
ref_ptr
<
osg
::
Texture3D
>
WDataTexture3D
::
getTexture
()
{
if
(
!
m_texture
)
...
...
@@ -241,6 +256,11 @@ void WDataTexture3D::createTexture()
}
}
dataType
WDataTexture3D
::
getDataType
()
{
return
m_valueSet
->
getDataType
();
}
boost
::
shared_ptr
<
WCondition
>
WDataTexture3D
::
getChangeCondition
()
{
return
m_changeCondition
;
...
...
src/dataHandler/WDataTexture3D.h
View file @
e5df103a
...
...
@@ -31,7 +31,7 @@
#include <osg/Texture3D>
#include "WDataHandlerEnums.h"
#include "WValueSetBase.h"
#include "WGridRegular3D.h"
...
...
@@ -92,6 +92,27 @@ public:
*/
void
setThreshold
(
float
threshold
);
/**
* Is this texture globally active and used for colormapping?
*
* \return true if active.
*/
bool
isGloballyActive
();
/**
* Sets whether the texture is active globally.
*
* \param active true if active
*/
void
setGloballyActive
(
bool
active
=
true
);
/**
* Returns the data type of the texture.
*
* \return the type.
*/
dataType
getDataType
();
/**
* getter for the texture object
*
...
...
@@ -181,6 +202,11 @@ protected:
*/
boost
::
shared_ptr
<
WCondition
>
m_changeCondition
;
/**
* Flag denotes whether this texture should be used by surfaces/slides for surface colormapping.
*/
bool
m_globalActive
;
private:
};
...
...
src/dataHandler/WSubject.cpp
View file @
e5df103a
...
...
@@ -29,6 +29,7 @@
#include "../common/WLogger.h"
#include "WDataSet.h"
#include "WDataTexture3D.h"
#include "exceptions/WDHNoSuchDataSet.h"
#include "WSubject.h"
...
...
@@ -71,6 +72,7 @@ void WSubject::addDataSet( boost::shared_ptr< WDataSet > dataset )
// also register condition
m_changeCondition
->
add
(
dataset
->
getChangeCondition
()
);
m_changeCondition
->
notify
();
}
void
WSubject
::
removeDataSet
(
boost
::
shared_ptr
<
WDataSet
>
dataset
)
...
...
@@ -82,8 +84,9 @@ void WSubject::removeDataSet( boost::shared_ptr< WDataSet > dataset )
// also deregister condition
m_changeCondition
->
remove
(
dataset
->
getChangeCondition
()
);
m_datasetAccess
->
endWrite
();
m_changeCondition
->
notify
();
}
void
WSubject
::
clear
()
...
...
@@ -121,6 +124,26 @@ boost::shared_ptr< WDataSet > WSubject::getDataSetByID( size_t datasetID )
return
result
;
}
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
WSubject
::
getDataTextures
()
{
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
tex
;
// iterate the list and find all textures
m_datasetAccess
->
beginRead
();
for
(
DatasetContainerType
::
iterator
iter
=
m_datasetAccess
->
get
().
begin
();
iter
!=
m_datasetAccess
->
get
().
end
();
++
iter
)
{
// is it a texture?
if
(
(
*
iter
)
->
isTexture
()
)
{
tex
.
push_back
(
(
*
iter
)
->
getTexture
()
);
}
}
m_datasetAccess
->
endRead
();
return
tex
;
}
WSubject
::
DatasetSharedContainerType
::
WSharedAccess
WSubject
::
getAccessObject
()
{
return
m_datasets
.
getAccessObject
();
...
...
src/dataHandler/WSubject.h
View file @
e5df103a
...
...
@@ -27,6 +27,7 @@
#include <string>
#include <vector>
#include <set>
#include <boost/shared_ptr.hpp>
#include "../common/WConditionSet.h"
...
...
@@ -36,6 +37,7 @@
#include "WPersonalInformation.h"
class
WDataSet
;
class
WDataTexture3D
;
/**
* Container for all WDataSets belonging to one subject or patient.
...
...
@@ -130,6 +132,13 @@ public:
*/
boost
::
shared_ptr
<
WDataSet
>
getDataSetByID
(
size_t
datasetID
);
/**
* This gives a list of data textures from all supporting datasets in this subject.
*
* \return the list of textures.
*/
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
getDataTextures
();
/**
* Gets an access object which allows thread save iteration over the datasets.
*
...
...
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
View file @
e5df103a
...
...
@@ -199,7 +199,6 @@ bool WQtDatasetBrowser::event( QEvent* event )
// if the type number is 1 (dataset item) emit change event
if
(
item
->
type
()
==
1
)
{
emit
dataSetBrowserEvent
(
QString
(
"textureChanged"
),
true
);
emit
dataSetBrowserEvent
(
QString
(
"dataSetAdded"
),
true
);
}
}
...
...
@@ -419,7 +418,6 @@ void WQtDatasetBrowser::changeTreeItem()
{
boost
::
shared_ptr
<
WModule
>
module
=
(
static_cast
<
WQtDatasetTreeItem
*
>
(
m_treeWidget
->
selectedItems
().
at
(
0
)
)
)
->
getModule
();
module
->
getProperties2
()
->
getProperty
(
"active"
)
->
toPropBool
()
->
set
(
m_treeWidget
->
selectedItems
().
at
(
0
)
->
checkState
(
0
)
);
emit
dataSetBrowserEvent
(
QString
(
"textureChanged"
),
true
);
}
else
if
(
m_treeWidget
->
selectedItems
().
size
()
==
1
&&
m_treeWidget
->
selectedItems
().
at
(
0
)
->
type
()
==
MODULE
)
{
...
...
@@ -468,13 +466,11 @@ std::vector< boost::shared_ptr< WDataSet > > WQtDatasetBrowser::getDataSetList(
void
WQtDatasetBrowser
::
moveTreeItemDown
()
{
m_treeWidget
->
moveTreeItemDown
();
emit
dataSetBrowserEvent
(
QString
(
"textureChanged"
),
true
);
}
void
WQtDatasetBrowser
::
moveTreeItemUp
()
{
m_treeWidget
->
moveTreeItemUp
();
emit
dataSetBrowserEvent
(
QString
(
"textureChanged"
),
true
);
}
int
WQtDatasetBrowser
::
getFirstSubject
()
...
...
src/kernel/WModuleFactory.cpp
View file @
e5df103a
...
...
@@ -44,7 +44,6 @@
#include "../modules/directVolumeRendering/WMDirectVolumeRendering.h"
#include "../modules/navSlices/WMNavSlices.h"
#include "../modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.h"
#include "../modules/textureList/WMTextureList.h"
#include "../modules/voxelizer/WMVoxelizer.h"
#include "../modules/writeNIfTI/WMWriteNIfTI.h"
#include "WModuleFactory.h"
...
...
@@ -83,7 +82,6 @@ void WModuleFactory::load()
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMMarchingCubes
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMDistanceMapIsosurface
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMDistanceMap
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMTextureList
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMGaussFiltering
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMHud
()
)
);
m_prototypes
.
insert
(
boost
::
shared_ptr
<
WModule
>
(
new
WMEEGView
()
)
);
...
...
src/modules/data/WMData.cpp
View file @
e5df103a
...
...
@@ -119,6 +119,10 @@ void WMData::propertyChanged( boost::shared_ptr< WPropertyBase > property )
{
m_dataSet
->
getTexture
()
->
setOpacity
(
m_opacity
->
get
()
);
}
else
if
(
property
==
m_active
)
{
m_dataSet
->
getTexture
()
->
setGloballyActive
(
m_active
->
get
()
);
}
}
void
WMData
::
notifyConnectionEstablished
(
boost
::
shared_ptr
<
WModuleConnector
>
here
,
...
...
@@ -197,6 +201,9 @@ void WMData::moduleMain()
debugLog
()
<<
"Loading data done."
;
// i am interested in the active property ( manually subscribe signal )
m_active
->
getCondition
()
->
subscribeSignal
(
boost
::
bind
(
&
WMData
::
propertyChanged
,
this
,
m_active
)
);
// register at datahandler
WDataHandler
::
registerDataSet
(
m_dataSet
);
...
...
src/modules/navSlices/WMNavSlices.cpp
View file @
e5df103a
...
...
@@ -451,37 +451,44 @@ void WMNavSlices::updateTextures()
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
;
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_updateLock
);
/*
if ( m_textureChanged
&& WKernel::getRunningKernel()->getGui()->isInitialized()()
)
if
(
m_textureChanged
)
{
m_textureChanged
=
false
;
std::vector< boost::shared_ptr< WDataSet > > dsl = WKernel::getRunningKernel()->getGui()->getDataSetList( 0, true );
if ( dsl.size() > 0 )
// grab a list of data textures
std
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>
tex
=
WDataHandler
::
getDefaultSubject
()
->
getDataTextures
();
if
(
tex
.
size
()
>
0
)
{
// reset all uniforms
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
m_typeUniforms
[
i
]
->
set
(
0
);
}
// for each texture -> apply
osg
::
StateSet
*
rootState
=
m_rootNode
->
getOrCreateStateSet
();
int
c
=
0
;
for ( s
ize_t i = 0; i < dsl.size
(); ++i )
for
(
s
td
::
vector
<
boost
::
shared_ptr
<
WDataTexture3D
>
>::
const_iterator
iter
=
tex
.
begin
();
iter
!=
tex
.
end
();
++
i
ter
)
{
osg::ref_ptr<osg::Texture3D> texture3D = dsl[i]->getTexture()->getTexture();
rootState->setTextureAttributeAndModes( c, texture3D, osg::StateAttribute::ON );
if
(
(
*
iter
)
->
isGloballyActive
()
)
{
osg
::
ref_ptr
<
osg
::
Texture3D
>
texture3D
=
(
*
iter
)
->
getTexture
();
rootState
->
setTextureAttributeAndModes
(
c
,
texture3D
,
osg
::
StateAttribute
::
ON
);
float t = dsl[i]->getTexture()->getThreshold() / 255.0;
float a = dsl[i]->getTexture()->getAlpha();
// set threshold/opacity as uniforms
float
t
=
(
*
iter
)
->
getThreshold
()
/
255.0
;
float
a
=
(
*
iter
)
->
getAlpha
();
m_typeUniforms[c]->set(
boost::shared_dynamic_cast<WDataSetSingle>( dsl[i] )->getValueSet(
)->getDataType() );
m_thresholdUniforms[c]->set( t );
m_alphaUniforms[c]->set( a );
m_typeUniforms
[
c
]
->
set
(
(
*
iter
)
->
getDataType
()
);
m_thresholdUniforms
[
c
]
->
set
(
t
);
m_alphaUniforms
[
c
]
->
set
(
a
);
++c;
++
c
;
}
}
}
}
*/
}
slock
.
unlock
();
}
...
...
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