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
e4a1f5af
Commit
e4a1f5af
authored
Dec 17, 2009
by
Sebastian Eichelbaum
Browse files
[CHANGE] - cleaned up WGUI interface, adopted modules appropriately
- also see ticket
#142
parent
8aa2018e
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
105 additions
and
139 deletions
+105
-139
src/common/CMakeLists.txt
src/common/CMakeLists.txt
+1
-0
src/common/WFlag.h
src/common/WFlag.h
+36
-5
src/gui/WGUI.cpp
src/gui/WGUI.cpp
+0
-5
src/gui/WGUI.h
src/gui/WGUI.h
+0
-34
src/gui/qt4/WQt4Gui.cpp
src/gui/qt4/WQt4Gui.cpp
+15
-14
src/gui/qt4/WQt4Gui.h
src/gui/qt4/WQt4Gui.h
+8
-22
src/kernel/CMakeLists.txt
src/kernel/CMakeLists.txt
+2
-0
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+9
-5
src/kernel/WModule.h
src/kernel/WModule.h
+11
-6
src/kernel/WModuleContainer.cpp
src/kernel/WModuleContainer.cpp
+2
-3
src/kernel/test/WModuleConnector_test.h
src/kernel/test/WModuleConnector_test.h
+0
-8
src/modules/coordinateSystem/WMCoordinateSystem.cpp
src/modules/coordinateSystem/WMCoordinateSystem.cpp
+3
-6
src/modules/coordinateSystem/WMCoordinateSystem.h
src/modules/coordinateSystem/WMCoordinateSystem.h
+0
-6
src/modules/distanceMap/WMDistanceMap.cpp
src/modules/distanceMap/WMDistanceMap.cpp
+3
-1
src/modules/eegTest/WMEEGTest.cpp
src/modules/eegTest/WMEEGTest.cpp
+3
-0
src/modules/fiberClustering/WMFiberClustering.cpp
src/modules/fiberClustering/WMFiberClustering.cpp
+3
-0
src/modules/fiberCulling/WMFiberCulling.cpp
src/modules/fiberCulling/WMFiberCulling.cpp
+3
-0
src/modules/fiberDisplay/WMFiberDisplay.cpp
src/modules/fiberDisplay/WMFiberDisplay.cpp
+3
-6
src/modules/fiberDisplay/WMFiberDisplay.h
src/modules/fiberDisplay/WMFiberDisplay.h
+0
-6
src/modules/hud/WMHud.cpp
src/modules/hud/WMHud.cpp
+3
-12
No files found.
src/common/CMakeLists.txt
View file @
e4a1f5af
...
...
@@ -13,6 +13,7 @@ IF( CXXTEST_FOUND )
"common"
# no libs for linking required
"WSegmentationFault.cpp"
"WTransferable.cpp"
"WConditionSet.cpp"
"WPrototyped.cpp"
"WStringUtils.h"
# since unit tests are already included via the .h file
)
...
...
src/common/WFlag.h
View file @
e4a1f5af
...
...
@@ -37,13 +37,25 @@ class WFlag
public:
/**
* Constructor. Uses a given condition to realize the wait/notify functionality.
* Constructor. Uses a given condition to realize the wait/notify functionality. By using this constructor, the specified
* condition gets deleted whenever this WFlag is deleted.
*
* \param condition the condition to use. NOTE: can also be a WConditionOneShot.
* \param initial the initial value of this flag
* \param condition the condition to use.
* \note condition can also be a WConditionOneShot.
* \param initial the initial value of this flag.
*/
WFlag
(
WCondition
*
condition
,
T
initial
);
/**
* Constructor. Uses a given condition to realize the wait/notify functionality. By using this constructor, the specified
* condition gets NOT explicitely deleted when this WFlag gets deleted.
*
* \param condition the condition to use.
* \note condition can also be a WConditionOneShot.
* \param initial the initial value of this flag.
*/
WFlag
(
boost
::
shared_ptr
<
WCondition
>
condition
,
T
initial
);
/**
* Destructor. It deletes the instance of WCondition specified on construction.
*/
...
...
@@ -82,12 +94,19 @@ public:
*/
virtual
void
operator
()(
T
value
);
/**
* Returns the condition that is used by this flag.
*
* \return the condition
*/
boost
::
shared_ptr
<
WCondition
>
getCondition
();
protected:
/**
* The condition to be used for waiting/notifying. Please note, that it gets deleted during destruction.
*/
WCondition
*
m_condition
;
boost
::
shared_ptr
<
WCondition
>
m_condition
;
/**
* The flag value.
...
...
@@ -104,6 +123,13 @@ typedef WFlag< bool > WBoolFlag;
template
<
typename
T
>
WFlag
<
T
>::
WFlag
(
WCondition
*
condition
,
T
initial
)
{
m_condition
=
boost
::
shared_ptr
<
WCondition
>
(
condition
);
m_flag
=
initial
;
}
template
<
typename
T
>
WFlag
<
T
>::
WFlag
(
boost
::
shared_ptr
<
WCondition
>
condition
,
T
initial
)
{
m_condition
=
condition
;
m_flag
=
initial
;
...
...
@@ -112,7 +138,6 @@ WFlag< T >::WFlag( WCondition* condition, T initial )
template
<
typename
T
>
WFlag
<
T
>::~
WFlag
()
{
delete
m_condition
;
}
template
<
typename
T
>
...
...
@@ -149,5 +174,11 @@ void WFlag< T >::set( T value )
m_condition
->
notify
();
}
template
<
typename
T
>
boost
::
shared_ptr
<
WCondition
>
WFlag
<
T
>::
getCondition
()
{
return
m_condition
;
}
#endif // WFLAG_H
src/gui/WGUI.cpp
View file @
e4a1f5af
...
...
@@ -43,8 +43,3 @@ const WFlag< bool >& WGUI::isInitialized() const
return
m_isInitialized
;
}
void
WGUI
::
slotAddDatasetToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
)
{
addDatasetToBrowser
(
module
,
0
);
}
src/gui/WGUI.h
View file @
e4a1f5af
...
...
@@ -82,25 +82,6 @@ public:
*/
virtual
int
run
()
=
0
;
/**
* Slot gets called whenever a new module is added.
*
* \param module
*/
virtual
void
slotAddDatasetToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* adds a dataset to the dataset browser for a give subject
*/
virtual
void
addDatasetToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
,
int
subjectId
)
=
0
;
/**
* adds a module to the dataset browser
*
* \param module
*/
virtual
void
addModuleToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
)
=
0
;
/**
* returns a vector of pointers to the loaded datasets for a given subject.
*
...
...
@@ -111,26 +92,11 @@ public:
*/
virtual
std
::
vector
<
boost
::
shared_ptr
<
WDataSet
>
>
getDataSetList
(
int
subjectId
,
bool
onlyTextures
=
false
)
=
0
;
/**
* returns a pointer to the selected module in the dataset browser
*
* \return the module
*/
virtual
boost
::
shared_ptr
<
WModule
>
getSelectedModule
()
=
0
;
/**
* getter functions for the signales proved by the gui
*/
virtual
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
getLoadButtonSignal
()
=
0
;
virtual
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
()
=
0
;
/**
* this function allows modules to register their property object with the gui
*/
virtual
void
connectProperties
(
boost
::
shared_ptr
<
WProperties
>
properties
)
=
0
;
protected:
/**
...
...
src/gui/qt4/WQt4Gui.cpp
View file @
e4a1f5af
...
...
@@ -28,6 +28,7 @@
#include <vector>
#include <boost/program_options.hpp>
#include <boost/shared_ptr.hpp>
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
...
...
@@ -35,6 +36,7 @@
#include "WMainWindow.h"
#include "../../kernel/WKernel.h"
#include "../../graphicsEngine/WGraphicsEngine.h"
#include "../../modules/data/WMData.h"
#include "WQt4Gui.h"
...
...
@@ -147,7 +149,7 @@ int WQt4Gui::run()
m_gui
->
getModuleButtonSignal
()
->
connect
(
boost
::
bind
(
&
WKernel
::
applyModule
,
m_kernel
,
_1
,
_2
)
);
// bind the GUI's slot with the ready signal
t_ModuleGenericSignalHandlerType
f
=
boost
::
bind
(
&
W
GUI
::
slotAddDatasetToBrowser
,
this
,
_1
);
t_ModuleGenericSignalHandlerType
f
=
boost
::
bind
(
&
W
Qt4Gui
::
slotAddDataset
OrModule
ToBrowser
,
this
,
_1
);
m_kernel
->
getRootContainer
()
->
addDefaultNotifier
(
READY
,
f
);
// now we are initialized
...
...
@@ -169,17 +171,22 @@ int WQt4Gui::run()
return
qtRetCode
;
}
void
WQt4Gui
::
a
ddDatasetToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
,
int
subjectId
)
void
WQt4Gui
::
slotA
ddDataset
OrModule
ToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
)
{
m_gui
->
getDatasetBrowser
()
->
addDataset
(
module
,
subjectId
);
}
// get properties from the module and register them
m_gui
->
getPropertyManager
()
->
connectProperties
(
module
->
getProperties
()
);
void
WQt4Gui
::
addModuleToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
)
{
m_gui
->
getDatasetBrowser
()
->
addModule
(
module
);
// TODO(schurade): is this differentiation between data and "normal" modules really needed?
if
(
boost
::
shared_dynamic_cast
<
WMData
>
(
module
).
get
()
)
{
m_gui
->
getDatasetBrowser
()
->
addDataset
(
module
,
0
);
}
else
{
m_gui
->
getDatasetBrowser
()
->
addModule
(
module
);
}
}
std
::
vector
<
boost
::
shared_ptr
<
WDataSet
>
>
WQt4Gui
::
getDataSetList
(
int
subjectId
,
bool
onlyTextures
)
{
return
m_gui
->
getDatasetBrowser
()
->
getDataSetList
(
subjectId
,
onlyTextures
);
...
...
@@ -190,7 +197,6 @@ boost::shared_ptr< WModule > WQt4Gui::getSelectedModule()
return
m_gui
->
getDatasetBrowser
()
->
getSelectedModule
();
}
boost
::
signals2
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>*
WQt4Gui
::
getLoadButtonSignal
()
{
return
m_gui
->
getLoaderSignal
();
...
...
@@ -201,8 +207,3 @@ boost::signals2::signal1< void, std::string >* WQt4Gui::getPickSignal()
return
m_gui
->
getPickSignal
();
}
void
WQt4Gui
::
connectProperties
(
boost
::
shared_ptr
<
WProperties
>
properties
)
{
m_gui
->
getPropertyManager
()
->
connectProperties
(
properties
);
}
src/gui/qt4/WQt4Gui.h
View file @
e4a1f5af
...
...
@@ -64,21 +64,6 @@ public:
*/
virtual
int
run
();
/**
* adds a dataset to the dataset browser
*
* \param module
* \param subjectId
*/
void
addDatasetToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
,
int
subjectId
);
/**
* adds a module to the dataset browser
*
* \param module
*/
void
addModuleToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* returns a vector of pointers to the loaded datasets for a given subject.
*
...
...
@@ -89,7 +74,6 @@ public:
*/
virtual
std
::
vector
<
boost
::
shared_ptr
<
WDataSet
>
>
getDataSetList
(
int
subjectId
,
bool
onlyTextures
=
false
);
/**
* returns a pointer to the selected module in the dataset browser
*
...
...
@@ -97,6 +81,14 @@ public:
*/
virtual
boost
::
shared_ptr
<
WModule
>
getSelectedModule
();
/**
* Slot gets called whenever a new module is added.
*
* \param module the module to be added
*
* \note This can be used to add datasets or other modules.
*/
virtual
void
slotAddDatasetOrModuleToBrowser
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* getter functions for the signales proved by the gui
...
...
@@ -105,12 +97,6 @@ public:
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
();
/**
* this function allows modules to register their property object with the gui
* \param properties the properties taht will be registered
*/
virtual
void
connectProperties
(
boost
::
shared_ptr
<
WProperties
>
properties
);
protected:
private:
...
...
src/kernel/CMakeLists.txt
View file @
e4a1f5af
...
...
@@ -18,6 +18,8 @@ IF( CXXTEST_FOUND )
"WModule.cpp"
"WModuleInputConnector.cpp"
"WModuleOutputConnector.cpp"
"WModuleSignals.cpp"
"WModuleConnectorSignals.cpp"
"WModuleInputData.h"
"WModuleOutputData.h"
"WModuleInputData.cpp"
...
...
src/kernel/WModule.cpp
View file @
e4a1f5af
...
...
@@ -43,6 +43,8 @@
#include "exceptions/WModuleUninitialized.h"
#include "../common/WException.h"
#include "../common/WLogger.h"
#include "../common/WCondition.h"
#include "../common/WConditionOneShot.h"
#include "WModule.h"
...
...
@@ -50,11 +52,16 @@ WModule::WModule():
WThreadedRunner
(),
m_initialized
(
new
WCondition
(),
false
),
m_isAssociated
(
new
WCondition
(),
false
),
m_isUsable
(
new
WCondition
(),
false
)
m_isUsable
(
new
WCondition
(),
false
),
m_isReady
(
new
WConditionOneShot
(),
false
),
m_moduleState
()
{
// initialize members
m_properties
=
boost
::
shared_ptr
<
WProperties
>
(
new
WProperties
()
);
m_container
=
boost
::
shared_ptr
<
WModuleContainer
>
();
// our internal state consist out of two conditions: data changed and the exit flag from WThreadedRunner.
m_moduleState
.
add
(
m_shutdownFlag
.
getCondition
()
);
}
WModule
::~
WModule
()
...
...
@@ -249,13 +256,10 @@ boost::shared_ptr< WProperties > WModule::getProperties() const
void
WModule
::
ready
()
{
m_isReady
(
true
);
signal_ready
(
shared_from_this
()
);
}
void
WModule
::
connectToGui
()
{
}
void
WModule
::
threadMain
()
{
#ifdef __linux__
...
...
src/kernel/WModule.h
View file @
e4a1f5af
...
...
@@ -45,6 +45,7 @@
#include "../common/WLogger.h"
#include "../common/WProperties.h"
#include "../common/WThreadedRunner.h"
#include "../common/WConditionSet.h"
class
WModuleConnector
;
class
WModuleInputConnector
;
...
...
@@ -143,12 +144,6 @@ public:
*/
virtual
boost
::
shared_ptr
<
WModule
>
factory
()
const
=
0
;
/**
* Takes all the relevant GUI signals and connects them to own member functions.
* NOTE: this is only temporal. See ticket 142.
*/
virtual
void
connectToGui
();
/**
* Connects a specified notify function with a signal this module instance is offering.
*
...
...
@@ -356,6 +351,16 @@ protected:
*/
WBoolFlag
m_isUsable
;
/**
* True if ready() was called.
*/
WBoolFlag
m_isReady
;
/**
* The internal state of the module. This is, by default, simply the exit flag from WThreadedRunner.
*/
WConditionSet
m_moduleState
;
/**
* The container this module belongs to.
*/
...
...
src/kernel/WModuleContainer.cpp
View file @
e4a1f5af
...
...
@@ -100,9 +100,6 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
}
slock
.
unlock
();
// TODO(ebaum,schurade): this should be removes some days
module
->
connectToGui
();
// run it
if
(
run
)
{
...
...
@@ -131,6 +128,8 @@ void WModuleContainer::remove( boost::shared_ptr< WModule > module )
lock
.
unlock
();
module
->
setAssociatedContainer
(
boost
::
shared_ptr
<
WModuleContainer
>
()
);
// TODO(ebaum): remove signal subscriptions
// TODO(ebaum): flat or deep removal? What to do with associated modules?
}
...
...
src/kernel/test/WModuleConnector_test.h
View file @
e4a1f5af
...
...
@@ -233,14 +233,6 @@ public:
return
"testdesc"
;
}
/**
* Connect anything to GUI.
*/
virtual
void
connectToGui
()
{
// do nothing here
}
/**
* Set up connectors.
*/
...
...
src/modules/coordinateSystem/WMCoordinateSystem.cpp
View file @
e4a1f5af
...
...
@@ -48,6 +48,9 @@ boost::shared_ptr< WModule > WMCoordinateSystem::factory() const
void
WMCoordinateSystem
::
moduleMain
()
{
// signal ready state
ready
();
createGeometry
();
// Since the modules run in a separate thread: wait
...
...
@@ -68,12 +71,6 @@ const std::string WMCoordinateSystem::getDescription() const
return
"This module displays coordinate systems as overlay withn the main 3D view."
;
}
void
WMCoordinateSystem
::
connectToGui
()
{
WKernel
::
getRunningKernel
()
->
getGui
()
->
connectProperties
(
m_properties
);
WKernel
::
getRunningKernel
()
->
getGui
()
->
addModuleToBrowser
(
shared_from_this
()
);
}
void
WMCoordinateSystem
::
properties
()
{
m_properties
->
addBool
(
"dataSetAdded"
,
false
,
true
);
...
...
src/modules/coordinateSystem/WMCoordinateSystem.h
View file @
e4a1f5af
...
...
@@ -72,12 +72,6 @@ public:
*/
virtual
const
std
::
string
getDescription
()
const
;
/**
* Connect the listener function of the module to the gui signals
* this has to be called after full initialization fo the gui
*/
void
connectToGui
();
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
...
...
src/modules/distanceMap/WMDistanceMap.cpp
View file @
e4a1f5af
...
...
@@ -66,6 +66,9 @@ const std::string WMDistanceMap::getDescription() const
void
WMDistanceMap
::
moduleMain
()
{
// signal ready state
ready
();
// TODO(wiebel): MC fix this hack when possible by using an input connector.
while
(
!
WKernel
::
getRunningKernel
()
)
{
...
...
@@ -88,7 +91,6 @@ void WMDistanceMap::moduleMain()
boost
::
shared_ptr
<
WValueSet
<
float
>
>
distanceMapValueSet
=
createOffset
(
dataSet
);
boost
::
shared_ptr
<
WMMarchingCubes
>
mc
=
boost
::
shared_ptr
<
WMMarchingCubes
>
(
new
WMMarchingCubes
()
);
mc
->
connectToGui
();
mc
->
generateSurface
(
dataSet
->
getGrid
(),
distanceMapValueSet
,
.4
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Rendering surface ..."
,
"Distance Map"
,
LL_INFO
);
...
...
src/modules/eegTest/WMEEGTest.cpp
View file @
e4a1f5af
...
...
@@ -106,6 +106,9 @@ void drawChannel( boost::shared_ptr< const WEEG > eegData, size_t channelId, osg
void
WMEEGTest
::
moduleMain
()
{
// signal ready state
ready
();
// load the sample scene.
//osg::Geode* sceneDataGeode = new osg::Geode();
...
...
src/modules/fiberClustering/WMFiberClustering.cpp
View file @
e4a1f5af
...
...
@@ -74,6 +74,9 @@ boost::shared_ptr< WModule > WMFiberClustering::factory() const
void
WMFiberClustering
::
moduleMain
()
{
// signal ready state
ready
();
boost
::
shared_ptr
<
WDataHandler
>
dataHandler
;
// TODO(math): fix this hack when possible by using an input connector.
while
(
!
WKernel
::
getRunningKernel
()
)
...
...
src/modules/fiberCulling/WMFiberCulling.cpp
View file @
e4a1f5af
...
...
@@ -62,6 +62,9 @@ boost::shared_ptr< WModule > WMFiberCulling::factory() const
void
WMFiberCulling
::
moduleMain
()
{
// signal ready state
ready
();
boost
::
shared_ptr
<
WDataHandler
>
dataHandler
;
// TODO(math): fix this hack when possible by using an input connector.
while
(
!
WKernel
::
getRunningKernel
()
)
...
...
src/modules/fiberDisplay/WMFiberDisplay.cpp
View file @
e4a1f5af
...
...
@@ -94,14 +94,11 @@ osg::ref_ptr< osg::Geode > WMFiberDisplay::genFiberGeode( boost::shared_ptr< con
return
geode
;
}
void
WMFiberDisplay
::
connectToGui
()
{
WKernel
::
getRunningKernel
()
->
getGui
()
->
connectProperties
(
m_properties
);
WKernel
::
getRunningKernel
()
->
getGui
()
->
addModuleToBrowser
(
shared_from_this
()
);
}
void
WMFiberDisplay
::
moduleMain
()
{
// signal ready state
ready
();
// ready();
// while( !m_FinishRequested )
// {
...
...
src/modules/fiberDisplay/WMFiberDisplay.h
View file @
e4a1f5af
...
...
@@ -73,12 +73,6 @@ public:
*/
virtual
boost
::
shared_ptr
<
WModule
>
factory
()
const
;
/**
* Takes all the relevant GUI signals and connects them to own member functions.
* NOTE: this is only temporal. See ticket 142.
*/
virtual
void
connectToGui
();
protected:
/**
* Entry point after loading the module. Runs in separate thread.
...
...
src/modules/hud/WMHud.cpp
View file @
e4a1f5af
...
...
@@ -64,13 +64,11 @@ void WMHud::properties()
m_properties
->
addBool
(
"showHUD1"
,
false
);
}
void
WMHud
::
notifyDataChange
(
boost
::
shared_ptr
<
WModuleConnector
>
/*input*/
,
boost
::
shared_ptr
<
WModuleConnector
>
/*output*/
)
{
}
void
WMHud
::
moduleMain
()
{
// signal ready state
ready
();
init
();
// Since the modules run in a separate thread: wait
...
...
@@ -81,13 +79,6 @@ void WMHud::moduleMain()
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
removeChild
(
m_rootNode
);
}
void
WMHud
::
connectToGui
()
{
WKernel
::
getRunningKernel
()
->
getGui
()
->
connectProperties
(
m_properties
);
WKernel
::
getRunningKernel
()
->
getGui
()
->
addModuleToBrowser
(
shared_from_this
()
);
}
void
WMHud
::
init
()
{
m_rootNode
=
osg
::
ref_ptr
<
osg
::
Projection
>
(
new
osg
::
Projection
);
...
...
Prev
1
2
Next
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