Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 99b5c682 authored by schultezub's avatar schultezub
Browse files

* fixed duplicate members in NumericProperty

* Introducing SimpleJobProcessor for dispatching non-OpenGL-related jobs

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@445 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent e8bee9d5
......@@ -46,6 +46,7 @@
#include "application/campvispainter.h"
#include "application/gui/mainwindow.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/simplejobprocessor.h"
#include "core/tools/quadrenderer.h"
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/visualizationpipeline.h"
......@@ -71,6 +72,7 @@ namespace campvis {
tgt::QtContextManager::init();
OpenGLJobProcessor::init();
SimpleJobProcessor::init();
}
CampVisApplication::~CampVisApplication() {
......@@ -189,6 +191,7 @@ namespace campvis {
#endif
}
SimpleJobProcessor::deinit();
OpenGLJobProcessor::deinit();
tgt::QtContextManager::deinit();
......
......@@ -189,7 +189,7 @@ namespace campvis {
}
void TumVisPainter::onRenderTargetChanged() {
GLJobProc.enqueueJob(getCanvas(), make_job(this, &TumVisPainter::paint), OpenGLJobProcessor::PaintJob);
GLJobProc.enqueueJob(getCanvas(), makeJobOnHeap(this, &TumVisPainter::paint), OpenGLJobProcessor::PaintJob);
}
void TumVisPainter::setCanvas(tgt::GLCanvas* canvas) {
......
......@@ -181,7 +181,7 @@ namespace campvis {
}
void DataContainerInspectorCanvas::invalidate() {
GLJobProc.enqueueJob(this, make_job(this, &DataContainerInspectorCanvas::paint), OpenGLJobProcessor::PaintJob);
GLJobProc.enqueueJob(this, makeJobOnHeap(this, &DataContainerInspectorCanvas::paint), OpenGLJobProcessor::PaintJob);
}
void DataContainerInspectorCanvas::createQuad() {
......
......@@ -225,7 +225,7 @@ namespace campvis {
}
void Geometry1DTransferFunctionEditor::invalidate() {
GLJobProc.enqueueJob(_canvas, make_job(this, &Geometry1DTransferFunctionEditor::paint), OpenGLJobProcessor::PaintJob);
GLJobProc.enqueueJob(_canvas, makeJobOnHeap(this, &Geometry1DTransferFunctionEditor::paint), OpenGLJobProcessor::PaintJob);
}
void Geometry1DTransferFunctionEditor::setupGUI() {
......
......@@ -211,7 +211,7 @@ namespace campvis {
}
void Geometry2DTransferFunctionEditor::invalidate() {
GLJobProc.enqueueJob(_canvas, make_job(this, &Geometry2DTransferFunctionEditor::paint), OpenGLJobProcessor::PaintJob);
GLJobProc.enqueueJob(_canvas, makeJobOnHeap(this, &Geometry2DTransferFunctionEditor::paint), OpenGLJobProcessor::PaintJob);
}
void Geometry2DTransferFunctionEditor::setupGUI() {
......
......@@ -124,7 +124,9 @@ IF(WIN32)
SET(TGT_WITH_WMI TRUE) #< enable Windows Management Instrumentation for hardware detection
ENDIF()
IF(CAMPVIS_DEBUG)
# SET_PROPERTY(GLOBAL PROPERTY COMPILE_DEFINITIONS_DEBUG TGT_DEBUG CAMPVIS_DEBUG)
LIST(APPEND CampvisGlobalDefinitions -DTGT_DEBUG -DCAMPVIS_DEBUG)
# set_property(GLOBAL PROPERTY COMPILE_DEFINITIONS_DEBUG "TGT_DEBUG CAMPVIS_DEBUG")
ENDIF()
# minimum Qt version
......
......@@ -100,6 +100,7 @@ namespace campvis {
if (processor->getEnabled() && !processor->getInvalidationLevel().isValid()) {
processor->lockProperties();
processor->setEnabled(false); // TODO: dirty hack to avoid multiple execution of the same processor -> introduce s.th. like _processor.isLocked()
#ifdef CAMPVIS_DEBUG
clock_t startTime = clock();
#endif
......@@ -107,6 +108,7 @@ namespace campvis {
#ifdef CAMPVIS_DEBUG
clock_t endTime = clock();
#endif
processor->setEnabled(true);
processor->unlockProperties();
#ifdef CAMPVIS_DEBUG
......
......@@ -99,7 +99,7 @@ namespace campvis {
tgtAssert(_canvas != 0, "Set a valid canvas before calling this method!");
GLJobProc.enqueueJob(
_canvas,
make_job<VisualizationPipeline, AbstractProcessor*>(this, &VisualizationPipeline::executeProcessor, processor),
makeJobOnHeap<VisualizationPipeline, AbstractProcessor*>(this, &VisualizationPipeline::executeProcessor, processor),
OpenGLJobProcessor::SerialJob);
}
......
......@@ -39,7 +39,7 @@ namespace campvis {
, _invalidationLevel(il)
{
_isVisible = true;
_inUse = false;
_inUse = 0;
}
AbstractProperty::~AbstractProperty() {
......@@ -80,11 +80,11 @@ namespace campvis {
}
void AbstractProperty::lock() {
_inUse = true;
++_inUse;
}
void AbstractProperty::unlock() {
_inUse = false;
--_inUse;
}
void AbstractProperty::init() {
......
......@@ -161,7 +161,7 @@ namespace campvis {
InvalidationLevel _invalidationLevel; ///< Invalidation level that this property triggers
tbb::atomic<bool> _isVisible; ///< Flag whether this property shall be visible in the GUI
tbb::atomic<bool> _inUse; ///< flag whether property is currently in use and values are written to back buffer
tbb::atomic<int> _inUse; ///< flag whether property is currently in use and values are written to back buffer
tbb::spin_mutex _localMutex; ///< Mutex used when altering local members
/**
......
......@@ -167,7 +167,7 @@ namespace campvis {
T vv = validateValue(value);
tbb::spin_mutex::scoped_lock lock(_localMutex);
if (_inUse)
if (_inUse != 0)
setBackValue(vv);
else {
setFrontValue(vv);
......@@ -181,7 +181,7 @@ namespace campvis {
if (_backBuffer != _value)
setFrontValue(_backBuffer);
_inUse = false;
AbstractProperty::unlock();
}
template<typename T>
......
......@@ -178,9 +178,6 @@ namespace campvis {
*/
virtual T validateValue(const T& value);
T _value; ///< value of the property
T _backBuffer; ///< back buffer for values when property is in use
T _minValue; ///< Minimum value for this property
T _maxValue; ///< Maximum value for this property
......@@ -247,25 +244,25 @@ namespace campvis {
template<typename T>
void campvis::NumericProperty<T>::setMinValue(const T& value) {
_minValue = value;
setValue(validateValue(getValue()));
setValue(validateValue(_value));
s_minMaxChanged(this);
}
template<typename T>
void campvis::NumericProperty<T>::setMaxValue(const T& value) {
_maxValue = value;
setValue(validateValue(getValue()));
setValue(validateValue(_value));
s_minMaxChanged(this);
}
template<typename T>
void campvis::NumericProperty<T>::increment() {
setValue(getValue() + T(1));
setValue(_value + T(1));
}
template<typename T>
void campvis::NumericProperty<T>::decrement() {
setValue(getValue() - T(1));
setValue(_value - T(1));
}
}
......
......@@ -197,12 +197,12 @@ namespace campvis {
template<typename T>
const GenericOption<T>& campvis::GenericOptionProperty<T>::getOption() const {
return _options[getValue()];
return _options[_value];
}
template<typename T>
T campvis::GenericOptionProperty<T>::getOptionValue() const {
return _options[getValue()]._value;
return _options[_value]._value;
}
template<typename T>
......
......@@ -49,6 +49,10 @@ namespace campvis {
* Executes the job, to be overwritten by subclasses.
*/
virtual void execute() = 0;
void operator()() {
this->execute();
}
};
// = Specific Jobs ================================================================================
......@@ -131,19 +135,30 @@ namespace campvis {
// = Helper functions for easier creation of jobs =================================================
/**
* Creates a new CallMemberFuncJob for the object \a target.
* Creates a new CallMemberFuncJob on the heap for the object \a target.
* \note The caller takes ownership of the returned pointer.
* \param target Target object to call method from.
* \param callee Pointer to method to call.
* \return Pointer to the newly created CallMemberFuncJob. Caller has ownership!
*/
template<class T>
CallMemberFuncJob<T>* make_job(T* target, void (T::*callee)()) {
CallMemberFuncJob<T>* makeJobOnHeap(T* target, void (T::*callee)()) {
return new CallMemberFuncJob<T>(target, callee);
}
/**
* Creates a new CallMemberFunc1ArgJob for the object \a target.
* Creates a new CallMemberFuncJob on the stack for the object \a target.
* \param target Target object to call method from.
* \param callee Pointer to method to call.
* \return The newly created CallMemberFuncJob
*/
template<class T>
CallMemberFuncJob<T> makeJob(T* target, void (T::*callee)()) {
return CallMemberFuncJob<T>(target, callee);
}
/**
* Creates a new CallMemberFunc1ArgJob on the heap for the object \a target.
* \note The caller takes ownership of the returned pointer.
* \param target Target object to call method from.
* \param callee Pointer to method to call.
......@@ -151,10 +166,22 @@ namespace campvis {
* \return Pointer to the newly created CallMemberFunc1ArgJob. Caller has ownership!
*/
template<class T, class A1>
CallMemberFunc1ArgJob<T, A1>* make_job(T* target, void (T::*callee)(A1), A1 arg1) {
CallMemberFunc1ArgJob<T, A1>* makeJobOnHeap(T* target, void (T::*callee)(A1), A1 arg1) {
return new CallMemberFunc1ArgJob<T, A1>(target, callee, arg1);
}
/**
* Creates a new CallMemberFunc1ArgJob on the stack for the object \a target.
* \param target Target object to call method from.
* \param callee Pointer to method to call.
* \param arg1 First argument to pass to \callee.
* \return The newly created CallMemberFunc1ArgJob.
*/
template<class T, class A1>
CallMemberFunc1ArgJob<T, A1> makeJob(T* target, void (T::*callee)(A1), A1 arg1) {
return CallMemberFunc1ArgJob<T, A1>(target, callee, arg1);
}
}
#endif // JOB_H__
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "simplejobprocessor.h"
#include "tgt/assert.h"
namespace campvis {
SimpleJobProcessor::SimpleJobProcessor()
{
}
SimpleJobProcessor::~SimpleJobProcessor() {
_taskGroup.cancel();
_taskGroup.wait();
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef SIMPLEJOBPROCESSOR_H__
#define SIMPLEJOBPROCESSOR_H__
#include "tgt/singleton.h"
#include "tbb/include/tbb/task_group.h"
namespace campvis {
/**
* Singleton class for managing and executing work items (jobs) in an asynchronous way.
* Enqueued jobs are dispatched via the tbb::task_group interface as single tasks.
* No priority schemes are implemented by now.
*/
class SimpleJobProcessor : public tgt::Singleton<SimpleJobProcessor> {
friend class tgt::Singleton<SimpleJobProcessor>;
public:
/**
* Destructor, cancels all unfinished jobs.
*/
virtual ~SimpleJobProcessor();
/**
* Enqueues the given Job.
* \param job Job to enqueue
*/
template<class Func>
void enqueueJob(const Func& f) {
_taskGroup.run(f);
};
protected:
SimpleJobProcessor();
tbb::task_group _taskGroup;
};
}
#define SimpleJobProc tgt::Singleton<SimpleJobProcessor>::getRef()
#endif // SIMPLEJOBPROCESSOR_H__
......@@ -187,7 +187,7 @@ void ConsoleLog::logFiltered(const std::string& cat, LogLevel level, const std::
if (colorOutput_)
output += "\033[00m"; // return to default color (Reset all attributes)
std::cout << output << std::endl;
std::cout << output << '\n';
}
void ConsoleLog::enableColors(bool enable) {
......
......@@ -33,6 +33,8 @@
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/tools/simplejobprocessor.h"
#include "core/tools/job.h"
namespace campvis {
......@@ -183,19 +185,13 @@ namespace campvis {
}
if (!_usReader.getInvalidationLevel().isValid()) {
executeProcessor(&_usReader);
// convert data
DataContainer::ScopedTypedData<ImageData> img(_data, _usReader.p_targetImageID.getValue());
if (img != 0) {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballEH->setSceneBounds(volumeExtent);
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
SimpleJobProc.enqueueJob(makeJob(this, &AdvancedUsVis::foobar));
}
if (!_usDenoiseilter.getInvalidationLevel().isValid()) {
SimpleJobProc.enqueueJob(makeJob<AdvancedUsVis, AbstractProcessor*>(this, &AdvancedUsVis::executeProcessor, &_usDenoiseilter));
}
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
if (! (*it)->getInvalidationLevel().isValid())
lockGLContextAndExecuteProcessor(*it);
......@@ -225,4 +221,19 @@ namespace campvis {
_camera.setWindowRatio(ratio);
}
void AdvancedUsVis::foobar() {
executeProcessor(&_usReader);
// convert data
DataContainer::ScopedTypedData<ImageData> img(_data, _usReader.p_targetImageID.getValue());
if (img != 0) {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballEH->setSceneBounds(volumeExtent);
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
}
}
\ No newline at end of file
......@@ -73,6 +73,8 @@ namespace campvis {
void onRenderTargetSizeChanged(const AbstractProperty* prop);
protected:
void foobar();
CameraProperty _camera;
MhdImageReader _usReader;
......
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