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

Introducing virtual method AbstractData::getTypeAsString() to let every data...

Introducing virtual method AbstractData::getTypeAsString() to let every data type return a string representation of it's type to be shown in the GUI. Hence, we don't need the static if-then-else block in DataContainerTreeWidget anymore.
parent 0314b02a
......@@ -101,46 +101,7 @@ namespace campvis {
const AbstractData* data = _dataHandle.getData();
cgtAssert(data != 0, "WTF - QtDataHandle with empty data?");
if (const ImageData* tester = dynamic_cast<const ImageData*>(data)) {
return QVariant(QString("Image Data"));
}
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
else if (const FiberData* tester = dynamic_cast<const FiberData*>(data)) {
return QVariant(QString("Fiber Geometry"));
}
#endif
else if (const IndexedMeshGeometry* tester = dynamic_cast<const IndexedMeshGeometry*>(data)) {
return QVariant(QString("Indexed Geometry"));
}
else if (const MultiIndexedGeometry* tester = dynamic_cast<const MultiIndexedGeometry*>(data)) {
return QVariant(QString("Multi Indexed Geometry"));
}
else if (const FaceGeometry* tester = dynamic_cast<const FaceGeometry*>(data)) {
return QVariant(QString("Face Geometry"));
}
else if (const MeshGeometry* tester = dynamic_cast<const MeshGeometry*>(data)) {
return QVariant(QString("Mesh Geometry"));
}
else if (const GeometryData* tester = dynamic_cast<const GeometryData*>(data)) {
return QVariant(QString("Geometry"));
}
else if (const RenderData* tester = dynamic_cast<const RenderData*>(data)) {
return QVariant(QString("Render Data"));
}
else if (const DataSeries* tester = dynamic_cast<const DataSeries*>(data)) {
return QVariant(QString("Data Series"));
}
else if (const ImageSeries* tester = dynamic_cast<const ImageSeries*>(data)) {
return QVariant(QString("Image Series"));
}
else if (const LightSourceData* tester = dynamic_cast<const LightSourceData*>(data)) {
return QVariant(QString("Light Source"));
}
return QVariant(QString::fromStdString(data->getTypeAsString()));
}
else
return QVariant();
......
......@@ -91,6 +91,12 @@ namespace campvis {
*/
virtual size_t getVideoMemoryFootprint() const = 0;
/**
* Returns a human readable representation of the data type that can be used for the GUI.
* \return A string with the type name to be used for the GUI.
*/
virtual std::string getTypeAsString() const = 0;
private:
/// This weak_ptr points to the shared_ptr owning group of this object, if existant.
/// Should be only accessed by DataHandle (therefore the friendship) in order to avoid
......
......@@ -67,4 +67,8 @@ namespace campvis {
_camera = camera;
}
std::string CameraData::getTypeAsString() const {
return "Camera Data";
}
}
\ No newline at end of file
......@@ -61,6 +61,9 @@ namespace campvis {
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Const getter for the camera settings.
......
......@@ -77,5 +77,10 @@ namespace campvis {
cgtAssert(index < _data.size(), "Index out of bounds.");
return _data[index];
}
std::string DataSeries::getTypeAsString() const {
return "Data Series";
}
}
\ No newline at end of file
......@@ -64,6 +64,9 @@ namespace campvis {
* \return Number of bytes occupied in video memory by the data.
*/
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Appends the AbstractData instance \a data to the series.
......
......@@ -274,5 +274,9 @@ namespace campvis {
_buffersDirty = true;
}
std::string FaceGeometry::getTypeAsString() const {
return "Face Geometry Data";
}
}
\ No newline at end of file
......@@ -72,9 +72,10 @@ namespace campvis {
/// \see AbstractData::clone()
virtual FaceGeometry* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Returns the number of vertices of this face.
......
......@@ -114,6 +114,11 @@ namespace campvis {
return 0;
};
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const {
return "Pointer to " + typeid(T).name();
}
protected:
std::shared_ptr<T> _data; ///< Shared pointer to the data.
};
......
......@@ -145,4 +145,9 @@ namespace campvis {
return sum;
}
std::string GeometryDataCollection::getTypeAsString() const {
return "Collection of Geometry Data";
}
}
\ No newline at end of file
......@@ -123,9 +123,10 @@ namespace campvis {
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
protected:
/// Collection of the geometries this object has.
......
......@@ -128,4 +128,8 @@ namespace campvis {
addRepresentation(representation);
}
std::string ImageData::getTypeAsString() const {
return "Image Data";
}
}
\ No newline at end of file
......@@ -81,6 +81,12 @@ namespace campvis {
*/
virtual size_t getVideoMemoryFootprint() const;
/**
* Returns a human readable representation of the data type that can be used for the GUI.
* \return A string with the type name to be used for the GUI.
*/
virtual std::string getTypeAsString() const;
/**
* Dimensionality of this image.
* \return _dimensionality
......
......@@ -77,5 +77,10 @@ namespace campvis {
cgtAssert(index < _images.size(), "Index out of bounds.");
return _images[index];
}
std::string ImageSeries::getTypeAsString() const {
return "Image Series";
}
}
\ No newline at end of file
......@@ -65,6 +65,9 @@ namespace campvis {
* \return Number of bytes occupied in video memory by the data.
*/
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Appends the image \a image to the series.
......
......@@ -219,4 +219,8 @@ namespace campvis {
_buffersDirty = true;
}
std::string IndexedMeshGeometry::getTypeAsString() const {
return "Indexed Geometry Data";
}
}
\ No newline at end of file
......@@ -95,12 +95,12 @@ namespace campvis {
/// \see AbstractData::clone()
virtual IndexedMeshGeometry* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Renders this IndexedMeshGeometry.
......
......@@ -66,4 +66,8 @@ namespace campvis {
shader->setUniform(uniformName + "._attenuation", _attenuation);
}
std::string LightSourceData::getTypeAsString() const {
return "Light Source Data";
}
}
\ No newline at end of file
......@@ -69,6 +69,8 @@ namespace campvis {
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractData::getTypeAsString()
virtual std::string getTypeAsString() const;
/**
* Binds this light source to the given shader by setting the corresponding uniforms.
......
......@@ -341,4 +341,8 @@ namespace campvis {
}
}
std::string MeshGeometry::getTypeAsString() const {
return "Mesh Geometry Data";
}
}
\ No newline at end of file
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