Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
057cc514
Commit
057cc514
authored
Oct 05, 2010
by
schurade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] custom coloring of fiber bundles should work again
parent
291e3a2b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
158 additions
and
31 deletions
+158
-31
src/dataHandler/WDataSetFibers.cpp
src/dataHandler/WDataSetFibers.cpp
+17
-6
src/kernel/WRMBranch.cpp
src/kernel/WRMBranch.cpp
+22
-0
src/kernel/WRMBranch.h
src/kernel/WRMBranch.h
+18
-0
src/modules/fiberDisplay/WFiberDrawable.cpp
src/modules/fiberDisplay/WFiberDrawable.cpp
+17
-20
src/modules/fiberDisplay/WFiberDrawable.h
src/modules/fiberDisplay/WFiberDrawable.h
+7
-0
src/modules/fiberDisplay/WFiberSelector.cpp
src/modules/fiberDisplay/WFiberSelector.cpp
+7
-1
src/modules/fiberDisplay/WFiberSelector.h
src/modules/fiberDisplay/WFiberSelector.h
+13
-0
src/modules/fiberDisplay/WSelectorBranch.cpp
src/modules/fiberDisplay/WSelectorBranch.cpp
+35
-2
src/modules/fiberDisplay/WSelectorBranch.h
src/modules/fiberDisplay/WSelectorBranch.h
+22
-2
No files found.
src/dataHandler/WDataSetFibers.cpp
View file @
057cc514
...
...
@@ -63,12 +63,13 @@ WDataSetFibers::WDataSetFibers( WDataSetFibers::VertexArray vertices,
m_bbMax
(
boundingBox
.
second
)
{
m_tangents
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
()
);
m_tangents
->
resize
(
m_vertices
->
size
()
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
globalColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
()
);
globalColors
->
resize
(
m_vertices
->
size
()
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
localColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
()
);
localColors
->
resize
(
m_vertices
->
size
()
);
size_t
size
=
m_vertices
->
size
();
m_tangents
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
(
size
)
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
globalColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
(
size
)
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
localColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
(
size
)
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
customColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
(
size
)
);
// TODO(all): use the new WThreadedJobs functionality
WCreateColorArraysThread
*
t1
=
new
WCreateColorArraysThread
(
0
,
m_lineLengths
->
size
()
/
4
,
m_vertices
,
...
...
@@ -105,6 +106,16 @@ WDataSetFibers::WDataSetFibers( WDataSetFibers::VertexArray vertices,
)
);
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
(
*
customColors
)[
i
]
=
(
*
globalColors
)[
i
];
}
m_colors
->
push_back
(
boost
::
shared_ptr
<
WItemSelectionItem
>
(
new
ColorScheme
(
"Custom Color"
,
"Colors copied from the global colors, will be used for bundle coloring."
,
NULL
,
customColors
,
ColorScheme
::
RGB
)
)
);
// the colors can be selected by properties
m_colorProp
=
m_properties
->
addProperty
(
"Color Scheme"
,
"Determines the coloring scheme to use for this data."
,
m_colors
->
getSelectorFirst
()
);
WPropertyHelper
::
PC_SELECTONLYONE
::
addTo
(
m_colorProp
);
...
...
src/kernel/WRMBranch.cpp
View file @
057cc514
...
...
@@ -25,6 +25,8 @@
#include <list>
#include <vector>
#include "../graphicsEngine/WGraphicsEngine.h"
#include "WROIManager.h"
#include "WRMBranch.h"
...
...
@@ -44,6 +46,7 @@ void WRMBranch::properties()
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
(
"Properties"
,
"This branch's properties"
)
);
m_dirty
=
m_properties
->
addProperty
(
"Dirty"
,
""
,
true
,
boost
::
bind
(
&
WRMBranch
::
propertyChanged
,
this
)
);
m_dirty
->
setHidden
(
true
);
m_isNot
=
m_properties
->
addProperty
(
"NOT"
,
"description"
,
false
,
boost
::
bind
(
&
WRMBranch
::
propertyChanged
,
this
)
);
m_bundleColor
=
m_properties
->
addProperty
(
"Bundle Color"
,
"description"
,
WColor
(
1.0
,
0.0
,
0.0
,
1.0
),
boost
::
bind
(
&
WRMBranch
::
propertyChanged
,
this
)
);
...
...
@@ -96,6 +99,11 @@ void WRMBranch::getRois( std::vector< osg::ref_ptr< WROI > >& roiVec ) // NOLINT
void
WRMBranch
::
removeAllRois
()
{
for
(
std
::
list
<
osg
::
ref_ptr
<
WROI
>
>::
iterator
iter
=
m_rois
.
begin
();
iter
!=
m_rois
.
end
();
++
iter
)
{
WGraphicsEngine
::
getGraphicsEngine
()
->
getScene
()
->
remove
(
(
*
iter
)
);
}
m_rois
.
clear
();
}
...
...
@@ -103,6 +111,12 @@ void WRMBranch::setDirty()
{
m_dirty
->
set
(
true
);
m_roiManager
->
setDirty
();
for
(
std
::
list
<
boost
::
function
<
void
()
>
>::
iterator
iter
=
m_changeNotifiers
.
begin
();
iter
!=
m_changeNotifiers
.
end
();
++
iter
)
{
(
*
iter
)();
}
}
osg
::
ref_ptr
<
WROI
>
WRMBranch
::
getFirstRoi
()
...
...
@@ -119,3 +133,11 @@ boost::shared_ptr< WProperties > WRMBranch::getProperties()
{
return
m_properties
;
}
void
WRMBranch
::
addChangeNotifier
(
boost
::
function
<
void
()
>
notifier
)
{
boost
::
unique_lock
<
boost
::
shared_mutex
>
lock
;
lock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_associatedNotifiersLock
);
m_changeNotifiers
.
push_back
(
notifier
);
lock
.
unlock
();
}
src/kernel/WRMBranch.h
View file @
057cc514
...
...
@@ -132,6 +132,14 @@ public:
*/
void
getRois
(
std
::
vector
<
osg
::
ref_ptr
<
WROI
>
>&
roiVec
);
//NOLINT
/**
* Add a specified notifier to the list of default notifiers which get connected to each branch
*
* \param notifier the notifier function
*/
void
addChangeNotifier
(
boost
::
function
<
void
()
>
notifier
);
protected:
/**
* initializes properties
...
...
@@ -164,6 +172,16 @@ private:
* The color used when in isosurface mode for blending.
*/
WPropColor
m_bundleColor
;
/**
* The notifiers connected to added rois by default.
*/
std
::
list
<
boost
::
function
<
void
()
>
>
m_changeNotifiers
;
/**
* Lock for associated notifiers set.
*/
boost
::
shared_mutex
m_associatedNotifiersLock
;
};
inline
bool
WRMBranch
::
empty
()
...
...
src/modules/fiberDisplay/WFiberDrawable.cpp
View file @
057cc514
...
...
@@ -92,16 +92,14 @@ void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
;
// TODO(schurade): roi refactoring
// if ( m_customColoring )
// {
// colors = WKernel::getRunningKernel()->getRoiManager()->getCustomColors();
// }
// else
// {
// colors = ( m_globalColoring ? m_dataset->getGlobalColors() : m_dataset->getLocalColors() );
// }
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
if
(
m_customColoring
)
{
colors
=
colors
=
m_dataset
->
getColorScheme
(
"Custom Color"
)
->
getColor
();
}
else
{
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
}
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
m_fiberSelector
->
getBitfield
();
...
...
@@ -131,16 +129,15 @@ void WFiberDrawable::drawTubes() const
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
tangents
=
m_dataset
->
getTangents
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
;
// TODO(schurade): roi refactoring
// if ( m_customColoring )
// {
// colors = WKernel::getRunningKernel()->getRoiManager()->getCustomColors();
// }
// else
// {
//
// }
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
if
(
m_customColoring
)
{
colors
=
m_dataset
->
getColorScheme
(
"Custom Color"
)
->
getColor
();
}
else
{
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
}
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
m_fiberSelector
->
getBitfield
();
...
...
src/modules/fiberDisplay/WFiberDrawable.h
View file @
057cc514
...
...
@@ -146,6 +146,12 @@ public:
*/
void
setSelector
(
boost
::
shared_ptr
<
WFiberSelector
>
selector
);
/**
* setter
* \param colors
*/
void
setCustomColors
(
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
);
protected:
private:
/**
...
...
@@ -170,6 +176,7 @@ private:
bool
m_customColoring
;
//!< True indicates use of custom colors
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
m_active
;
//!< pointer to the bitfield of active fibers
boost
::
shared_ptr
<
WFiberSelector
>
m_fiberSelector
;
//!< the selector object which provides the bitfield for fiber selection
...
...
src/modules/fiberDisplay/WFiberSelector.cpp
View file @
057cc514
...
...
@@ -75,7 +75,8 @@ void WFiberSelector::slotAddRoi( osg::ref_ptr< WROI > roi )
}
if
(
!
(
branch
.
get
()
)
)
{
branch
=
boost
::
shared_ptr
<
WSelectorBranch
>
(
new
WSelectorBranch
(
m_size
,
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBranch
(
roi
)
)
);
branch
=
boost
::
shared_ptr
<
WSelectorBranch
>
(
new
WSelectorBranch
(
m_fibers
,
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBranch
(
roi
)
)
);
m_branches
.
push_back
(
branch
);
}
...
...
@@ -119,6 +120,11 @@ void WFiberSelector::slotRemoveBranch( boost::shared_ptr< WRMBranch > branch )
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
WFiberSelector
::
getBitfield
()
{
for
(
std
::
list
<
boost
::
shared_ptr
<
WSelectorBranch
>
>::
iterator
iter
=
m_branches
.
begin
();
iter
!=
m_branches
.
end
();
++
iter
)
{
m_dirty
=
std
::
max
(
m_dirty
,
(
*
iter
)
->
dirty
()
);
}
if
(
m_dirty
)
{
recalculate
();
...
...
src/modules/fiberDisplay/WFiberSelector.h
View file @
057cc514
...
...
@@ -102,6 +102,19 @@ protected:
*/
void
slotRemoveBranch
(
boost
::
shared_ptr
<
WRMBranch
>
branch
);
/**
* setter
* \param colors
*/
void
setCustomColors
(
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
);
/**
* getter
* \return colors
*/
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
getCustomColors
();
private:
/**
...
...
src/modules/fiberDisplay/WSelectorBranch.cpp
View file @
057cc514
...
...
@@ -24,12 +24,16 @@
#include "WSelectorBranch.h"
WSelectorBranch
::
WSelectorBranch
(
size_t
size
,
boost
::
shared_ptr
<
WRMBranch
>
branch
)
:
m_size
(
size
),
WSelectorBranch
::
WSelectorBranch
(
boost
::
shared_ptr
<
const
WDataSetFibers
>
fibers
,
boost
::
shared_ptr
<
WRMBranch
>
branch
)
:
m_fibers
(
fibers
),
m_size
(
fibers
->
size
()
),
m_dirty
(
true
),
m_branch
(
branch
)
{
m_bitField
=
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
(
new
std
::
vector
<
bool
>
(
m_size
,
false
)
);
boost
::
function
<
void
()
>
changeSignal
=
boost
::
bind
(
&
WSelectorBranch
::
setDirty
,
this
);
m_branch
->
addChangeNotifier
(
changeSignal
);
}
WSelectorBranch
::~
WSelectorBranch
()
...
...
@@ -47,6 +51,11 @@ void WSelectorBranch::addRoi( boost::shared_ptr< WSelectorRoi> roi )
void
WSelectorBranch
::
setDirty
()
{
m_dirty
=
true
;
if
(
m_branch
->
getProperties
()
->
getProperty
(
"Bundle Color"
)
->
toPropColor
()
->
changed
()
)
{
colorChanged
();
}
}
void
WSelectorBranch
::
removeRoi
(
osg
::
ref_ptr
<
WROI
>
roi
)
...
...
@@ -115,3 +124,27 @@ void WSelectorBranch::recalculate()
m_bitField
=
m_workerBitfield
;
}
void
WSelectorBranch
::
colorChanged
()
{
WColor
color
=
m_branch
->
getProperties
()
->
getProperty
(
"Bundle Color"
)
->
toPropColor
()
->
get
(
true
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
array
=
m_fibers
->
getColorScheme
(
"Custom Color"
)
->
getColor
();
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
startIndexes
=
m_fibers
->
getLineStartIndexes
();
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
pointsPerLine
=
m_fibers
->
getLineLengths
();
for
(
size_t
i
=
0
;
i
<
m_size
;
++
i
)
{
if
(
(
*
m_bitField
)[
i
]
)
{
size_t
idx
=
(
*
startIndexes
)[
i
]
*
3
;
for
(
size_t
k
=
0
;
k
<
(
*
pointsPerLine
)[
i
];
++
k
)
{
(
*
array
)[
idx
++
]
=
color
.
getRed
();
(
*
array
)[
idx
++
]
=
color
.
getGreen
();
(
*
array
)[
idx
++
]
=
color
.
getBlue
();
}
}
}
}
src/modules/fiberDisplay/WSelectorBranch.h
View file @
057cc514
...
...
@@ -39,10 +39,10 @@ class WSelectorBranch
public:
/**
* constructor
* \param
size number of fibers int he dataset
* \param
fibers pointer to the fiber dataset to work on
* \param branch pointer to the branch object in the roi manager
*/
WSelectorBranch
(
size_t
size
,
boost
::
shared_ptr
<
WRMBranch
>
branch
);
WSelectorBranch
(
boost
::
shared_ptr
<
const
WDataSetFibers
>
fibers
,
boost
::
shared_ptr
<
WRMBranch
>
branch
);
/**
* destructor
...
...
@@ -85,13 +85,28 @@ public:
*/
void
setDirty
();
/**
* getter
*/
bool
dirty
();
protected:
/**
* function gets called when the color property of the roi branch has changed, it will write this color
* into the custom color array of the fiber dataset
*/
void
colorChanged
();
private:
/**
* updates the output bitfield with the information from all rois in this branch
*/
void
recalculate
();
/**
* Pointer to the fiber data set
*/
boost
::
shared_ptr
<
const
WDataSetFibers
>
m_fibers
;
/**
* size of the fiber dataset, stored for convinience
*/
...
...
@@ -139,4 +154,9 @@ inline bool WSelectorBranch::empty()
return
m_rois
.
empty
();
}
inline
bool
WSelectorBranch
::
dirty
()
{
return
m_dirty
;
}
#endif // WSELECTORBRANCH_H
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