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
de9e2bbc
Commit
de9e2bbc
authored
Mar 17, 2010
by
schurade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] coloring of fiber bundles
parent
85f7a978
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
6 deletions
+119
-6
src/modules/fiberDisplay/WMFiberDisplay.cpp
src/modules/fiberDisplay/WMFiberDisplay.cpp
+5
-3
src/modules/fiberDisplay/WMFiberDisplay.h
src/modules/fiberDisplay/WMFiberDisplay.h
+1
-0
src/modules/fiberDisplay/WRMBranch.cpp
src/modules/fiberDisplay/WRMBranch.cpp
+6
-0
src/modules/fiberDisplay/WRMBranch.h
src/modules/fiberDisplay/WRMBranch.h
+12
-0
src/modules/fiberDisplay/WROIManagerFibers.cpp
src/modules/fiberDisplay/WROIManagerFibers.cpp
+37
-0
src/modules/fiberDisplay/WROIManagerFibers.h
src/modules/fiberDisplay/WROIManagerFibers.h
+20
-0
src/modules/fiberDisplay/WTubeDrawable.cpp
src/modules/fiberDisplay/WTubeDrawable.cpp
+29
-3
src/modules/fiberDisplay/WTubeDrawable.h
src/modules/fiberDisplay/WTubeDrawable.h
+9
-0
No files found.
src/modules/fiberDisplay/WMFiberDisplay.cpp
View file @
de9e2bbc
...
...
@@ -197,8 +197,10 @@ void WMFiberDisplay::activate()
void
WMFiberDisplay
::
properties
()
{
m_
useTubesProp
=
m_properties2
->
addProperty
(
"Use Tubes"
,
"Draw fiber tracts as fake tubes
."
,
false
);
m_
customColoring
=
m_properties2
->
addProperty
(
"Custom coloring"
,
"Switches the coloring between custom and predefined
."
,
false
);
m_coloring
=
m_properties2
->
addProperty
(
"Global/Local coloring"
,
"Switches the coloring between global and local."
,
true
);
m_useTubesProp
=
m_properties2
->
addProperty
(
"Use Tubes"
,
"Draw fiber tracts as fake tubes."
,
false
);
m_tubeThickness
=
m_properties2
->
addProperty
(
"Tube thickness"
,
"Adjusts the thickness of tubes"
,
50.
,
boost
::
bind
(
&
WMFiberDisplay
::
adjustTubes
,
this
)
);
m_tubeThickness
->
setMin
(
0
);
...
...
@@ -232,10 +234,10 @@ void WMFiberDisplay::toggleTubes()
void
WMFiberDisplay
::
toggleColoring
()
{
if
(
m_coloring
->
changed
()
)
if
(
m_coloring
->
changed
()
||
m_customColoring
->
changed
()
)
{
m_tubeDrawable
->
setColoringMode
(
m_coloring
->
get
(
true
)
);
m_tubeDrawable
->
dirtyDisplayList
(
);
m_tubeDrawable
->
setCustomColoring
(
m_customColoring
->
get
(
true
)
);
}
}
...
...
src/modules/fiberDisplay/WMFiberDisplay.h
View file @
de9e2bbc
...
...
@@ -115,6 +115,7 @@ protected:
private:
WPropBool
m_coloring
;
//!< Enable/Disable global (true) or local (false) coloring of the fiber tracts
WPropBool
m_customColoring
;
//!< Enable/Disable custom colors
WPropBool
m_useTubesProp
;
//!< Property indicating whether to use tubes for the fibers tracts.
WPropDouble
m_tubeThickness
;
//!< Property determining the thickness of tubes .
...
...
src/modules/fiberDisplay/WRMBranch.cpp
View file @
de9e2bbc
...
...
@@ -36,6 +36,8 @@ WRMBranch::WRMBranch( boost::shared_ptr< WROIManagerFibers > roiManager ) :
setDirty
();
m_properties
=
boost
::
shared_ptr
<
WProperties2
>
(
new
WProperties2
()
);
m_isNot
=
m_properties
->
addProperty
(
"NOT"
,
"description"
,
false
,
boost
::
bind
(
&
WRMBranch
::
slotToggleNot
,
this
)
);
m_bundleColor
=
m_properties
->
addProperty
(
"Bundle Color"
,
"description"
,
WColor
(
1.0
,
0.0
,
0.0
,
1.0
),
boost
::
bind
(
&
WRMBranch
::
slotChangeBundleColor
,
this
)
);
}
WRMBranch
::~
WRMBranch
()
...
...
@@ -172,3 +174,7 @@ boost::shared_ptr< WProperties2 > WRMBranch::getProperties()
return
m_properties
;
}
void
WRMBranch
::
slotChangeBundleColor
()
{
m_roiManager
->
updateBundleColor
(
shared_from_this
(),
m_bundleColor
->
get
()
);
}
src/modules/fiberDisplay/WRMBranch.h
View file @
de9e2bbc
...
...
@@ -138,6 +138,13 @@ protected:
*/
void
slotToggleNot
();
/**
* slot gets called when a property has changed
*
*/
void
slotChangeBundleColor
();
private:
bool
m_dirty
;
//!< dirty flag to indicate the bit field must be recalculated
...
...
@@ -161,6 +168,11 @@ private:
* indicates if the branch is negated
*/
WPropBool
m_isNot
;
/**
* The color used when in isosurface mode for blending.
*/
WPropColor
m_bundleColor
;
};
#endif // WRMBRANCH_H
src/modules/fiberDisplay/WROIManagerFibers.cpp
View file @
de9e2bbc
...
...
@@ -136,6 +136,7 @@ void WROIManagerFibers::addFiberDataset( boost::shared_ptr< const WDataSetFibers
m_kdTree
=
boost
::
shared_ptr
<
WKdTree
>
(
new
WKdTree
(
verts
->
size
()
/
3
,
&
(
(
*
verts
)[
0
]
)
)
);
addBitField
(
fibers
->
size
()
);
createCustomColorArray
();
setDirty
();
}
...
...
@@ -291,3 +292,39 @@ void WROIManagerFibers::addDefaultNotifier( boost::function< void( boost::shared
m_notifiers
.
push_back
(
notifier
);
lock
.
unlock
();
}
void
WROIManagerFibers
::
createCustomColorArray
()
{
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
=
m_fibers
->
getGlobalColors
();
m_customColors
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
(
(
*
colors
).
size
()
)
);
for
(
size_t
i
=
0
;
i
<
(
*
colors
).
size
();
++
i
)
{
(
*
m_customColors
)[
i
]
=
(
*
colors
)[
i
];
}
}
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
WROIManagerFibers
::
getCustomColors
()
{
return
m_customColors
;
}
void
WROIManagerFibers
::
updateBundleColor
(
boost
::
shared_ptr
<
WRMBranch
>
branch
,
WColor
color
)
{
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
bf
=
branch
->
getBitField
();
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
starts
=
m_fibers
->
getLineStartIndexes
();
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
lengths
=
m_fibers
->
getLineLengths
();
for
(
size_t
i
=
0
;
i
<
bf
->
size
();
++
i
)
{
if
(
(
*
bf
)[
i
]
)
{
for
(
size_t
k
=
(
*
starts
)[
i
];
k
<
(
*
starts
)[
i
]
+
(
*
lengths
)[
i
];
++
k
)
{
(
*
m_customColors
)[
k
*
3
]
=
color
.
getRed
();
(
*
m_customColors
)[
k
*
3
+
1
]
=
color
.
getGreen
();
(
*
m_customColors
)[
k
*
3
+
2
]
=
color
.
getBlue
();
}
}
}
}
src/modules/fiberDisplay/WROIManagerFibers.h
View file @
de9e2bbc
...
...
@@ -146,6 +146,24 @@ public:
*/
void
recalculate
();
/**
* creates a color array, that is used for coloring of fibers
*/
void
createCustomColorArray
();
/**
* getter
*/
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
getCustomColors
();
/**
* updates the custom color array with the color of a selected branch
*
* \param branch
* \param color
*/
void
updateBundleColor
(
boost
::
shared_ptr
<
WRMBranch
>
branch
,
WColor
color
);
protected:
private:
bool
m_dirty
;
//!< dirty flag
...
...
@@ -188,6 +206,8 @@ private:
* bool to lock the update function, will be removed again once we found out why the boost lock isnt working
*/
bool
m_recalcLock
;
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
m_customColors
;
//!< vector to store custom colors
};
#endif // WROIMANAGERFIBERS_H
src/modules/fiberDisplay/WTubeDrawable.cpp
View file @
de9e2bbc
...
...
@@ -36,7 +36,8 @@
WTubeDrawable
::
WTubeDrawable
()
:
osg
::
Drawable
(),
m_useTubes
(
false
),
m_globalColoring
(
true
)
m_globalColoring
(
true
),
m_customColoring
(
false
)
{
setSupportsDisplayList
(
false
);
// This contructor intentionally left blank. Duh.
...
...
@@ -102,12 +103,27 @@ bool WTubeDrawable::getColoringMode() const
return
m_globalColoring
;
}
void
WTubeDrawable
::
setCustomColoring
(
bool
custom
)
{
m_customColoring
=
custom
;
}
void
WTubeDrawable
::
drawFibers
(
osg
::
RenderInfo
&
renderInfo
)
const
//NOLINT
{
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
startIndexes
=
m_dataset
->
getLineStartIndexes
();
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
pointsPerLine
=
m_dataset
->
getLineLengths
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
verts
=
m_dataset
->
getVertices
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
;
if
(
m_customColoring
)
{
colors
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getCustomColors
();
}
else
{
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
}
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBitField
();
osg
::
State
&
state
=
*
renderInfo
.
getState
();
...
...
@@ -134,7 +150,17 @@ void WTubeDrawable::drawTubes() const
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
pointsPerLine
=
m_dataset
->
getLineLengths
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
verts
=
m_dataset
->
getVertices
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
tangents
=
m_dataset
->
getTangents
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
colors
;
if
(
m_customColoring
)
{
colors
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getCustomColors
();
}
else
{
colors
=
(
m_globalColoring
?
m_dataset
->
getGlobalColors
()
:
m_dataset
->
getLocalColors
()
);
}
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBitField
();
for
(
size_t
i
=
0
;
i
<
active
->
size
();
++
i
)
...
...
src/modules/fiberDisplay/WTubeDrawable.h
View file @
de9e2bbc
...
...
@@ -109,6 +109,13 @@ public:
*/
void
setColoringMode
(
bool
globalColoring
);
/**
* Set the use of custom colors
*
* \param custom
*/
void
setCustomColoring
(
bool
custom
);
/**
* In which mode coloring for the fibers is applied.
*
...
...
@@ -137,6 +144,8 @@ private:
bool
m_useTubes
;
//!< flag
bool
m_globalColoring
;
//!< True indicates global, false local coloring
bool
m_customColoring
;
//!< True indicates use of custom colors
};
#endif // WTUBEDRAWABLE_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