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
b6030a2f
Commit
b6030a2f
authored
Apr 09, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - properties can now be nested in groups
parent
36703156
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
167 additions
and
45 deletions
+167
-45
src/common/WPreferences.cpp
src/common/WPreferences.cpp
+1
-1
src/common/WProperties.cpp
src/common/WProperties.cpp
+14
-6
src/common/WProperties.h
src/common/WProperties.h
+29
-27
src/common/WPropertyBase.cpp
src/common/WPropertyBase.cpp
+6
-0
src/common/WPropertyBase.h
src/common/WPropertyBase.h
+7
-0
src/common/WPropertyTypes.h
src/common/WPropertyTypes.h
+12
-0
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
+21
-0
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
+14
-0
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
+14
-3
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.h
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.h
+7
-1
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+1
-1
src/modules/fiberDisplay/WRMBranch.cpp
src/modules/fiberDisplay/WRMBranch.cpp
+1
-1
src/modules/fiberDisplay/WRMROIRepresentation.cpp
src/modules/fiberDisplay/WRMROIRepresentation.cpp
+1
-1
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+19
-4
src/modules/template/WMTemplate.h
src/modules/template/WMTemplate.h
+20
-0
No files found.
src/common/WPreferences.cpp
View file @
b6030a2f
...
...
@@ -24,4 +24,4 @@
#include "WPreferences.h"
WProperties
WPreferences
::
m_preferences
;
WProperties
WPreferences
::
m_preferences
(
"Preferences"
)
;
src/common/WProperties.cpp
View file @
b6030a2f
...
...
@@ -34,8 +34,7 @@
#include "WProperties.h"
WProperties
::
WProperties
(
std
::
string
name
,
std
::
string
description
)
:
m_name
(
name
),
m_description
(
description
),
WPropertyBase
(
name
,
description
),
m_propAccess
(
m_properties
.
getAccessObject
()
)
{
}
...
...
@@ -44,14 +43,15 @@ WProperties::~WProperties()
{
}
std
::
string
WProperties
::
get
Nam
e
()
const
PROPERTY_TYPE
WProperties
::
get
Typ
e
()
const
{
return
m_name
;
return
PV_GROUP
;
}
std
::
string
WProperties
::
g
et
Description
()
const
bool
WProperties
::
s
et
AsString
(
std
::
string
/*value*/
)
{
return
m_description
;
// groups can't be set in any way. -> ignore it.
return
true
;
}
bool
WProperties
::
propNamePredicate
(
boost
::
shared_ptr
<
WPropertyBase
>
prop1
,
boost
::
shared_ptr
<
WPropertyBase
>
prop2
)
const
...
...
@@ -124,6 +124,14 @@ WProperties::PropertySharedContainerType::WSharedAccess WProperties::getAccessOb
return
m_properties
.
getAccessObject
();
}
WPropGroup
WProperties
::
addPropertyGroup
(
std
::
string
name
,
std
::
string
description
,
bool
hide
)
{
WPropGroup
p
=
WPropGroup
(
new
WProperties
(
name
,
description
)
);
p
->
setHidden
(
hide
);
addProperty
(
p
);
return
p
;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// convenience methods for
// template< typename T>
...
...
src/common/WProperties.h
View file @
b6030a2f
...
...
@@ -36,16 +36,17 @@
#include "WSharedObject.h"
#include "WPropertyBase.h"
#include "WPropertyTypes.h"
#include "WPropertyVariable.h"
/**
* Class to manage properties of an object and to provide convenience methods for easy access and manipulation. It also allows
* thread safe iteration on its elements. The main purpose of this class is to group properties together and to allow searching properties by a
* given name. The name of each property in a group has to be unique and is constructed using the group names containing them: hello
.
you
.
property
* given name. The name of each property in a group has to be unique and is constructed using the group names containing them: hello
/
you
/
property
* is the property with the name "property" in the group "you" which against is in the group "hello".
* \note The root group of each module does not have a name.
*/
class
WProperties
class
WProperties
:
public
WPropertyBase
{
public:
...
...
@@ -84,27 +85,13 @@ public:
* \param name the name of the property group. The GUI is using this name for naming the tabs/group boxes
* \param description the description of the group.
*/
WProperties
(
std
::
string
name
=
""
,
std
::
string
description
=
"
Root Group
"
);
WProperties
(
std
::
string
name
=
"
unnamed group
"
,
std
::
string
description
=
"
an unnamed group of properties
"
);
/**
* destructor
*/
virtual
~
WProperties
();
/**
* The name of this property group.
*
* \return the name
*/
std
::
string
getName
()
const
;
/**
* The description of this property group.
*
* \return the description.
*/
std
::
string
getDescription
()
const
;
/**
* Simply insert the specified property to the list.
*
...
...
@@ -149,6 +136,15 @@ public:
// Convenience methods to create and add properties
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Create and add a new property group. Use these groups to structure your properties.
*
* \param name the name of the group.
* \param description the description of the group.
* \param hide true if group should be completely hidden.
*/
WPropGroup
addPropertyGroup
(
std
::
string
name
,
std
::
string
description
,
bool
hide
=
false
);
/**
* Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
*
...
...
@@ -217,6 +213,22 @@ public:
boost
::
shared_ptr
<
WCondition
>
condition
,
WPropertyBase
::
PropertyChangeNotifierType
notifier
,
bool
hide
=
false
);
/**
* Gets the real type of this instance. In this case, PV_GROUP.
*
* \return the real type.
*/
virtual
PROPERTY_TYPE
getType
()
const
;
/**
* This methods allows properties to be set by a string value. This method does nothing here, as groups can not be set in any kind.
*
* \param value the new value to set. IGNORED.
*
* \return always true
*/
virtual
bool
setAsString
(
std
::
string
value
);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Convenience methods to create and add properties
// NOTE: these methods use the type of the initial parameter to automatically use the proper type.
...
...
@@ -775,16 +787,6 @@ public:
private:
/**
* The name of this properties group.
*/
std
::
string
m_name
;
/**
* The description of this property group.
*/
std
::
string
m_description
;
/**
* The set of proerties. This uses the operators ==,<,> WProperty to determine equalness.
*/
...
...
src/common/WPropertyBase.cpp
View file @
b6030a2f
...
...
@@ -30,6 +30,7 @@
#include "exceptions/WPropertyNameMalformed.h"
#include "WPropertyBase.h"
#include "WProperties.h"
#include "WPropertyVariable.h"
WPropertyBase
::
WPropertyBase
(
std
::
string
name
,
std
::
string
description
)
:
...
...
@@ -120,3 +121,8 @@ WPropPosition WPropertyBase::toPropPosition()
return
boost
::
shared_static_cast
<
WPVPosition
>
(
shared_from_this
()
);
}
WPropGroup
WPropertyBase
::
toPropGroup
()
{
return
boost
::
shared_static_cast
<
WPVGroup
>
(
shared_from_this
()
);
}
src/common/WPropertyBase.h
View file @
b6030a2f
...
...
@@ -160,6 +160,13 @@ public:
*/
WPropPosition
toPropPosition
();
/**
* Helper converts this instance to its native type.
*
* \return the property as group
*/
WPropGroup
toPropGroup
();
/**
* Helper converts this instance to an arbitrary type.
*
...
...
src/common/WPropertyTypes.h
View file @
b6030a2f
...
...
@@ -38,6 +38,7 @@
template
<
typename
T
>
class
WPropertyVariable
;
class
WProperties
;
////////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTE: If you add new types here, please also add corresponding addProperty methods to WProperties
...
...
@@ -53,6 +54,7 @@ class WPropertyVariable;
typedef
enum
{
PV_UNKNOWN
,
// type not know
PV_GROUP
,
// the group property
PV_INT
,
// integer value
PV_DOUBLE
,
// floating point value
PV_BOOL
,
// boolean
...
...
@@ -89,6 +91,11 @@ namespace WPVBaseTypes
* int32_t, double, bool, ... so we are able to change the type later on without modifications of thousands of modules.
*/
/**
* Group properties.
*/
typedef
WProperties
WPVGroup
;
/**
* Int properties.
*/
...
...
@@ -174,6 +181,11 @@ typedef boost::shared_ptr< WPVPosition > WPropPosition;
*/
typedef
boost
::
shared_ptr
<
WPVColor
>
WPropColor
;
/**
* Alias for the group properties.
*/
typedef
boost
::
shared_ptr
<
WPVGroup
>
WPropGroup
;
/**
* This namespace contains several helper classes which translate their template type to an enum.
*/
...
...
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
View file @
b6030a2f
...
...
@@ -24,6 +24,8 @@
#include <string>
#include <QtGui/QGroupBox>
#include "WQtDSBWidget.h"
WQtDSBWidget
::
WQtDSBWidget
(
std
::
string
name
,
QWidget
*
parent
)
...
...
@@ -69,6 +71,19 @@ WPropertyFilenameWidget* WQtDSBWidget::addProp( WPropFilename property )
return
new
WPropertyFilenameWidget
(
property
,
&
m_controlLayout
,
this
);
}
void
WQtDSBWidget
::
addGroup
(
WQtDSBWidget
*
widget
)
{
// TODO(ebaum): extend it to collapse the group
QGroupBox
*
group
=
new
QGroupBox
(
widget
->
getName
()
,
this
);
QGridLayout
*
grid
=
new
QGridLayout
();
grid
->
addWidget
(
widget
,
0
,
0
);
group
->
setLayout
(
grid
);
// create a new group box
int
row
=
m_controlLayout
.
rowCount
();
m_controlLayout
.
addWidget
(
group
,
row
,
0
,
1
,
2
);
}
void
WQtDSBWidget
::
addSpacer
()
{
m_pageLayout
.
addStretch
();
...
...
@@ -79,3 +94,9 @@ QString WQtDSBWidget::getName()
{
return
m_name
;
}
void
WQtDSBWidget
::
setName
(
QString
name
)
{
m_name
=
name
;
}
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
View file @
b6030a2f
...
...
@@ -137,6 +137,13 @@ public:
*/
WPropertyColorWidget
*
addProp
(
WPropColor
property
);
/**
* Adds an widget containing another property group to this widget. It encloses it with a GroupBox.
*
* \param widget the widget
*/
void
addGroup
(
WQtDSBWidget
*
widget
);
/**
* helper function to add a spacer at the end
*/
...
...
@@ -147,6 +154,13 @@ public:
*/
QString
getName
();
/**
* Sets the name of this widget.
*
* \param name the name.
*/
void
setName
(
QString
name
);
protected:
private:
...
...
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
View file @
b6030a2f
...
...
@@ -384,8 +384,7 @@ void WQtDatasetBrowser::selectRoiTreeItem()
buildPropTab
(
props
);
}
void
WQtDatasetBrowser
::
buildPropTab
(
boost
::
shared_ptr
<
WProperties
>
props
)
WQtDSBWidget
*
WQtDatasetBrowser
::
buildPropWidget
(
boost
::
shared_ptr
<
WProperties
>
props
)
{
WQtDSBWidget
*
tab
=
new
WQtDSBWidget
(
"Settings"
);
...
...
@@ -394,6 +393,8 @@ void WQtDatasetBrowser::buildPropTab( boost::shared_ptr< WProperties > props )
WProperties
::
PropertyAccessType
propAccess
=
props
->
getAccessObject
();
propAccess
->
beginRead
();
tab
->
setName
(
QString
::
fromStdString
(
props
->
getName
()
)
);
// iterate all properties. This Locks the properties set -> use endIteration to unlock
for
(
WProperties
::
PropertyConstIterator
iter
=
propAccess
->
get
().
begin
();
iter
!=
propAccess
->
get
().
end
();
++
iter
)
{
...
...
@@ -427,6 +428,9 @@ void WQtDatasetBrowser::buildPropTab( boost::shared_ptr< WProperties > props )
WLogger
::
getLogger
()
->
addLogMessage
(
"This property type
\"
PV_POSITION
\"
is not yet supported by the GUI."
,
"DatasetBrowser"
,
LL_WARNING
);
break
;
case
PV_GROUP
:
tab
->
addGroup
(
buildPropWidget
(
(
*
iter
)
->
toPropGroup
()
)
);
break
;
default:
WLogger
::
getLogger
()
->
addLogMessage
(
"This property type is not yet supported."
,
"DatasetBrowser"
,
LL_WARNING
);
break
;
...
...
@@ -435,7 +439,14 @@ void WQtDatasetBrowser::buildPropTab( boost::shared_ptr< WProperties > props )
}
propAccess
->
endRead
();
}
tab
->
addSpacer
();
return
tab
;
}
void
WQtDatasetBrowser
::
buildPropTab
(
boost
::
shared_ptr
<
WProperties
>
props
)
{
WQtDSBWidget
*
tab
=
buildPropWidget
(
props
);
addTabWidgetContent
(
tab
);
}
...
...
@@ -498,7 +509,7 @@ void WQtDatasetBrowser::addTabWidgetContent( WQtDSBWidget* content )
sa
->
setWidget
(
content
);
sa
->
setWidgetResizable
(
true
);
m_tabWidget
->
addTab
(
sa
,
content
->
getName
()
);
m_tabWidget
->
addTab
(
sa
,
"Settings"
);
}
void
WQtDatasetBrowser
::
moveTreeItemDown
()
...
...
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.h
View file @
b6030a2f
...
...
@@ -205,10 +205,16 @@ private slots:
/**
* function that builds the property tab
*
* \param props
* \param props
the properties.
*/
void
buildPropTab
(
boost
::
shared_ptr
<
WProperties
>
props
);
/**
* Method builds a widgets containing all properties in props. It recursively calls itself to build group widgets for WPropGroup properties.
*
* \param props the properties.
*/
WQtDSBWidget
*
buildPropWidget
(
boost
::
shared_ptr
<
WProperties
>
props
);
/**
* function gets called when a change to a tree item, eg. check box status, occurs
...
...
src/kernel/WModule.cpp
View file @
b6030a2f
...
...
@@ -64,7 +64,7 @@ WModule::WModule():
m_moduleState
()
{
// initialize members
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
()
);
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
(
"Properties"
,
"Module's properties"
)
);
m_active
=
m_properties
->
addProperty
(
"active"
,
"Determines whether the module should be activated."
,
true
,
true
);
m_active
->
getCondition
()
->
subscribeSignal
(
boost
::
bind
(
&
WModule
::
activate
,
this
)
);
...
...
src/modules/fiberDisplay/WRMBranch.cpp
View file @
b6030a2f
...
...
@@ -34,7 +34,7 @@ WRMBranch::WRMBranch( boost::shared_ptr< WROIManagerFibers > roiManager ) :
m_roiManager
(
roiManager
)
{
setDirty
();
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
()
);
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
(
"Properties"
,
"This branch's properties"
)
);
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
)
);
...
...
src/modules/fiberDisplay/WRMROIRepresentation.cpp
View file @
b6030a2f
...
...
@@ -42,7 +42,7 @@ WRMROIRepresentation::WRMROIRepresentation( osg::ref_ptr< WROI > roi, boost::sha
{
roi
->
getSignalIsModified
()
->
connect
(
boost
::
bind
(
&
WRMROIRepresentation
::
setDirty
,
this
)
);
setDirty
();
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
()
);
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
(
"Properties"
,
"This ROI's properties"
)
);
m_isNot
=
m_properties
->
addProperty
(
"NOT"
,
"description"
,
false
,
boost
::
bind
(
&
WRMROIRepresentation
::
slotToggleNot
,
this
)
);
m_isActive
=
m_properties
->
addProperty
(
"active"
,
"description"
,
true
,
boost
::
bind
(
&
WRMROIRepresentation
::
slotToggleNot
,
this
)
);
m_isActive
->
setHidden
(
true
);
...
...
src/modules/template/WMTemplate.cpp
View file @
b6030a2f
...
...
@@ -169,10 +169,25 @@ void WMTemplate::properties()
// These lines create some new properties and add them to the property list of this module. The specific type to create is determined by the
// initial value specified in the third argument. The first argument is the name of the property, which needs to be unique among all
// properties of this module. The second argument is a description. A nice feature is the possibility to specify an own condition, which gets
// fired when the property gets modified. This is especially useful to wake up the module's thread on property changes. So, the property
// m_anInteger will wake the module thread on changes. m_enableFeature and m_aColor should not wake up the module thread. They get read by
// the update callback of this modules OSG node, to update the color.
// properties of this group and must not contain any slashes (/). The second argument is a description. A nice feature is the possibility
// to specify an own condition, which gets fired when the property gets modified. This is especially useful to wake up the module's thread
// on property changes. So, the property m_anInteger will wake the module thread on changes. m_enableFeature and m_aColor should not wake up
// the module thread. They get read by the update callback of this modules OSG node, to update the color.
// Adding a lot of properties might confuse the user. Using WPropGroup, you have the possibility to group your properties together. A
// WPropGroup needs a name and can provide a description. As with properties, the name should not contain any "/" and must be unique.
m_group1
=
m_properties
->
addPropertyGroup
(
"Group 1"
,
"A nice group for grouping stuff."
);
m_group1a
=
m_group1
->
addPropertyGroup
(
"Group 1a"
,
"A group nested into
\"
Group 1
\"
."
);
m_group2
=
m_properties
->
addPropertyGroup
(
"Group 2"
,
"Another nice group for grouping stuff."
);
// To understand how the groups can be used, you should consider that m_properties itself is a WPropGroup! This means, you can use your newly
// created groups exactly in the same way as you would use m_properties.
m_group1Bool
=
m_group1
->
addProperty
(
"Funny stuff"
,
"A grouped property"
,
true
);
// You even can add one property multiple times to different groups:
m_group2
->
addProperty
(
m_aColor
);
m_group1a
->
addProperty
(
m_aDouble
);
// How can the values of the properties be changed? You can take a look at moduleMain where this is shown. For short: m_anInteger->set( 2 )
// and m_anInteger->get().
...
...
src/modules/template/WMTemplate.h
View file @
b6030a2f
...
...
@@ -126,11 +126,31 @@ private:
*/
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
/**
* To group properties, use WPropGroup.
*/
WPropGroup
m_group1
;
/**
* To group properties, use WPropGroup.
*/
WPropGroup
m_group1a
;
/**
* To group properties, use WPropGroup.
*/
WPropGroup
m_group2
;
/**
* En/Disables an feature.
*/
WPropBool
m_enableFeature
;
/**
* A nice feature trigger inside m_group1
*/
WPropBool
m_group1Bool
;
/**
* An integer value.
*/
...
...
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