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

* Introducing GeometryDataCollection class.

* Fixed crash (due to nullptr) in DataContainerInspectorWidget if DevIL module not present.
parent de26ca34
......@@ -413,6 +413,7 @@ namespace campvis {
void DataContainerInspectorWidget::onDCTWidgetSelectionModelSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
updateInfoWidget();
#ifdef CAMPVIS_HAS_MODULE_DEVIL
// get the selection from the tree widget
const QModelIndexList& indices = _dctWidget->selectionModel()->selectedRows();
......@@ -424,6 +425,7 @@ namespace campvis {
}
}
_btnSaveToFile->setDisabled(true);
#endif
}
void DataContainerInspectorWidget::onBtnSaveToFileClicked() {
......
......@@ -77,7 +77,7 @@ namespace campvis {
GeometryData& operator=(const GeometryData& rhs);
/// \see AbstractData::clone()
virtual AbstractData* clone() const = 0;
virtual GeometryData* clone() const = 0;
/**
* Renders this GeometryData.
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "geometrydatacollection.h"
#include "tgt/logmanager.h"
namespace campvis {
const std::string GeometryDataCollection::loggerCat_ = "CAMPVis.core.datastructures.GeometryDataCollection";;
GeometryDataCollection::GeometryDataCollection()
: GeometryData()
{
}
GeometryDataCollection::GeometryDataCollection(const GeometryDataCollection& rhs)
: GeometryData(rhs)
{
for (size_t i = 0; i < rhs._geometries.size(); ++i)
this->_geometries.push_back(rhs._geometries[i]->clone());
}
GeometryDataCollection::~GeometryDataCollection() {
for (size_t i = 0; i < _geometries.size(); ++i)
delete _geometries[i];
}
GeometryDataCollection& GeometryDataCollection::operator=(const GeometryDataCollection& rhs) {
if (this == &rhs)
return *this;
GeometryData::operator=(rhs);
// clone the geometries
for (size_t i = 0; i < rhs._geometries.size(); ++i)
this->_geometries.push_back(rhs._geometries[i]->clone());
return *this;
}
GeometryDataCollection* GeometryDataCollection::clone() const {
GeometryDataCollection* toReturn = new GeometryDataCollection();
for (size_t i = 0; i < _geometries.size(); ++i)
toReturn->_geometries.push_back(this->_geometries[i]->clone());
return toReturn;
}
void GeometryDataCollection::addGeometry(GeometryData* g) {
_geometries.push_back(g);
}
size_t GeometryDataCollection::getNumGeometries() const {
return _geometries.size();
}
const GeometryData* GeometryDataCollection::getGeometry(size_t index) const {
tgtAssert(index < _geometries.size(), "Index out of bounds!");
if (index < _geometries.size()) {
return _geometries[index];
}
return nullptr;
}
void GeometryDataCollection::removeGeometry(size_t index) {
tgtAssert(index < _geometries.size(), "Index out of bounds!");
if (index < _geometries.size()) {
delete _geometries[index];
_geometries.erase(_geometries.begin() + index);
}
}
void GeometryDataCollection::render(GLenum mode /*= GL_POLYGON*/) const {
for (size_t i = 0; i < _geometries.size(); ++i)
_geometries[i]->render(mode);
}
tgt::Bounds GeometryDataCollection::getWorldBounds() const {
tgt::Bounds toReturn;
for (size_t i = 0; i < _geometries.size(); ++i)
toReturn.addVolume(_geometries[i]->getWorldBounds());
return toReturn;
}
bool GeometryDataCollection::hasTextureCoordinates() const {
for (size_t i = 0; i < _geometries.size(); ++i) {
if (! _geometries[i]->hasTextureCoordinates())
return false;
}
return true;
}
void GeometryDataCollection::applyTransformationToVertices(const tgt::mat4& t) {
for (size_t i = 0; i < _geometries.size(); ++i)
_geometries[i]->applyTransformationToVertices(t);
}
size_t GeometryDataCollection::getLocalMemoryFootprint() const {
size_t sum = sizeof(GeometryDataCollection);
for (size_t i = 0; i < _geometries.size(); ++i)
sum += _geometries[i]->getLocalMemoryFootprint();
return sum;
}
size_t GeometryDataCollection::getVideoMemoryFootprint() const {
size_t sum = GeometryData::getVideoMemoryFootprint();
for (size_t i = 0; i < _geometries.size(); ++i)
sum += _geometries[i]->getVideoMemoryFootprint();
return sum;
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef GEOMETRYDATACOLLECTION_H__
#define GEOMETRYDATACOLLECTION_H__
#include "core/datastructures/geometrydata.h"
#include <vector>
namespace tgt {
class BufferObject;
class GLCanvas;
}
namespace campvis {
/**
* GeometryData that holds a collection of independent GeometryData objects.
* All geometries of this collection are rendered (and handled) at once.
*/
class CAMPVIS_CORE_API GeometryDataCollection : public GeometryData {
public:
/**
* Constructor
* \param vertexFeatures List of features present for each vertex
*/
explicit GeometryDataCollection();
/**
* Copy constructor
* \param rhs GeometryDataCollection to copy
*/
GeometryDataCollection(const GeometryDataCollection& rhs);
/**
* Destructor, deletes VBOs/VAO if necessary.
*/
virtual ~GeometryDataCollection();
/**
* Assignment operator.
* \param rhs GeometryDataCollection to assign to this.
* \return *this after assignment
*/
GeometryDataCollection& operator=(const GeometryDataCollection& rhs);
/// \see AbstractData::clone()
virtual GeometryDataCollection* clone() const;
/**
* Adds the GeometryData \a g to this collection.
* \param g Geometry to add.
*/
void addGeometry(GeometryData* g);
/**
* Returns the number of held geometries.
* \return _geometries.size()
*/
size_t getNumGeometries() const;
/**
* Returns the geometry with index \a index of this collection.
* \param index Index of the geometry to return.
* \return _geometries[index]
*/
const GeometryData* getGeometry(size_t index) const;
/**
* Removes geometry with index \a index from this collection.
* \param index Index of geometry to remove.
*/
void removeGeometry(size_t index);
/**
* Renders this GeometryDataCollection.
* Must be called from a valid OpenGL context.
*/
virtual void render(GLenum mode = GL_POLYGON) const;
/**
* Returns the geometry extent in world coordinates.
* \return The geometry extent in world coordinates.
*/
virtual tgt::Bounds getWorldBounds() const;
/**
* Returns whether all geometries of the collection have texture coordinates.
* \return True if all geometries of the collection set texture coordinates during rendering.
*/
virtual bool hasTextureCoordinates() const;
/**
* Applies the transformation matrix \a t to each vertex of this geometry.
* \param t Transformation matrix to apply
*/
virtual void applyTransformationToVertices(const tgt::mat4& t);
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
protected:
/// Collection of the geometries this object has.
std::vector<GeometryData*> _geometries;
private:
static const std::string loggerCat_;
};
}
#endif // GEOMETRYDATACOLLECTION_H__
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