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
6b3a4d08
Commit
6b3a4d08
authored
Apr 02, 2013
by
Sebastian Eichelbaum
Browse files
[ADD
#59
] loading of rois now works.
parent
fc75b437
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
12 deletions
+99
-12
src/core/kernel/WROIManager.cpp
src/core/kernel/WROIManager.cpp
+18
-6
src/core/kernel/WROIManager.h
src/core/kernel/WROIManager.h
+15
-0
src/core/kernel/WRoiProjectFileIO.cpp
src/core/kernel/WRoiProjectFileIO.cpp
+59
-4
src/core/kernel/WRoiProjectFileIO.h
src/core/kernel/WRoiProjectFileIO.h
+7
-2
No files found.
src/core/kernel/WROIManager.cpp
View file @
6b3a4d08
...
...
@@ -41,14 +41,10 @@ WROIManager::~WROIManager()
{
}
void
WROIManager
::
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
)
void
WROIManager
::
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
,
boost
::
shared_ptr
<
WRMBranch
>
toBranch
)
{
// create new branch
boost
::
shared_ptr
<
WRMBranch
>
newBranch
=
boost
::
shared_ptr
<
WRMBranch
>
(
new
WRMBranch
(
shared_from_this
()
)
);
// add branch to list
m_branches
.
push_back
(
newBranch
);
// add roi to branch
new
Branch
->
addRoi
(
newRoi
);
to
Branch
->
addRoi
(
newRoi
);
for
(
std
::
list
<
boost
::
shared_ptr
<
boost
::
function
<
void
(
osg
::
ref_ptr
<
WROI
>
)
>
>
>::
iterator
iter
=
m_addNotifiers
.
begin
();
iter
!=
m_addNotifiers
.
end
();
++
iter
)
...
...
@@ -57,6 +53,22 @@ void WROIManager::addRoi( osg::ref_ptr< WROI > newRoi )
}
}
void
WROIManager
::
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
)
{
addRoi
(
newRoi
,
addBranch
()
);
}
boost
::
shared_ptr
<
WRMBranch
>
WROIManager
::
addBranch
()
{
// create new branch
boost
::
shared_ptr
<
WRMBranch
>
newBranch
=
boost
::
shared_ptr
<
WRMBranch
>
(
new
WRMBranch
(
shared_from_this
()
)
);
// add branch to list
m_branches
.
push_back
(
newBranch
);
// return
return
newBranch
;
}
void
WROIManager
::
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
,
osg
::
ref_ptr
<
WROI
>
parentRoi
)
{
// find branch
...
...
src/core/kernel/WROIManager.h
View file @
6b3a4d08
...
...
@@ -50,6 +50,13 @@ public:
*/
~
WROIManager
();
/**
* Add a new branch.
*
* \return the new branch.
*/
boost
::
shared_ptr
<
WRMBranch
>
addBranch
();
/**
* adds a new master ROI
*
...
...
@@ -67,6 +74,14 @@ public:
*/
void
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
,
osg
::
ref_ptr
<
WROI
>
parentRoi
);
/**
* Add a ROI to a branch.
*
* \param newRoi the new ROI to add
* \param toBranch the branch to add the ROI to.
*/
void
addRoi
(
osg
::
ref_ptr
<
WROI
>
newRoi
,
boost
::
shared_ptr
<
WRMBranch
>
toBranch
);
/**
* removes a roi
*
...
...
src/core/kernel/WRoiProjectFileIO.cpp
View file @
6b3a4d08
...
...
@@ -85,7 +85,7 @@ bool WRoiProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": Property
\"
"
<<
prop
<<
"
\"
of Branch "
<<
branch
<<
" set to "
<<
propValue
;
// store info
m_branchProperties
[
branch
]
=
Property
(
prop
,
propValue
);
m_branchProperties
[
branch
]
.
push_back
(
Property
(
prop
,
propValue
)
);
}
else
if
(
boost
::
regex_match
(
line
,
matches
,
roiBoxPropRe
)
)
{
...
...
@@ -95,7 +95,7 @@ bool WRoiProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": Property
\"
"
<<
prop
<<
"
\"
of ROI "
<<
roiID
<<
" set to "
<<
propValue
;
// store info
m_roiProperties
[
roiID
]
=
Property
(
prop
,
propValue
);
m_roiProperties
[
roiID
]
.
push_back
(
Property
(
prop
,
propValue
)
);
}
else
{
...
...
@@ -108,7 +108,62 @@ bool WRoiProjectFileIO::parse( std::string line, unsigned int lineNumber )
void
WRoiProjectFileIO
::
done
()
{
// apply
boost
::
shared_ptr
<
WROIManager
>
rm
=
WKernel
::
getRunningKernel
()
->
getRoiManager
();
std
::
map
<
Branch
,
boost
::
shared_ptr
<
WRMBranch
>
>
branches
;
// add all branches
for
(
std
::
vector
<
Branch
>::
const_iterator
i
=
m_branches
.
begin
();
i
!=
m_branches
.
end
();
++
i
)
{
boost
::
shared_ptr
<
WRMBranch
>
branch
=
rm
->
addBranch
();
branches
[
*
i
]
=
branch
;
// set the properties
for
(
Properties
::
const_iterator
propI
=
m_branchProperties
[
*
i
].
begin
();
propI
!=
m_branchProperties
[
*
i
].
end
();
++
propI
)
{
std
::
string
name
=
(
*
propI
).
get
<
0
>
();
std
::
string
value
=
(
*
propI
).
get
<
1
>
();
WPropertyBase
::
SPtr
prop
=
branch
->
getProperties
()
->
findProperty
(
name
);
if
(
prop
)
{
prop
->
setAsString
(
value
);
}
else
{
addError
(
"The ROI does not have a property named
\"
"
+
name
+
"
\"
. Skipping."
);
}
}
}
// add ROIs to the branches
for
(
std
::
vector
<
Roi
>::
const_iterator
i
=
m_rois
.
begin
();
i
!=
m_rois
.
end
();
++
i
)
{
// get branch of this ROI
boost
::
shared_ptr
<
WRMBranch
>
branch
=
branches
[
(
*
i
).
get
<
1
>
()
];
// add ROI to branch
osg
::
ref_ptr
<
WROI
>
roi
(
new
WROIBox
(
WPosition
(),
WPosition
()
)
);
rm
->
addRoi
(
roi
,
branch
);
// set the properties
for
(
Properties
::
const_iterator
propI
=
m_roiProperties
[
(
*
i
).
get
<
0
>
()
].
begin
();
propI
!=
m_roiProperties
[
(
*
i
).
get
<
0
>
()
].
end
();
++
propI
)
{
std
::
string
name
=
(
*
propI
).
get
<
0
>
();
std
::
string
value
=
(
*
propI
).
get
<
1
>
();
WPropertyBase
::
SPtr
prop
=
roi
->
getProperties
()
->
findProperty
(
name
);
if
(
prop
)
{
prop
->
setAsString
(
value
);
}
else
{
addError
(
"The ROI does not have a property named
\"
"
+
name
+
"
\"
. Skipping."
);
}
}
}
// clear everything
m_branches
.
clear
();
...
...
@@ -128,6 +183,7 @@ void WRoiProjectFileIO::save( std::ostream& output ) // NOLINT
// write all branches
WROIManager
::
Branches
branches
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBranches
();
unsigned
int
branchIndex
=
0
;
unsigned
int
roiIndex
=
0
;
for
(
WROIManager
::
Branches
::
const_iterator
branchIter
=
branches
.
begin
();
branchIter
!=
branches
.
end
();
++
branchIter
)
{
// get the branch
...
...
@@ -140,7 +196,6 @@ void WRoiProjectFileIO::save( std::ostream& output ) // NOLINT
// handle this branch's ROIs
WROIManager
::
ROIs
rois
=
branch
->
getRois
();
unsigned
int
roiIndex
=
0
;
for
(
WROIManager
::
ROIs
::
const_iterator
roiIter
=
rois
.
begin
();
roiIter
!=
rois
.
end
();
++
roiIter
)
{
// differentiate the type of roi, currently we will support only WROiBox
...
...
src/core/kernel/WRoiProjectFileIO.h
View file @
6b3a4d08
...
...
@@ -84,6 +84,11 @@ private:
*/
typedef
boost
::
tuple
<
std
::
string
,
std
::
string
>
Property
;
/**
* The properties as vector.
*/
typedef
std
::
vector
<
Property
>
Properties
;
/**
* All loaded branch IDs
*/
...
...
@@ -92,7 +97,7 @@ private:
/**
* Properties of each branch
*/
std
::
map
<
Branch
,
Propert
y
>
m_branchProperties
;
std
::
map
<
Branch
,
Propert
ies
>
m_branchProperties
;
/**
* ID of a ROI
...
...
@@ -112,7 +117,7 @@ private:
/**
* Properties of each branch
*/
std
::
map
<
RoiID
,
Propert
y
>
m_roiProperties
;
std
::
map
<
RoiID
,
Propert
ies
>
m_roiProperties
;
};
#endif // WROIPROJECTFILEIO_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