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 b7e1f9b7 authored by schultezub's avatar schultezub
Browse files

introduced MWheelToNumericPropertyEventHandler

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@190 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 37dccfdc
#include "mwheeltonumericpropertyeventhandler.h"
#include "tgt/assert.h"
#include "tgt/event/mouseevent.h"
namespace TUMVis {
const std::string MWheelToNumericPropertyEventHandler::loggerCat_ = "TUMVis.core.eventhandler.MWheelToNumericPropertyEventHandler";
MWheelToNumericPropertyEventHandler::MWheelToNumericPropertyEventHandler(INumericProperty* property)
: AbstractEventHandler()
, _prop(property)
{
tgtAssert(_prop != 0, "Assigned property must not be 0.");
}
MWheelToNumericPropertyEventHandler::~MWheelToNumericPropertyEventHandler() {
}
bool MWheelToNumericPropertyEventHandler::accept(tgt::Event* e) {
if (tgt::MouseEvent* me = dynamic_cast<tgt::MouseEvent*>(e)) {
return me->action() == tgt::MouseEvent::WHEEL;
}
return false;
}
void MWheelToNumericPropertyEventHandler::execute(tgt::Event* e) {
tgtAssert(dynamic_cast<tgt::MouseEvent*>(e) != 0, "Given event has wrong type. Check if the event is accepted by this event handler before executing it!");
// this is only to be executed when the event was accepted, so the static cast is safe.
tgt::MouseEvent* me = static_cast<tgt::MouseEvent*>(e);
tgtAssert(me->action() == tgt::MouseEvent::WHEEL, "Given event has wrong type. Check if the event is accepted by this event handler before executing it!");
switch (me->button()) {
case tgt::MouseEvent::MOUSE_WHEEL_UP:
_prop->increment();
e->ignore();
break;
case tgt::MouseEvent::MOUSE_WHEEL_DOWN:
_prop->decrement();
e->ignore();
break;
}
}
}
#ifndef MWHEELTONUMERICPROPERTYEVENTHANDLER_H__
#define MWHEELTONUMERICPROPERTYEVENTHANDLER_H__
#include "tgt/logmanager.h"
#include "core/eventhandlers/abstracteventhandler.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
/**
* Event handler that maps mouse wheel events to a numeric property.
*
*/
class MWheelToNumericPropertyEventHandler : public AbstractEventHandler {
public:
/**
* Creates a MWheelToNumericPropertyEventHandler.
*/
MWheelToNumericPropertyEventHandler(INumericProperty* property);
/**
* Virtual Destructor
**/
virtual ~MWheelToNumericPropertyEventHandler();
/**
* Checks, whether the given event \a e is handled by this EventHandler.
* \param e The event to check
* \return True, if the given event is handled by this EventHandler.
*/
virtual bool accept(tgt::Event* e);
/**
* Performs the event handling.
* \param e The event to handle
*/
virtual void execute(tgt::Event* e);
protected:
INumericProperty* _prop;
static const std::string loggerCat_;
};
}
#endif // MWHEELTONUMERICPROPERTYEVENTHANDLER_H__
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
namespace TUMVis { namespace TUMVis {
class INumericProperty {
public:
virtual void increment() = 0;
virtual void decrement() = 0;
};
/** /**
* Generic class for numeric properties. * Generic class for numeric properties.
* Numeric properties manage a minimum and maximum value and ensure, that the property's * Numeric properties manage a minimum and maximum value and ensure, that the property's
...@@ -15,7 +21,7 @@ namespace TUMVis { ...@@ -15,7 +21,7 @@ namespace TUMVis {
* \tparam T Base type of the property's value. * \tparam T Base type of the property's value.
*/ */
template<typename T> template<typename T>
class NumericProperty : public GenericProperty<T> { class NumericProperty : public GenericProperty<T>, public INumericProperty {
public: public:
/** /**
* Creates a new NumericProperty. * Creates a new NumericProperty.
...@@ -72,8 +78,8 @@ namespace TUMVis { ...@@ -72,8 +78,8 @@ namespace TUMVis {
*/ */
virtual void setMaxValue(const T& value); virtual void setMaxValue(const T& value);
void increment(); virtual void increment();
void decrement(); virtual void decrement();
protected: protected:
......
...@@ -6,36 +6,42 @@ namespace TUMVis { ...@@ -6,36 +6,42 @@ namespace TUMVis {
SliceVis::SliceVis(tgt::GLCanvas* canvas /*= 0*/) SliceVis::SliceVis(tgt::GLCanvas* canvas /*= 0*/)
: VisualizationPipeline(canvas) : VisualizationPipeline(canvas)
, _imageReader(0) , _imageReader()
, _sliceExtractor(0) , _sliceExtractor(_canvasSize)
, _wheelHandler(&_sliceExtractor._sliceNumber)
{ {
_imageReader = new MhdImageReader(); _processors.push_back(&_imageReader);
_processors.push_back(_imageReader); _processors.push_back(&_sliceExtractor);
_sliceExtractor = new SliceExtractor(_canvasSize); _eventHandlers.push_back(&_wheelHandler);
_processors.push_back(_sliceExtractor);
} }
SliceVis::~SliceVis() { SliceVis::~SliceVis() {
delete _imageReader;
delete _sliceExtractor;
} }
void SliceVis::init() { void SliceVis::init() {
VisualizationPipeline::init(); VisualizationPipeline::init();
_imageReader->_url.setValue("D:\\Medical Data\\smallHeart.mhd"); _imageReader._url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader->_targetImageID.setValue("reader.output"); _imageReader._targetImageID.setValue("reader.output");
_sliceExtractor->_sourceImageID.setValue("se.input"); _sliceExtractor._sourceImageID.setValue("se.input");
_sliceExtractor->_sliceNumber.setValue(0); _sliceExtractor._sliceNumber.setValue(0);
_renderTargetID.setValue("renderTarget"); _renderTargetID.setValue("renderTarget");
_renderTargetID.addSharedProperty(&(_sliceExtractor->_targetImageID)); _renderTargetID.addSharedProperty(&(_sliceExtractor._targetImageID));
_imageReader.addObserver(this);
_sliceExtractor.addObserver(this);
execute();
} }
void SliceVis::execute() { void SliceVis::execute() {
if (! _imageReader->getInvalidationLevel().isValid()) { {
_imageReader->process(_data); tbb::spin_mutex::scoped_lock lock(_localMutex);
_invalidationLevel.setValid();
}
if (! _imageReader.getInvalidationLevel().isValid()) {
_imageReader.process(_data);
// convert data // convert data
const ImageData* img = _data.getTypedData<ImageData>("reader.output"); const ImageData* img = _data.getTypedData<ImageData>("reader.output");
...@@ -44,23 +50,26 @@ namespace TUMVis { ...@@ -44,23 +50,26 @@ namespace TUMVis {
_data.addData("se.input", local); _data.addData("se.input", local);
} }
} }
if (! _sliceExtractor->getInvalidationLevel().isValid()) { if (! _sliceExtractor.getInvalidationLevel().isValid()) {
_sliceExtractor->process(_data); _sliceExtractor.process(_data);
} }
// TODO: separate execution of the pipeline and rendering to canvas, as we want
// to do this asynchroniously in the mere future.
_canvas->repaint();
} }
void SliceVis::keyEvent(tgt::KeyEvent* e) { void SliceVis::keyEvent(tgt::KeyEvent* e) {
if (e->pressed()) { if (e->pressed()) {
switch (e->keyCode()) { switch (e->keyCode()) {
case tgt::KeyEvent::K_UP: case tgt::KeyEvent::K_UP:
_sliceExtractor->_sliceNumber.increment(); _sliceExtractor._sliceNumber.increment();
break; break;
case tgt::KeyEvent::K_DOWN: case tgt::KeyEvent::K_DOWN:
_sliceExtractor->_sliceNumber.decrement(); _sliceExtractor._sliceNumber.decrement();
break; break;
} }
} }
_canvas->repaint();
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define SLICEVIS_H__ #define SLICEVIS_H__
#include "core/datastructures/imagedatalocal.h" #include "core/datastructures/imagedatalocal.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventhandler.h"
#include "core/pipeline/visualizationpipeline.h" #include "core/pipeline/visualizationpipeline.h"
#include "modules/io/mhdimagereader.h" #include "modules/io/mhdimagereader.h"
#include "modules/vis/sliceextractor.h" #include "modules/vis/sliceextractor.h"
...@@ -30,8 +31,10 @@ namespace TUMVis { ...@@ -30,8 +31,10 @@ namespace TUMVis {
virtual void keyEvent(tgt::KeyEvent* e); virtual void keyEvent(tgt::KeyEvent* e);
protected: protected:
MhdImageReader* _imageReader; MhdImageReader _imageReader;
SliceExtractor* _sliceExtractor; SliceExtractor _sliceExtractor;
MWheelToNumericPropertyEventHandler _wheelHandler;
}; };
} }
......
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