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
c14a116c
Commit
c14a116c
authored
Oct 22, 2009
by
schurade
Browse files
[CHANGE] properties emit a signal now when their value changed
parent
33e5c76f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
35 deletions
+126
-35
src/kernel/WKernel.cpp
src/kernel/WKernel.cpp
+1
-0
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+2
-2
src/kernel/WModuleConnectorSignals.h
src/kernel/WModuleConnectorSignals.h
+5
-5
src/kernel/WProperties.cpp
src/kernel/WProperties.cpp
+12
-7
src/kernel/WProperties.h
src/kernel/WProperties.h
+42
-6
src/kernel/WProperty.cpp
src/kernel/WProperty.cpp
+27
-6
src/kernel/WProperty.h
src/kernel/WProperty.h
+11
-0
src/modules/navigationSlices/WNavigationSliceModule.cpp
src/modules/navigationSlices/WNavigationSliceModule.cpp
+19
-7
src/modules/navigationSlices/WNavigationSliceModule.h
src/modules/navigationSlices/WNavigationSliceModule.h
+5
-0
tools/brainlint.py
tools/brainlint.py
+2
-2
No files found.
src/kernel/WKernel.cpp
View file @
c14a116c
...
...
@@ -296,6 +296,7 @@ void WKernel::slotFinishLoadData( boost::shared_ptr< WDataSet > dataSet )
module
->
getProperties
()
->
addBool
(
"active"
,
true
);
module
->
getProperties
()
->
addInt
(
"threshold"
,
0
);
module
->
getProperties
()
->
addInt
(
"alpha"
,
100
);
module
->
getProperties
()
->
setMax
(
"alpha"
,
100
);
module
->
getProperties
()
->
setValue
(
"name"
,
dataSet
->
getFileName
()
);
m_gui
->
addDatasetToBrowser
(
module
,
0
);
...
...
src/kernel/WModule.cpp
View file @
c14a116c
...
...
@@ -38,10 +38,10 @@
WModule
::
WModule
()
:
WThreadedRunner
(),
m_properties
()
m_properties
(),
m_initialized
(
false
)
{
// initialize members
m_initialized
=
false
;
}
WModule
::~
WModule
()
...
...
src/kernel/WModuleConnectorSignals.h
View file @
c14a116c
...
...
@@ -30,7 +30,7 @@
class
WModuleConnector
;
/**
/**
* Enum of all possible signals between WModuleConnector instances.
* TODO(ebaum): Replace this by an automatic mapping class also able to allow varying function signatures.
*/
...
...
@@ -46,9 +46,9 @@ MODULE_CONNECTOR_SIGNAL;
// Types
// **************************************************************************************************************************
/**
/**
* Signal transmitting sender and receiver.
*
*
* \param boost::shared_ptr<WModuleConnector> this should be the receiver, depending on specific signal.
* \param boost::shared_ptr<WModuleConnector> this should be the sender, depending on specific signal.
*
...
...
@@ -56,9 +56,9 @@ MODULE_CONNECTOR_SIGNAL;
typedef
boost
::
function
<
void
(
boost
::
shared_ptr
<
WModuleConnector
>
,
boost
::
shared_ptr
<
WModuleConnector
>
)
>
t_GenericSignalHandlerType
;
/**
/**
* Generic signal type used in the most signals involving a sender and receiver.
*
*
* \param recv The connector receiving the signal.
* \param sender The counterpart (sender).
*/
...
...
src/kernel/WProperties.cpp
View file @
c14a116c
...
...
@@ -39,45 +39,50 @@ WProperties::~WProperties()
{
}
void
WProperties
::
addBool
(
std
::
string
name
,
bool
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addBool
(
std
::
string
name
,
bool
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
void
WProperties
::
addChar
(
std
::
string
name
,
char
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addChar
(
std
::
string
name
,
char
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
void
WProperties
::
addInt
(
std
::
string
name
,
int
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addInt
(
std
::
string
name
,
int
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
void
WProperties
::
addFloat
(
std
::
string
name
,
float
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addFloat
(
std
::
string
name
,
float
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
void
WProperties
::
addDouble
(
std
::
string
name
,
double
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addDouble
(
std
::
string
name
,
double
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
void
WProperties
::
addString
(
std
::
string
name
,
std
::
string
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
boost
::
signal1
<
void
,
std
::
string
>*
WProperties
::
addString
(
std
::
string
name
,
std
::
string
value
,
std
::
string
shortDesc
,
std
::
string
longDesc
)
{
WProperty
*
prop
=
new
WProperty
(
name
,
value
,
shortDesc
,
longDesc
);
m_propertyList
[
name
]
=
prop
;
return
prop
->
getSignalValueChanged
();
}
WProperty
*
WProperties
::
findProp
(
std
::
string
name
)
...
...
src/kernel/WProperties.h
View file @
c14a116c
...
...
@@ -49,12 +49,12 @@ public:
std
::
map
<
std
::
string
,
WProperty
*
>*
getProperties
();
void
addBool
(
std
::
string
name
,
bool
value
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
void
addChar
(
std
::
string
name
,
char
value
=
0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
void
addInt
(
std
::
string
name
,
int
value
=
0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
void
addFloat
(
std
::
string
name
,
float
value
=
0.0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
void
addDouble
(
std
::
string
name
,
double
value
=
0.0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
void
addString
(
std
::
string
name
,
std
::
string
value
=
""
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addBool
(
std
::
string
name
,
bool
value
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addChar
(
std
::
string
name
,
char
value
=
0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addInt
(
std
::
string
name
,
int
value
=
0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addFloat
(
std
::
string
name
,
float
value
=
0.0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addDouble
(
std
::
string
name
,
double
value
=
0.0
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
boost
::
signal1
<
void
,
std
::
string
>*
addString
(
std
::
string
name
,
std
::
string
value
=
""
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
std
::
string
getValueString
(
const
std
::
string
prop
);
...
...
@@ -66,6 +66,22 @@ public:
}
}
template
<
typename
T
>
void
setMin
(
std
::
string
prop
,
const
T
&
arg
)
{
if
(
findProp
(
prop
)
)
{
findProp
(
prop
)
->
setMin
(
arg
);
}
}
template
<
typename
T
>
void
setMax
(
std
::
string
prop
,
const
T
&
arg
)
{
if
(
findProp
(
prop
)
)
{
findProp
(
prop
)
->
setMax
(
arg
);
}
}
template
<
typename
T
>
T
getValue
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -74,6 +90,26 @@ public:
}
return
0
;
}
template
<
typename
T
>
T
getMin
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
{
return
findProp
(
prop
)
->
getMin
<
T
>
();
}
return
0
;
}
template
<
typename
T
>
T
getMax
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
{
return
findProp
(
prop
)
->
getMax
<
T
>
();
}
return
0
;
}
private:
WProperty
*
findProp
(
std
::
string
name
);
...
...
src/kernel/WProperty.cpp
View file @
c14a116c
...
...
@@ -31,7 +31,8 @@ WProperty::WProperty( std::string name, std::string value, std::string shortDesc
m_name
(
name
),
m_value
(
value
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
}
...
...
@@ -39,7 +40,8 @@ WProperty::WProperty( std::string name, bool value, std::string shortDesc, std::
:
m_type
(
P_BOOL
),
m_name
(
name
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
setValue
(
value
);
}
...
...
@@ -48,7 +50,8 @@ WProperty::WProperty( std::string name, char value, std::string shortDesc, std::
:
m_type
(
P_CHAR
),
m_name
(
name
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
setMin
(
-
128
);
setMax
(
127
);
...
...
@@ -59,7 +62,8 @@ WProperty::WProperty( std::string name, int value, std::string shortDesc, std::s
:
m_type
(
P_INT
),
m_name
(
name
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
setMin
(
0
);
setMax
(
255
);
...
...
@@ -70,7 +74,8 @@ WProperty::WProperty( std::string name, float value, std::string shortDesc, std:
:
m_type
(
P_FLOAT
),
m_name
(
name
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
setMin
(
0.0
);
setMax
(
100.0
);
...
...
@@ -81,7 +86,8 @@ WProperty::WProperty( std::string name, double value, std::string shortDesc, std
:
m_type
(
P_DOUBLE
),
m_name
(
name
),
m_shortDesc
(
shortDesc
),
m_longDesc
(
longDesc
)
m_longDesc
(
longDesc
),
m_isHidden
(
false
)
{
setMin
(
0.0
);
setMax
(
100.0
);
...
...
@@ -132,3 +138,18 @@ std::string WProperty::getValueString()
{
return
m_value
;
}
void
WProperty
::
setHidden
()
{
m_isHidden
=
true
;
}
bool
WProperty
::
isHidden
()
{
return
m_isHidden
;
}
boost
::
signal1
<
void
,
std
::
string
>*
WProperty
::
getSignalValueChanged
()
{
return
&
m_signalValueChanged
;
}
src/kernel/WProperty.h
View file @
c14a116c
...
...
@@ -28,6 +28,7 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include "../gui/qt4/signalslib.hpp"
typedef
enum
{
...
...
@@ -70,9 +71,14 @@ public:
void
setShortDesc
(
const
std
::
string
desc
);
void
setLongDesc
(
const
std
::
string
desc
);
void
setHidden
();
bool
isHidden
();
std
::
string
getShortDesc
();
std
::
string
getLongDesc
();
boost
::
signal1
<
void
,
std
::
string
>*
getSignalValueChanged
();
template
<
typename
T
>
void
setValue
(
const
T
&
arg
)
{
...
...
@@ -84,6 +90,7 @@ public:
{
m_value
=
""
;
}
m_signalValueChanged
(
m_name
);
}
template
<
typename
T
>
void
setMin
(
const
T
&
arg
)
...
...
@@ -137,6 +144,10 @@ private:
std
::
string
m_max
;
std
::
string
m_shortDesc
;
std
::
string
m_longDesc
;
bool
m_isHidden
;
boost
::
signal1
<
void
,
std
::
string
>
m_signalValueChanged
;
};
#endif // WPROPERTY_H
src/modules/navigationSlices/WNavigationSliceModule.cpp
View file @
c14a116c
...
...
@@ -97,19 +97,19 @@ void WNavigationSliceModule::connectors()
void
WNavigationSliceModule
::
properties
()
{
m_properties
.
addBool
(
"textureChanged"
,
true
);
(
m_properties
.
addBool
(
"textureChanged"
,
true
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
m_properties
.
addInt
(
"axialPos"
,
80
);
m_properties
.
addInt
(
"coronalPos"
,
100
);
m_properties
.
addInt
(
"sagittalPos"
,
80
);
(
m_properties
.
addInt
(
"axialPos"
,
80
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
(
m_properties
.
addInt
(
"coronalPos"
,
100
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
(
m_properties
.
addInt
(
"sagittalPos"
,
80
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
m_properties
.
addInt
(
"maxAxial"
,
160
);
m_properties
.
addInt
(
"maxCoronal"
,
200
);
m_properties
.
addInt
(
"maxSagittal"
,
160
);
m_properties
.
addBool
(
"showAxial"
,
true
);
m_properties
.
addBool
(
"showCoronal"
,
true
);
m_properties
.
addBool
(
"showSagittal"
,
true
);
(
m_properties
.
addBool
(
"showAxial"
,
true
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
(
m_properties
.
addBool
(
"showCoronal"
,
true
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
(
m_properties
.
addBool
(
"showSagittal"
,
true
)
)
->
connect
(
boost
::
bind
(
&
WNavigationSliceModule
::
slotPropertyChanged
,
this
,
_1
)
);
}
void
WNavigationSliceModule
::
notifyDataChange
(
boost
::
shared_ptr
<
WModuleConnector
>
input
,
...
...
@@ -414,3 +414,15 @@ void WNavigationSliceModule::initUniforms( osg::StateSet* sliceState )
sliceState
->
addUniform
(
m_samplerUniforms
[
i
]
);
}
}
void
WNavigationSliceModule
::
slotPropertyChanged
(
std
::
string
propertyName
)
{
if
(
propertyName
==
"textureChanged"
)
{
updateTextures
();
}
else
{
updateSlices
();
}
}
src/modules/navigationSlices/WNavigationSliceModule.h
View file @
c14a116c
...
...
@@ -79,6 +79,11 @@ public:
*/
void
connectToGui
();
/**
*
*/
void
slotPropertyChanged
(
std
::
string
propertyName
);
protected:
/**
...
...
tools/brainlint.py
View file @
c14a116c
...
...
@@ -1983,9 +1983,9 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error):
if
(
not
line
.
startswith
(
'#include'
)
and
not
is_header_guard
and
not
Match
(
r
'^\s*//.*http(s?)://\S*$'
,
line
)):
line_width
=
GetLineWidth
(
line
)
if
line_width
>
1
3
0
:
if
line_width
>
1
5
0
:
error
(
filename
,
linenum
,
'whitespace/line_length'
,
4
,
'Lines should be <= 1
3
0 characters long'
)
'Lines should be <= 1
5
0 characters long'
)
if
(
cleansed_line
.
count
(
';'
)
>
1
and
# for loops are allowed two ;'s (and may run over two lines).
...
...
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