Commit 3f6158f3 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixed various issues:

* Fixed deadlock in VolumeRenderer when changing the RaycastingProcessor
* Fixed compile error in ITK module
* Fixed some gcc warnings
* Fixed usage of deprecated ScopedSynchronousGlJobExecution in mainwindow.cpp
parent 6a9c4ca7
...@@ -460,8 +460,9 @@ namespace campvis { ...@@ -460,8 +460,9 @@ namespace campvis {
void MainWindow::onLuaCommandExecuted(const QString& cmd) { void MainWindow::onLuaCommandExecuted(const QString& cmd) {
#ifdef CAMPVIS_HAS_SCRIPTING #ifdef CAMPVIS_HAS_SCRIPTING
if (_application->getLuaVmState() != nullptr) { if (_application->getLuaVmState() != nullptr) {
cgt::OpenGLJobProcessor::ScopedSynchronousGlJobExecution jobGuard; GLJobProc.enqueueJobBlocking([&]() {
_application->getLuaVmState()->execString(cmd.toStdString()); _application->getLuaVmState()->execString(cmd.toStdString());
});
_application->getLuaVmState()->getGlobalTable()->updateValueMap(); _application->getLuaVmState()->getGlobalTable()->updateValueMap();
_scriptingConsoleWidget->_editCommand->setCompleter(new LuaCompleter(_application->getLuaVmState(), _scriptingConsoleWidget->_editCommand)); _scriptingConsoleWidget->_editCommand->setCompleter(new LuaCompleter(_application->getLuaVmState(), _scriptingConsoleWidget->_editCommand));
......
...@@ -133,6 +133,10 @@ namespace campvis { ...@@ -133,6 +133,10 @@ namespace campvis {
template<class T> template<class T>
campvis::GenericGeometryTransferFunction<T>::~GenericGeometryTransferFunction() { campvis::GenericGeometryTransferFunction<T>::~GenericGeometryTransferFunction() {
for (typename std::vector<T*>::iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
delete *it;
}
_geometries.clear();
} }
template<class T> template<class T>
...@@ -163,17 +167,15 @@ namespace campvis { ...@@ -163,17 +167,15 @@ namespace campvis {
for (typename std::vector<T*>::iterator it = _geometries.begin(); it != _geometries.end(); ++it) { for (typename std::vector<T*>::iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
(*it)->s_changed.disconnect(this); (*it)->s_changed.disconnect(this);
delete *it;
} }
_geometries.clear();
if (_fbo != 0) { if (_fbo != nullptr) {
delete _fbo; delete _fbo;
_fbo = 0; _fbo = nullptr;
} }
ShdrMgr.dispose(_shader); ShdrMgr.dispose(_shader);
_shader = 0; _shader = nullptr;
AbstractTransferFunction::deinit(); AbstractTransferFunction::deinit();
} }
......
...@@ -108,21 +108,27 @@ namespace cgt { ...@@ -108,21 +108,27 @@ namespace cgt {
_evaluationCondition.notify_all(); _evaluationCondition.notify_all();
} }
void OpenGLJobProcessor::setContext(cgt::GLCanvas* context) { void OpenGLJobProcessor::enqueueJob(std::function<void(void)> fn) {
cgtAssert(_context == nullptr, "You are trying to change an already set context, thou shalt not do that!"); enqueueJob(cgt::makeJobOnHeap([fn]() { fn(); }));
_context = context;
}
cgt::GLCanvas* OpenGLJobProcessor::getContext() {
return _context;
} }
void OpenGLJobProcessor::enqueueJobBlocking(std::function<void(void)> fn) { void OpenGLJobProcessor::enqueueJobBlocking(std::function<void(void)> fn) {
char signalVariable = 0; char signalVariable = 0;
enqueueJob(cgt::makeJobOnHeap([&signalVariable, fn]() { fn(); signalVariable = 1; })); enqueueJob(cgt::makeJobOnHeap([&signalVariable, fn]() { fn(); signalVariable = 1; }));
while (signalVariable == 0) while (signalVariable == 0) {
_evaluationCondition.notify_all();
std::this_thread::yield(); std::this_thread::yield();
}
}
void OpenGLJobProcessor::setContext(cgt::GLCanvas* context) {
cgtAssert(_context == nullptr, "You are trying to change an already set context, thou shalt not do that!");
_context = context;
}
cgt::GLCanvas* OpenGLJobProcessor::getContext() {
return _context;
} }
} }
......
...@@ -103,11 +103,19 @@ namespace cgt { ...@@ -103,11 +103,19 @@ namespace cgt {
*/ */
void enqueueJob(AbstractJob* job); void enqueueJob(AbstractJob* job);
/**
* Enqueues the given job.
*
* \note OpenGLJobProcessor takes ownership of \a job.
* \param jfn Functor defining job to execute.
*/
void enqueueJob(std::function<void(void)> fn);
/** /**
* Enqueues the given job and blockes the execution until the job has been processed. * Enqueues the given job and blockes the execution until the job has been processed.
* *
* \note OpenGLJobProcessor takes ownership of \a job. * \note OpenGLJobProcessor takes ownership of \a job.
* \param fn Functor defining job to execute! * \param fn Functor defining job to execute.
*/ */
void enqueueJobBlocking(std::function<void(void)> fn); void enqueueJobBlocking(std::function<void(void)> fn);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "qtcanvas.h" #include "qtcanvas.h"
#include <QThread> #include <QThread>
#include <QOpenGLContext>
namespace cgt { namespace cgt {
...@@ -40,8 +39,8 @@ QtCanvas::QtCanvas(const std::string& title, ...@@ -40,8 +39,8 @@ QtCanvas::QtCanvas(const std::string& title,
const ivec2& size, const ivec2& size,
const Buffers buffers, const Buffers buffers,
QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/) QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
: GLCanvas(title, size, buffers) : QGLWidget(getQGLFormat(buffers), 0, (shared ? shareWidget_ : 0), f)
, QGLWidget(getQGLFormat(buffers), 0, (shared ? shareWidget_ : 0), f) , GLCanvas(title, size, buffers)
{ {
resize(size.x, size.y); resize(size.x, size.y);
if (shared && shareWidget_ == 0) if (shared && shareWidget_ == 0)
...@@ -68,8 +67,7 @@ QtCanvas::QtCanvas(const std::string& title, ...@@ -68,8 +67,7 @@ QtCanvas::QtCanvas(const std::string& title,
} }
QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/) QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
: GLCanvas() : QGLWidget(0, (shared ? shareWidget_ : 0), f)
, QGLWidget(0, (shared ? shareWidget_ : 0), f)
{ {
if (shared && shareWidget_ == 0) if (shared && shareWidget_ == 0)
shareWidget_ = this; shareWidget_ = this;
......
...@@ -34,8 +34,10 @@ namespace campvis { ...@@ -34,8 +34,10 @@ namespace campvis {
return nullptr; return nullptr;
if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(source)) { if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(source)) {
cgt::OpenGLJobProcessor::ScopedSynchronousGlJobExecution jobGuard; ImageRepresentationGL* toReturn = nullptr;
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer()); GLJobProc.enqueueJobBlocking([&]() {
toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
});
return toReturn; return toReturn;
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
// //
// ================================================================================================ // ================================================================================================
#ifdef CAMPVIS_HAS_MODULE_DEVIL
#include "ssimdemo.h" #include "ssimdemo.h"
#include "cgt/glcontextmanager.h" #include "cgt/glcontextmanager.h"
...@@ -161,4 +163,6 @@ namespace campvis { ...@@ -161,4 +163,6 @@ namespace campvis {
_currentlyBatchProcessing = false; _currentlyBatchProcessing = false;
} }
} }
\ No newline at end of file
#endif // CAMPVIS_HAS_MODULE_DEVIL
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#ifndef SSIMDEMO_H__ #ifndef SSIMDEMO_H__
#define SSIMDEMO_H__ #define SSIMDEMO_H__
#ifdef CAMPVIS_HAS_MODULE_DEVIL
#include "core/tools/glreduction.h" #include "core/tools/glreduction.h"
#include "core/pipeline/autoevaluationpipeline.h" #include "core/pipeline/autoevaluationpipeline.h"
...@@ -77,4 +79,5 @@ namespace campvis { ...@@ -77,4 +79,5 @@ namespace campvis {
}; };
} }
#endif //CAMPVIS_HAS_MODULE_DEVIL
#endif // SSIMDEMO_H__ #endif // SSIMDEMO_H__
...@@ -45,7 +45,10 @@ namespace campvis { ...@@ -45,7 +45,10 @@ namespace campvis {
// explicitly instantiate templates to register the pipelines // explicitly instantiate templates to register the pipelines
template class PipelineRegistrar<MorphologyDemo>; template class PipelineRegistrar<MorphologyDemo>;
template class PipelineRegistrar<ResamplingDemo>; template class PipelineRegistrar<ResamplingDemo>;
#ifdef CAMPVIS_HAS_MODULE_DEVIL
template class PipelineRegistrar<SsimDemo>; template class PipelineRegistrar<SsimDemo>;
#endif
template class SmartProcessorRegistrar<GlGaussianFilter>; template class SmartProcessorRegistrar<GlGaussianFilter>;
template class SmartProcessorRegistrar<GlGradientVolumeGenerator>; template class SmartProcessorRegistrar<GlGradientVolumeGenerator>;
......
...@@ -238,21 +238,22 @@ namespace campvis { ...@@ -238,21 +238,22 @@ namespace campvis {
GLJobProc.enqueueJobBlocking([&]() { GLJobProc.enqueueJobBlocking([&]() {
_raycaster->init(); _raycaster->init();
_raycaster->p_sourceImageID.setValue(currentRaycaster->p_sourceImageID.getValue());
_raycaster->p_entryImageID.setValue(currentRaycaster->p_entryImageID.getValue());
_raycaster->p_exitImageID.setValue(currentRaycaster->p_exitImageID.getValue());
_raycaster->p_targetImageID.setValue(currentRaycaster->p_targetImageID.getValue());
_raycaster->p_camera.setValue(currentRaycaster->p_camera.getValue());
_raycaster->p_transferFunction.replaceTF(currentRaycaster->p_transferFunction.getTF()->clone());
_raycaster->p_jitterStepSizeMultiplier.setValue(currentRaycaster->p_jitterStepSizeMultiplier.getValue());
_raycaster->p_samplingRate.setValue(currentRaycaster->p_samplingRate.getValue());
currentRaycaster->deinit(); currentRaycaster->deinit();
}); });
invalidate(PG_INVALID | EEP_INVALID | RAYCASTER_INVALID | AbstractProcessor::INVALID_RESULT); _raycaster->p_sourceImageID.setValue(currentRaycaster->p_sourceImageID.getValue());
_raycaster->p_entryImageID.setValue(currentRaycaster->p_entryImageID.getValue());
_raycaster->p_exitImageID.setValue(currentRaycaster->p_exitImageID.getValue());
_raycaster->p_targetImageID.setValue(currentRaycaster->p_targetImageID.getValue());
_raycaster->p_camera.setValue(currentRaycaster->p_camera.getValue());
_raycaster->p_transferFunction.replaceTF(currentRaycaster->p_transferFunction.getTF()->clone());
_raycaster->p_jitterStepSizeMultiplier.setValue(currentRaycaster->p_jitterStepSizeMultiplier.getValue());
_raycaster->p_samplingRate.setValue(currentRaycaster->p_samplingRate.getValue());
delete currentRaycaster; delete currentRaycaster;
invalidate(PG_INVALID | EEP_INVALID | RAYCASTER_INVALID | AbstractProcessor::INVALID_RESULT);
} }
VisualizationProcessor::onPropertyChanged(prop); VisualizationProcessor::onPropertyChanged(prop);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment