Files
OpenSpace/modules/iswa/rendering/datacygnet.h
2016-06-03 11:32:09 -04:00

93 lines
4.0 KiB
C++

/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __DATACYGNET_H__
#define __DATACYGNET_H__
#include <modules/iswa/rendering/iswacygnet.h>
#include <modules/iswa/util/dataprocessor.h>
namespace {
const int MAX_TEXTURES = 6;
}
namespace openspace{
/**
* This class abstracts away the the loading of data and creation of
* textures for all data cygnets. It specifies the interface that needs to
* be implemented for all concrete subclasses
*/
class DataCygnet : public IswaCygnet {
public:
DataCygnet(const ghoul::Dictionary& dictionary);
~DataCygnet();
protected:
bool updateTexture() override;
void fillOptions(std::string& source);
/**
* loads the transferfunctions specified in tfPath into
* _transferFunctions list.
*
* @param tfPath Path to transfer function file
*/
void readTransferFunctions(std::string tfPath);
/**
* This function binds and sets all textures that should go to the
* shader program, this includes both the data and transferfunctions.
*/
void setTextureUniforms();
/**
* Optional interface method. this has an implementation
* in datacygnet.cpp, but needs to be overriden for kameleonplane
*/
virtual bool updateTextureResource() override;
// Subclass interface.
// ===================
virtual bool createGeometry() = 0;
virtual bool destroyGeometry() = 0;
virtual void renderGeometry() const = 0;
/**
* This function should return the processed data that
* will populate the texture
*/
virtual std::vector<float*> textureData() = 0;
// This function can call parent setTextureUniforms()
virtual void setUniforms() = 0;
properties::SelectionProperty _dataOptions;
std::shared_ptr<DataProcessor> _dataProcessor;
std::string _dataBuffer;
glm::size3_t _textureDimensions;
private:
bool readyToRender() const override;
bool downloadTextureResource() override;
};
} //namespace openspace
#endif //__DATACYGNET_H__