Commit 0dfc7a2d authored by schultezub's avatar schultezub
Browse files

* adapted core directory structure

 * added AbstractEventHandler

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@171 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent cd5d3388
......@@ -16,7 +16,7 @@ namespace TUMVis {
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
getCamera()->look();
glColor3f(1.f, 0.f, 0.f);
tgt::Sphere sphere(_size, 64, 32);
tgt::Sphere sphere(.5f, 64, 32);
sphere.render();
}
......
......@@ -6,11 +6,15 @@ MESSAGE(STATUS "Configuring TUMVis Core")
FILE(GLOB TUMVIS_CORE_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
datastructures/*.cpp
eventhandler/*.cpp
pipeline/*.cpp
tools/*.cpp
)
FILE(GLOB TUMVIS_CORE_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
datastructures/*.h
eventhandler/*.h
pipeline/*.h
tools/*.h
)
......
#include "abstractpipeline.h"
namespace TUMVis {
const std::string AbstractPipeline::loggerCat_ = "TUMVis.core.datastructures.AbstractPipeline";
}
#include "abstracteventhandler.h"
namespace TUMVis {
const std::string AbstractEventHandler::loggerCat_ = "TUMVis.core.eventhandler.AbstractEventhandler";
AbstractEventHandler::AbstractEventHandler() {
}
AbstractEventHandler::~AbstractEventHandler() {
}
}
#ifndef ABSTRACTEVENTHANDLER_H__
#define ABSTRACTEVENTHANDLER_H__
#include "tgt/logmanager.h"
#include "tgt/event/eventlistener.h"
namespace TUMVis {
/**
* Abstract base class for TUMVis EventHandlers.
*
*/
class AbstractEventHandler {
public:
/**
* Creates a AbstractEventHandler.
*/
AbstractEventHandler();
/**
* Virtual Destructor
**/
virtual ~AbstractEventHandler();
/**
* 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) = 0;
/**
* Performs the event handling.
* \param e The event to handle
*/
virtual void execute(tgt::Event* e) = 0;
protected:
static const std::string loggerCat_;
};
}
#endif // ABSTRACTEVENTHANDLER_H__
#include "abstractpipeline.h"
namespace TUMVis {
const std::string AbstractPipeline::loggerCat_ = "TUMVis.core.datastructures.AbstractPipeline";
void AbstractPipeline::onEvent(tgt::Event* e) {
// cycle through event handlers, ask each one if it handles the event and if so, execute it.
for (std::vector<AbstractEventHandler*>::iterator it = _eventHandlers.begin(); it != _eventHandlers.end() && !e->isAccepted(); ++it) {
if ((*it)->accept(e)) {
(*it)->execute(e);
}
}
}
void AbstractPipeline::setCanvas(tgt::GLCanvas* canvas) {
_canvas = canvas;
}
}
#ifndef ABSTRACTPIPELINE_H__
#define ABSTRACTPIPELINE_H__
#include "tgt/glcanvas.h"
#include "tgt/logmanager.h"
#include "tgt/event/eventlistener.h"
#include "core/datastructures/datacontainer.h"
#include "core/eventhandler/abstracteventhandler.h"
#include <vector>
namespace TUMVis {
......@@ -10,12 +15,12 @@ namespace TUMVis {
* Abstract base class for TUMVis Pipelines.
*
*/
class AbstractPipeline {
class AbstractPipeline : public tgt::EventListener {
public:
/**
* Creates a AbstractPipeline.
*/
AbstractPipeline();
AbstractPipeline(tgt::GLCanvas* canvas = 0);
/**
* Virtual Destructor
......@@ -24,13 +29,28 @@ namespace TUMVis {
/**
* Execute this processor.
* Execute this pipeline.
**/
virtual void execute() = 0;
/**
* Performs the event handling for the assigned canvas.
* Default behaviour is to execute all assigned EventHandlers, may be overwritten by subclasses.
* \param e event parameters
*/
virtual void onEvent(tgt::Event* e);
/**
* Sets the target canvas for rendering.
* \param canvas Target canvas for rendering
*/
void setCanvas(tgt::GLCanvas* canvas);
protected:
DataContainer _data; ///< DataContainer containing local working set of data for this Pipeline
DataContainer _data; ///< DataContainer containing local working set of data for this Pipeline
tgt::GLCanvas* _canvas; ///< Target canvas for rendering
std::vector<AbstractEventHandler*> _eventHandlers; ///< List of registered event handlers for the pipeline
static const std::string loggerCat_;
};
......
......@@ -20,4 +20,17 @@ namespace TUMVis {
const DataContainer& AbstractProcessor::getDataContainer() const {
return _data;
}
int AbstractProcessor::getInvalidationLevel() const {
return _invalidationLevel;
}
void AbstractProcessor::setInvalidationLevel(InvalidationLevel il) {
if (il == VALID) {
_invalidationLevel = static_cast<int>(VALID);
}
else {
_invalidationLevel |= static_cast<int>(il);
}
}
}
......@@ -13,6 +13,12 @@ namespace TUMVis {
*/
class AbstractProcessor {
public:
enum InvalidationLevel {
VALID = 0,
INVALID_RESULT = 1 << 0,
INVALID_SHADER = 1 << 1,
};
/**
* Creates a AbstractProcessor.
*/
......@@ -44,8 +50,24 @@ namespace TUMVis {
**/
const DataContainer& getDataContainer() const;
/**
* Returns the invalidation level of this processor.
* Remind, that this is internally handled as a integer bit-set, so make sure to test via logic or.
* \return Integer representation of _invalidationLevel
*/
int getInvalidationLevel() const;
/**
* Update the processor's invalidation level by \a il.
* If \a il is VALID, the processor's invalidation level will be set to VALID.
* If \a il is one of the INVALID_X state, the processor's corresponding flag will be set.
* \param il Invalidation level to set.
*/
void setInvalidationLevel(InvalidationLevel il);
protected:
DataContainer _data; ///< DataContainer containing local working set of data for this Processor
int _invalidationLevel; ///< Invalidation level of this processor
static const std::string loggerCat_;
};
......
# Install script for directory: D:/Daten/Christian/Dokumente/Eigene Dokumente/TUM/work/tumvis/ext/tgt
# Set the install prefix
IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
SET(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/TUMVis")
ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
IF(BUILD_TYPE)
STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
ELSE(BUILD_TYPE)
SET(CMAKE_INSTALL_CONFIG_NAME "Release")
ENDIF(BUILD_TYPE)
MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
# Set the component getting installed.
IF(NOT CMAKE_INSTALL_COMPONENT)
IF(COMPONENT)
MESSAGE(STATUS "Install component: \"${COMPONENT}\"")
SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
ELSE(COMPONENT)
SET(CMAKE_INSTALL_COMPONENT)
ENDIF(COMPONENT)
ENDIF(NOT CMAKE_INSTALL_COMPONENT)
......@@ -3,7 +3,7 @@
#include <string>
#include "core/datastructures/abstractprocessor.h"
#include "core/pipeline/abstractprocessor.h"
namespace TUMVis {
/**
......
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