OpenWalnut
1.5.0dev
|
OpenWalnut kernel, managing modules and interaction between UI, GE and DataHandler. More...
#include <WKernel.h>
Public Types | |
enum | KERNEL_SIGNAL { KERNEL_STARTUPCOMPLETE } |
Enum of all possible signals WKernel instances can emit. More... | |
typedef boost::function< void(void) > | t_KernelGenericSignalHandlerType |
Signal for generic events. More... | |
typedef boost::signals2::signal< void(void) > | t_KernelGenericSignalType |
Generic signal type used in the most signals. More... | |
Public Types inherited from WThreadedRunner | |
typedef std::shared_ptr< WThreadedRunner > | SPtr |
Abbreviation to a shared_ptr to this type. More... | |
typedef std::shared_ptr< const WThreadedRunner > | ConstSPtr |
Abbreviation to a const shared_ptr to this type. More... | |
typedef boost::function< void(void) > | THREADFUNCTION |
Type used for simple thread functions. More... | |
Public Member Functions | |
virtual | ~WKernel () |
Destructor. More... | |
boost::signals2::connection | subscribeSignal (KERNEL_SIGNAL signal, t_KernelGenericSignalHandlerType notifier) |
Subscribe to several signals. More... | |
void | finalize () |
Stops execution of the modules in the root container. More... | |
std::shared_ptr< WGraphicsEngine > | getGraphicsEngine () const |
Returns pointer to currently running instance of graphics engine. More... | |
const WBoolFlag & | isFinishRequested () const |
Determines whether all threads should finish. More... | |
WBatchLoader::SPtr | loadDataSets (std::vector< std::string > filenames, bool suppressColormaps=false) |
Load specified datasets. More... | |
WBatchLoader::SPtr | loadDataSetsSynchronously (std::vector< std::string > filenames, bool suppressColormaps=false) |
Loads the specified files synchronously. More... | |
std::shared_ptr< WModule > | applyModule (std::shared_ptr< WModule > applyOn, std::shared_ptr< WModule > prototype) |
Function combines to modules. More... | |
std::shared_ptr< WModuleContainer > | getRootContainer () const |
Returns the root module container. More... | |
std::shared_ptr< WUI > | getUI () const |
Getter for the associated UI. More... | |
std::shared_ptr< WROIManager > | getRoiManager () |
get for roi manager More... | |
std::shared_ptr< WSelectionManager > | getSelectionManager () |
get for selection manager More... | |
std::shared_ptr< WScriptEngine > | getScriptEngine () |
Get the script engine of this kernel. More... | |
WTimer::ConstSPtr | getTimer () const |
Returns the system timer. More... | |
virtual boost::signals2::connection | subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier) |
Connects a specified notify function with a signal this thread instance is offering. More... | |
Public Member Functions inherited from WThreadedRunner | |
WThreadedRunner () | |
Default constructor. More... | |
virtual | ~WThreadedRunner () |
Destructor. More... | |
virtual void | run () |
Run thread. More... | |
void | run (THREADFUNCTION f) |
Run thread. More... | |
void | wait (bool requestFinish=false) |
Wait for the thread to be finished. More... | |
virtual void | requestStop () |
This method's purpose is to request a stop without waiting for it. More... | |
virtual boost::signals2::connection | subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier) |
Connects a specified notify function with a signal this thread instance is offering. More... | |
const WBoolFlag & | isCrashed () const |
Checks whether this thread has been crashed. More... | |
const std::string & | getCrashMessage () const |
Get the message of the exception finally causing the crash. More... | |
void | setThreadName (std::string name) |
Set the name of the thread. More... | |
std::string | getThreadName () const |
Returns the current thread name. More... | |
Static Public Member Functions | |
static WKernel * | instance (std::shared_ptr< WGraphicsEngine > ge, std::shared_ptr< WUI > ui) |
Returns pointer to the running kernel or a new if no kernel was there. More... | |
static WKernel * | getRunningKernel () |
Returns pointer to the currently running kernel. More... | |
Static Public Member Functions inherited from WThreadedRunner | |
static void | setThisThreadName (std::string name) |
Static function to set the name of the calling thread. More... | |
Protected Member Functions | |
WKernel (std::shared_ptr< WGraphicsEngine > ge, std::shared_ptr< WUI > ui) | |
Constructor is protected because this class is a singleton. More... | |
virtual void | threadMain () |
Function that has to be overwritten for execution. More... | |
Protected Member Functions inherited from WThreadedRunner | |
virtual void | notifyStop () |
Gets called when the thread should be stopped. More... | |
void | yield () const |
Give remaining execution timeslice to another thread. More... | |
void | sleep (const int32_t t) const |
Sets thread asleep. More... | |
void | msleep (const int32_t t) const |
Sets thread asleep. More... | |
void | waitForStop () |
Let the thread sleep until a stop request was given. More... | |
virtual void | onThreadException (const WException &e) |
This method is called if an exception was caught, which came from the custom thread code. More... | |
void | handleDeadlyException (const WException &e, std::string sender="WThreadedRunner") |
Handle the specified exception which was not caught in the thread, which basically means the thread has crashed. More... | |
Protected Attributes | |
std::shared_ptr< WUI > | m_ui |
The UI. More... | |
std::shared_ptr< WGraphicsEngine > | m_graphicsEngine |
Pointer to an initialized graphics engine. More... | |
std::shared_ptr< WROIManager > | m_roiManager |
Pointer to a roi manager. More... | |
std::shared_ptr< WSelectionManager > | m_selectionManager |
pointer to a selection manager More... | |
std::shared_ptr< WModuleFactory > | m_moduleFactory |
The module factory to use. More... | |
std::shared_ptr< WModuleContainer > | m_moduleContainer |
The container containing the modules. More... | |
std::shared_ptr< WScriptEngine > | m_scriptEngine |
The script engine to use. More... | |
Protected Attributes inherited from WThreadedRunner | |
boost::thread | m_thread |
Thread instance. More... | |
WBoolFlag | m_shutdownFlag |
Condition getting fired whenever the thread should quit. More... | |
WBoolFlag | m_isCrashed |
True whenever an exception is thrown during threadMain. More... | |
std::string | m_crashMessage |
The crash message. More... | |
Private Member Functions | |
void | loadModules () |
Loads all the modules it can find. More... | |
void | init () |
Initializes the graphics engine, data handler and so on. More... | |
Private Attributes | |
WTimer::SPtr | m_timer |
The ow system timer. More... | |
WConditionOneShot | m_startupCompleted |
Notified when the startup, including GE and UI has been completed. More... | |
Static Private Attributes | |
static WKernel * | m_kernel = NULL |
Pointer to the unique instance of this singleton class. More... | |
OpenWalnut kernel, managing modules and interaction between UI, GE and DataHandler.
typedef boost::function< void ( void ) > WKernel::t_KernelGenericSignalHandlerType |
typedef boost::signals2::signal< void ( void ) > WKernel::t_KernelGenericSignalType |
|
virtual |
Destructor.
Definition at line 76 of file WKernel.cpp.
References WLogger::addLogMessage(), and WLogger::getLogger().
|
protected |
Constructor is protected because this class is a singleton.
Awaits an INITIALIZED graphics engine an UI.
ge | initialized graphics engine. |
ui | initialized UI. |
Definition at line 56 of file WKernel.cpp.
References WLogger::addLogMessage(), wlog::debug(), WLogger::getLogger(), init(), m_graphicsEngine, m_kernel, m_ui, and WThreadedRunner::setThreadName().
Referenced by instance().
std::shared_ptr< WModule > WKernel::applyModule | ( | std::shared_ptr< WModule > | applyOn, |
std::shared_ptr< WModule > | prototype | ||
) |
Function combines to modules.
This is a simple alias for "getRootContainer()->applyModule". It runs synchronously, which could freeze the calling thread for a couple of time.
applyOn | the module which already has to be in the container and to apply the other one on. |
prototype | the prototype of the module to apply on the other one specified. |
Definition at line 204 of file WKernel.cpp.
References getRootContainer().
void WKernel::finalize | ( | ) |
Stops execution of the modules in the root container.
Note that this does not wait for the kernel thread since this could cause a dead lock. This is actually an alias for getRootContainer()->stop().
Definition at line 137 of file WKernel.cpp.
References WLogger::addLogMessage(), WDataHandler::getDataHandler(), WLogger::getLogger(), and getRootContainer().
Referenced by WMainWindow::closeStage1Thread().
std::shared_ptr< WGraphicsEngine > WKernel::getGraphicsEngine | ( | ) | const |
Returns pointer to currently running instance of graphics engine.
Definition at line 122 of file WKernel.cpp.
References m_graphicsEngine.
Referenced by WOnscreenSelection::brushCheck(), WMArbitraryROIs::cleanup(), WQtGLWidget::cleanUp(), WMCoordinateSystem::createGeometry(), WMPointConnector::createHandler(), WSelectionManager::getFrontSector(), WMPointConnector::handleClickSelection(), WMDatasetProfile::init(), WMArbitraryPlane::initPlane(), WMClusterDisplay::initWidgets(), WMClusterDisplayVoxels::initWidgets(), WMHierchClustDisplay::initWidgets(), WOnscreenSelection::isSelected(), WMArbitraryPlane::moduleMain(), WMButterfly::moduleMain(), WMClusterDisplay::moduleMain(), WMClusterDisplayVoxels::moduleMain(), WMColormapper::moduleMain(), WMCoordinateSystem::moduleMain(), WMDatasetProfile::moduleMain(), WMDirectVolumeRendering::moduleMain(), WMEEGView::moduleMain(), WMEffectiveConnectivityCluster::moduleMain(), WMFiberDisplay::moduleMain(), WMHierchClustDisplay::moduleMain(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), WMIsosurface::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMNavigationSlices::moduleMain(), WMPaintTexture::moduleMain(), WMPickingDVR::moduleMain(), WMPointConnector::moduleMain(), WMPointRenderer::moduleMain(), WMProjectionsAsContext::moduleMain(), WMSplineSurface::moduleMain(), WMSuperquadricGlyphs::moduleMain(), WMSurfaceIllustrator::moduleMain(), WMSurfaceParameterAnimator::moduleMain(), WMTeemGlyphs::moduleMain(), WMTemplate::moduleMain(), WMTemplateColormapping::moduleMain(), WMTemplateRenderPipelines::moduleMain(), WMTemplateShaders::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WMTriangleMeshRenderer::moduleMain(), WMVectorPlot::moduleMain(), WMVoxelizer::moduleMain(), WQtGLWidget::paintEvent(), WMEEGView::redraw(), WMArbitraryROIs::renderMesh(), WMSplineSurface::renderMesh(), WMTeemGlyphs::renderSlice(), WQtGui::run(), WSelectionManager::setPaintMode(), WMDatasetProfile::update(), WOnscreenSelection::updateDisplay(), WMClusterDisplay::updateWidgets(), WMClusterDisplayVoxels::updateWidgets(), WMHierchClustDisplay::updateWidgets(), WOnscreenSelection::WOnscreenSelection(), WQtGLWidget::WQtGLWidget(), and WOnscreenSelection::~WOnscreenSelection().
std::shared_ptr< WROIManager > WKernel::getRoiManager | ( | ) |
get for roi manager
Definition at line 209 of file WKernel.cpp.
References m_roiManager.
Referenced by WQtControlPanel::addRoi(), WMPaintTexture::createROI(), WQtControlPanel::deleteROITreeItem(), WRoiProjectFileIO::done(), WMArbitraryROIs::finalizeROI(), WMClusterDisplay::handleRoiChanged(), WQtControlPanel::handleRoiDragDrop(), WMClusterDisplay::moduleMain(), WMEEGView::moduleMain(), WMainWindow::newRoi(), WQtControlPanel::removeRoi(), WRoiProjectFileIO::save(), WQtControlPanel::selectRoiTreeItem(), WFiberSelector::slotAddRoi(), WFiberSelector::WFiberSelector(), and WFiberSelector::~WFiberSelector().
std::shared_ptr< WModuleContainer > WKernel::getRootContainer | ( | ) | const |
Returns the root module container.
This is the actual module graph container.
Definition at line 127 of file WKernel.cpp.
References m_moduleContainer.
Referenced by applyModule(), WQtControlPanel::createCompatibleButtons(), WQtControlPanel::deleteModule(), finalize(), WProjectFile::load(), loadDataSets(), loadDataSetsSynchronously(), WMainWindow::newProject(), WProjectFile::onThreadException(), WModuleProjectFileCombiner::save(), WQtNetworkEditorProjectFileIO::save(), and WProjectFile::threadMain().
|
static |
Returns pointer to the currently running kernel.
Definition at line 117 of file WKernel.cpp.
References m_kernel.
Referenced by WQtControlPanel::addRoi(), WMainWindow::autoAdd(), WOnscreenSelection::brushCheck(), WMVectorPlot::buildPlotSlices(), WMArbitraryROIs::cleanup(), WQtGLWidget::cleanUp(), WMainWindow::closeStage1Thread(), WQtControlPanel::createCompatibleButtons(), WMCoordinateSystem::createGeometry(), WMPointConnector::createHandler(), WMPaintTexture::createROI(), WMClusterDisplayVoxels::createTexture(), WQtControlPanel::deleteModule(), WQtControlPanel::deleteROITreeItem(), WRoiProjectFileIO::done(), WMArbitraryROIs::finalizeROI(), WSelectionManager::getFrontSector(), WMPointConnector::handleClickSelection(), WMClusterDisplay::handleRoiChanged(), WQtControlPanel::handleRoiDragDrop(), WMDatasetProfile::init(), WMArbitraryPlane::initPlane(), WMHierchClustDisplay::initTexture(), WMClusterDisplay::initWidgets(), WMClusterDisplayVoxels::initWidgets(), WMHierchClustDisplay::initWidgets(), WUIRequirement::isComplied(), WOnscreenSelection::isSelected(), WProjectFile::load(), WMArbitraryPlane::moduleMain(), WMArbitraryROIs::moduleMain(), WMButterfly::moduleMain(), WMClusterDisplay::moduleMain(), WMClusterDisplayVoxels::moduleMain(), WMColormapper::moduleMain(), WMCoordinateSystem::moduleMain(), WMDatasetProfile::moduleMain(), WMDirectVolumeRendering::moduleMain(), WMEEGView::moduleMain(), WMEffectiveConnectivityCluster::moduleMain(), WMFiberDisplay::moduleMain(), WMHierchClustDisplay::moduleMain(), WMHistogramView::moduleMain(), WMMultiHistogramView::moduleMain(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), WMIsosurface::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMNavigationSlices::moduleMain(), WMPaintTexture::moduleMain(), WMPickingDVR::moduleMain(), WMPointConnector::moduleMain(), WMPointRenderer::moduleMain(), WMProjectionsAsContext::moduleMain(), WMSplineSurface::moduleMain(), WMSuperquadricGlyphs::moduleMain(), WMSurfaceIllustrator::moduleMain(), WMSurfaceParameterAnimator::moduleMain(), WMTeemGlyphs::moduleMain(), WMTemplate::moduleMain(), WMTemplateColormapping::moduleMain(), WMTemplateRenderPipelines::moduleMain(), WMTemplateShaders::moduleMain(), WMTemplateUI::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WMTriangleMeshRenderer::moduleMain(), WMVectorPlot::moduleMain(), WMVoxelizer::moduleMain(), WMainWindow::newProject(), WMainWindow::newRoi(), WProjectFile::onThreadException(), WMEEGView::openCustomWidget(), WMainWindow::openLoadDialog(), WQtGLWidget::paintEvent(), WMCoordinateSystem::properties(), WMNavigationSlices::properties(), WMOpenIGTLinkSender::properties(), WMEEGView::redraw(), WQtControlPanel::removeRoi(), WMArbitraryROIs::renderMesh(), WMSplineSurface::renderMesh(), WMTeemGlyphs::renderSlice(), WQtGui::run(), WScriptUI::run(), WModuleProjectFileCombiner::save(), WRoiProjectFileIO::save(), WQtNetworkEditorProjectFileIO::save(), WQtControlPanel::selectRoiTreeItem(), WQtGLWidget::setFitScreenPosition(), WSelectionManager::setPaintMode(), WMainWindow::setupGUI(), WFiberSelector::slotAddRoi(), WProjectFile::threadMain(), WMDatasetProfile::update(), WMArbitraryPlane::updateCallback(), WMCoordinateSystem::updateCallback(), WMDatasetProfile::updateCallback(), WMVectorPlot::updateCallback(), WOnscreenSelection::updateDisplay(), WMArbitraryPlane::updatePlane(), WMClusterDisplay::updateWidgets(), WMClusterDisplayVoxels::updateWidgets(), WMHierchClustDisplay::updateWidgets(), WFiberSelector::WFiberSelector(), WOnscreenSelection::WOnscreenSelection(), WQtGLWidget::WQtGLWidget(), WFiberSelector::~WFiberSelector(), and WOnscreenSelection::~WOnscreenSelection().
std::shared_ptr< WScriptEngine > WKernel::getScriptEngine | ( | ) |
Get the script engine of this kernel.
Definition at line 219 of file WKernel.cpp.
References m_scriptEngine.
Referenced by WMainWindow::openLoadDialog(), and WScriptUI::run().
std::shared_ptr< WSelectionManager > WKernel::getSelectionManager | ( | ) |
get for selection manager
Definition at line 214 of file WKernel.cpp.
References m_selectionManager.
Referenced by WMVectorPlot::buildPlotSlices(), WMClusterDisplayVoxels::createTexture(), WMDatasetProfile::init(), WMArbitraryPlane::initPlane(), WMHierchClustDisplay::initTexture(), WMArbitraryPlane::moduleMain(), WMArbitraryROIs::moduleMain(), WMDatasetProfile::moduleMain(), WMPaintTexture::moduleMain(), WMainWindow::newRoi(), WMCoordinateSystem::properties(), WMArbitraryPlane::updateCallback(), WMCoordinateSystem::updateCallback(), WMDatasetProfile::updateCallback(), and WMVectorPlot::updateCallback().
WTimer::ConstSPtr WKernel::getTimer | ( | ) | const |
Returns the system timer.
If you need timing for animations and similar, use this one. This timer can change to frame based timing if the user plays back some animation. So, everything which uses this timer can always do accurate per-frame animations even if frame time and real-time differ.
Definition at line 224 of file WKernel.cpp.
References m_timer.
std::shared_ptr< WUI > WKernel::getUI | ( | ) | const |
Getter for the associated UI.
Definition at line 132 of file WKernel.cpp.
References m_ui.
Referenced by WUIRequirement::isComplied(), WMHistogramView::moduleMain(), WMMultiHistogramView::moduleMain(), WMTemplateUI::moduleMain(), and WMEEGView::openCustomWidget().
|
private |
Initializes the graphics engine, data handler and so on.
Definition at line 92 of file WKernel.cpp.
References WDataHandler::getDataHandler(), WModuleFactory::getModuleFactory(), m_moduleContainer, m_moduleFactory, m_roiManager, m_scriptEngine, and m_selectionManager.
Referenced by WKernel().
|
static |
Returns pointer to the running kernel or a new if no kernel was there.
If a running kernel exists the function return it and does not check if GE and UI of the running kernel are equivalent to the ones given as parameters.
ge | initialized graphics engine. |
ui | initialized ui. |
Definition at line 82 of file WKernel.cpp.
References m_kernel, and WKernel().
Referenced by WQtGui::run(), and WScriptUI::run().
const WBoolFlag & WKernel::isFinishRequested | ( | ) | const |
Determines whether all threads should finish.
Definition at line 189 of file WKernel.cpp.
References WThreadedRunner::m_shutdownFlag.
WBatchLoader::SPtr WKernel::loadDataSets | ( | std::vector< std::string > | filenames, |
bool | suppressColormaps = false |
||
) |
Load specified datasets.
It immediately returns and starts another thread, which actually loads the data.
filenames | list of filenames to load. The registered notification handler for the root container will get notified on error and success. |
suppressColormaps | if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you combine multiple data loaders into one new data loader or data set |
Definition at line 194 of file WKernel.cpp.
References getRootContainer().
Referenced by WQtGui::run().
WBatchLoader::SPtr WKernel::loadDataSetsSynchronously | ( | std::vector< std::string > | filenames, |
bool | suppressColormaps = false |
||
) |
Loads the specified files synchronously.
filenames | list of filenames to load. The registered notification handler for the root container will get notified on error and success. |
suppressColormaps | if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you combine multiple data loaders into one new data loader or data set |
Definition at line 199 of file WKernel.cpp.
References getRootContainer().
Referenced by WQtGui::run().
|
private |
Loads all the modules it can find.
boost::signals2::connection WKernel::subscribeSignal | ( | WKernel::KERNEL_SIGNAL | signal, |
WKernel::t_KernelGenericSignalHandlerType | notifier | ||
) |
Subscribe to several signals.
signal | the signal to subscribe |
notifier | the notifier to call |
Definition at line 229 of file WKernel.cpp.
References m_startupCompleted, and WCondition::subscribeSignal().
boost::signals2::connection WThreadedRunner::subscribeSignal |
Connects a specified notify function with a signal this thread instance is offering.
WSignalSubscriptionFailed | thrown if the signal can't be connected. |
signal | the signal to connect to. |
notifier | the notifier function to bind. |
Definition at line 105 of file WThreadedRunner.cpp.
|
protectedvirtual |
Function that has to be overwritten for execution.
It gets executed in a separate thread after run() has been called.
Reimplemented from WThreadedRunner.
Definition at line 148 of file WKernel.cpp.
References WLogger::addLogMessage(), WLogger::getLogger(), WModuleFactory::getModuleLoader(), wlog::info(), m_graphicsEngine, m_startupCompleted, m_ui, WConditionOneShot::notify(), WThreadedRunner::waitForStop(), and wlog::warn().
|
protected |
Pointer to an initialized graphics engine.
Definition at line 241 of file WKernel.h.
Referenced by getGraphicsEngine(), threadMain(), and WKernel().
|
staticprivate |
Pointer to the unique instance of this singleton class.
Used for program wide access to the kernel.
Definition at line 282 of file WKernel.h.
Referenced by getRunningKernel(), instance(), and WKernel().
|
protected |
The container containing the modules.
Definition at line 261 of file WKernel.h.
Referenced by getRootContainer(), and init().
|
protected |
|
protected |
Pointer to a roi manager.
Definition at line 246 of file WKernel.h.
Referenced by getRoiManager(), and init().
|
protected |
The script engine to use.
Definition at line 266 of file WKernel.h.
Referenced by getScriptEngine(), and init().
|
protected |
pointer to a selection manager
Definition at line 251 of file WKernel.h.
Referenced by getSelectionManager(), and init().
|
private |
Notified when the startup, including GE and UI has been completed.
Definition at line 292 of file WKernel.h.
Referenced by subscribeSignal(), and threadMain().
|
private |
|
protected |
The UI.
Definition at line 236 of file WKernel.h.
Referenced by getUI(), threadMain(), and WKernel().