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

Fixed various cppcheck issues and compiler warnings

parent ef127d10
......@@ -157,15 +157,15 @@ namespace campvis {
if (const AbstractData* data = _dataHandle.getData()) {
if (const RenderData* tester = dynamic_cast<const RenderData*>(data)) {
for (size_t i = 0; i < tester->getNumColorTextures(); ++i) {
DataHandleTreeItem* dhti = new DataHandleTreeItem(QtDataHandle(tester->getColorDataHandle(i)), _name + "::ColorTexture" + StringUtils::toString(i), this);
new DataHandleTreeItem(QtDataHandle(tester->getColorDataHandle(i)), _name + "::ColorTexture" + StringUtils::toString(i), this);
}
if (tester->hasDepthTexture()) {
DataHandleTreeItem* dhti = new DataHandleTreeItem(QtDataHandle(tester->getDepthDataHandle()), _name + "::DepthTexture", this);
new DataHandleTreeItem(QtDataHandle(tester->getDepthDataHandle()), _name + "::DepthTexture", this);
}
}
else if (const ImageSeries* tester = dynamic_cast<const ImageSeries*>(data)) {
for (size_t i = 0; i < tester->getNumImages(); ++i) {
DataHandleTreeItem* dhti = new DataHandleTreeItem(QtDataHandle(tester->getImage(i)), _name + "::Image" + StringUtils::toString(i), this);
new DataHandleTreeItem(QtDataHandle(tester->getImage(i)), _name + "::Image" + StringUtils::toString(i), this);
}
}
......
......@@ -138,7 +138,7 @@ namespace campvis {
_logDisplay->clear();
_logHighlighter->setFilterRegExp(_filterRegExp);
for (std::deque<LogEntry>::iterator it = _logMessages.begin(); it != _logMessages.end(); it++) {
for (std::deque<LogEntry>::iterator it = _logMessages.begin(); it != _logMessages.end(); ++it) {
displayMessage(*it);
}
}
......
......@@ -303,7 +303,7 @@ namespace campvis {
PipelineTreeItem* pipeti = new PipelineTreeItem(*pipe, it->second);
for (std::vector<AbstractProcessor*>::const_iterator proc = (*pipe)->getProcessors().begin(); proc != (*pipe)->getProcessors().end(); ++proc) {
ProcessorTreeItem* procti = new ProcessorTreeItem(*proc, pipeti);
new ProcessorTreeItem(*proc, pipeti);
}
}
else {
......
......@@ -58,6 +58,7 @@ namespace campvis {
}
_property->s_changed.connect(this, &AbstractPropertyWidget::onPropertyChanged);
// cppcheck-suppress pureVirtualCall
connect(this, SIGNAL(s_propertyChanged(const AbstractProperty*)), this, SLOT(updateWidgetFromProperty()));
}
......
......@@ -95,7 +95,6 @@ namespace campvis {
void Geometry1DTransferFunctionEditor::paint() {
Geometry1DTransferFunction* gtf = static_cast<Geometry1DTransferFunction*>(_transferFunction);
const std::vector<TFGeometry1D*>& geometries = gtf->getGeometries();
const tgt::vec2& intensityDomain = gtf->getIntensityDomain();
// TODO: get rid of intermediate mode?
glPushAttrib(GL_ALL_ATTRIB_BITS);
......@@ -120,18 +119,16 @@ namespace campvis {
maxFilling = log(maxFilling);
float xl = static_cast<float>(0.f) / static_cast<float>(numBuckets);
float xr = 0.f;
float yl = (_logScale
? log(static_cast<float>(ih->getNumElements(0))) / maxFilling
: static_cast<float>(ih->getNumElements(0)) / maxFilling);
float yr = 0.f;
glBegin(GL_QUADS);
glColor4f(1.f, .75f, 0.f, .5f);
for (size_t i = 1; i < numBuckets; ++i) {
xr = static_cast<float>(i) / static_cast<float>(numBuckets);
yr = (_logScale
float xr = static_cast<float>(i) / static_cast<float>(numBuckets);
float yr = (_logScale
? std::max(0.f, static_cast<float>(log(static_cast<float>(ih->getNumElements(i)))) / maxFilling)
: static_cast<float>(ih->getNumElements(i)) / maxFilling);
......@@ -139,9 +136,6 @@ namespace campvis {
glVertex2f(xl, yl);
glVertex2f(xr, yr);
glVertex2f(xr, 0.f);
xl = xr;
yl = yr;
}
glEnd();
}
......@@ -248,7 +242,7 @@ namespace campvis {
QLabel* lblOpacityBottom = new QLabel(tr("0%"), this);
_layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight);
_canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false);
_canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, 0, false);
tgt::GlContextManager::getRef().registerContextAndInitGlew(_canvas);
GLJobProc.registerContext(_canvas);
......
......@@ -91,7 +91,6 @@ namespace campvis {
void Geometry2DTransferFunctionEditor::paint() {
Geometry2DTransferFunction* gtf = static_cast<Geometry2DTransferFunction*>(_transferFunction);
const std::vector<TFGeometry2D*>& geometries = gtf->getGeometries();
const tgt::vec2& intensityDomain = gtf->getIntensityDomain();
// TODO: get rid of intermediate mode?
glPushAttrib(GL_ALL_ATTRIB_BITS);
......@@ -122,15 +121,13 @@ namespace campvis {
float maxFilling = static_cast<float>(ih->getMaxFilling());
float xl = static_cast<float>(0.f) / static_cast<float>(numBuckets);
float xr = 0.f;
float yl = static_cast<float>(ih->getNumElements(0)) / maxFilling;
float yr = 0.f;
glBegin(GL_QUADS);
glColor4f(1.f, .75f, 0.f, .5f);
for (size_t i = 1; i < numBuckets; ++i) {
xr = static_cast<float>(i) / static_cast<float>(numBuckets);
yr = static_cast<float>(ih->getNumElements(i)) / maxFilling;
float xr = static_cast<float>(i) / static_cast<float>(numBuckets);
float yr = static_cast<float>(ih->getNumElements(i)) / maxFilling;
glVertex2f(xl, 0.f);
glVertex2f(xl, yl);
......@@ -229,7 +226,7 @@ namespace campvis {
QLabel* lblOpacityBottom = new QLabel(tr("0%"), this);
_layout->addWidget(lblOpacityBottom, 3, 0, 1, 1, Qt::AlignRight);
_canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, false);
_canvas = new tgt::QtThreadedCanvas("", tgt::ivec2(256, 128), tgt::GLCanvas::RGBA_BUFFER, 0, false);
tgt::GlContextManager::getRef().registerContextAndInitGlew(_canvas);
GLJobProc.registerContext(_canvas);
......
......@@ -65,8 +65,8 @@ namespace campvis {
SimpleTransferFunction* stf = static_cast<SimpleTransferFunction*>(_transferFunction);
_cpwColorLeft->blockSignals(true);
_cpwColorRight->blockSignals(true);
_cpwColorLeft->setColor(QtColorTools::toQColor(static_cast<SimpleTransferFunction*>(_transferFunction)->getLeftColor()));
_cpwColorRight->setColor(QtColorTools::toQColor(static_cast<SimpleTransferFunction*>(_transferFunction)->getRightColor()));
_cpwColorLeft->setColor(QtColorTools::toQColor(stf->getLeftColor()));
_cpwColorRight->setColor(QtColorTools::toQColor(stf->getRightColor()));
_cpwColorLeft->blockSignals(false);
_cpwColorRight->blockSignals(false);
}
......
......@@ -50,13 +50,13 @@ namespace campvis {
for (size_t i = 0; i < TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS; ++i) {
if (attachments[i] != 0) {
ImageData* img = new ImageData(2, attachments[i]->getDimensions(), attachments[i]->getNumChannels());
ImageRepresentationGL* rep = ImageRepresentationGL::create(img, attachments[i]);
ImageRepresentationGL::create(img, attachments[i]);
_colorTextures.push_back(DataHandle(img));
}
}
if (attachments[TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS] != 0) {
ImageData* img = new ImageData(2, attachments[TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS]->getDimensions(), attachments[TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS]->getNumChannels());
ImageRepresentationGL* rep = ImageRepresentationGL::create(img, attachments[TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS]);
ImageRepresentationGL::create(img, attachments[TGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS]);
_depthTexture = DataHandle(img);
}
}
......
......@@ -146,8 +146,10 @@ namespace campvis {
void TrackballNavigationEventListener::removeLqModeProcessor(VisualizationProcessor* vp) {
for (std::vector<VisualizationProcessor*>::iterator it = _lqModeProcessors.begin(); it != _lqModeProcessors.end(); ++it) {
if (*it == vp)
if (*it == vp) {
_lqModeProcessors.erase(it);
return;
}
}
}
......
......@@ -568,7 +568,7 @@ std::vector<std::string> TarFileFactory::getFilenames() {
std::vector<std::string> files;
std::map<std::string, ArchivedFile>::iterator theIterator;
for (theIterator = files_.begin(); theIterator != files_.end(); theIterator++)
for (theIterator = files_.begin(); theIterator != files_.end(); ++theIterator)
files.push_back((*theIterator).first);
return files;
......@@ -627,7 +627,7 @@ bool FileSystem::exists(const std::string& filename) {
void FileSystem::addFactory(FileFactory* ff) {
std::vector<std::string> files = ff->getFilenames();
std::vector<std::string>::iterator theIterator;
for (theIterator = files.begin(); theIterator != files.end(); theIterator++)
for (theIterator = files.begin(); theIterator != files.end(); ++theIterator)
virtualFS_[*theIterator] = ff;
factories_.push_back(ff);
......@@ -1156,7 +1156,6 @@ std::vector<std::string> FileSystem::listFiles(const std::string& directory, con
WIN32_FIND_DATA findFileData = {0};
HANDLE hFind = 0;
std::stack<std::string> stackDirs;
std::string dir(converted + "\\*");
hFind = FindFirstFile(dir.c_str(), &findFileData);
......
......@@ -113,81 +113,6 @@ bool GLCanvas::getAutoFlush() {
return autoFlush_;
}
bool GLCanvas::takeScreenshot(std::string fname) {
//taken from gamedev.net forum:
FILE *pFile; // The file pointer.
unsigned char uselessChar; // used for useless char.
short int uselessInt; // used for useless int.
unsigned char imageType; // Type of image we are saving.
int index; // used with the for loop.
unsigned char bits; // Bit depth.
long Size; // Size of the picture.
int colorMode;
unsigned char tempColors;
short int width = getWidth();
short int height = getHeight();
// Open file for output.
pFile = fopen(fname.c_str(), "wb");
// Check if the file opened or not.
if (!pFile) {
fclose(pFile);
return false;
}
unsigned char *image = new unsigned char[getWidth()*getHeight()*3];
//read image from gl:
glReadPixels( 0, 0, getWidth(), getHeight(), GL_RGB, GL_UNSIGNED_BYTE, image );
// Set the image type, the color mode, and the bit depth.
imageType = 2; colorMode = 3; bits = 24;
// Set these two to 0.
uselessChar = 0; uselessInt = 0;
// Write useless data.
size_t written = 0;
written += fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
written += fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
// Now image type.
written += fwrite(&imageType, sizeof(unsigned char), 1, pFile);
// Write useless data.
written += fwrite(&uselessInt, sizeof(short int), 1, pFile);
written += fwrite(&uselessInt, sizeof(short int), 1, pFile);
written += fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
written += fwrite(&uselessInt, sizeof(short int), 1, pFile);
written += fwrite(&uselessInt, sizeof(short int), 1, pFile);
// Write the size that you want.
written += fwrite(&width, sizeof(short int), 1, pFile);
written += fwrite(&height, sizeof(short int), 1, pFile);
written += fwrite(&bits, sizeof(unsigned char), 1, pFile);
// Write useless data.
written += fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
// Get image size.
Size = width * height * colorMode;
// Now switch image from RGB to BGR.
for (index = 0; index < Size; index += colorMode){
tempColors = image[index];
image[index] = image[index + 2];
image[index + 2] = tempColors;
}
// Finally write the image.
written += fwrite(image, sizeof(unsigned char), Size, pFile);
// close the file.
fclose(pFile);
delete[] image;
return (written > 0);
}
const ivec4& GLCanvas::getRgbaSize() const {
return rgbaSize_;
}
......
......@@ -150,10 +150,6 @@ public:
/// wheater canvas automatically calls glFlush or swap
bool getAutoFlush();
///Take a screenshot and save it as TGA file.
///@param fname Target filename
bool takeScreenshot(std::string fname);
/// Getter
const ivec4& getRgbaSize() const;
......
......@@ -52,9 +52,9 @@ void GUIApplication::removeCanvas(GLCanvas* canvas) {
}
void GUIApplication::initCanvases() {
std::list<GLCanvas*>::iterator iter;
for ( iter = canvases_.begin(); iter != canvases_.end(); iter++ ) {
if (!(*iter)->isInitialized()) (*iter)->init();
for (std::list<GLCanvas*>::iterator iter = canvases_.begin(); iter != canvases_.end(); ++iter) {
if (! (*iter)->isInitialized())
(*iter)->init();
}
}
......
......@@ -297,7 +297,7 @@ LogManager::LogManager(const std::string& logDir)
LogManager::~LogManager() {
vector<Log*>::iterator it;
for (it = logs_.begin(); it != logs_.end(); it++)
for (it = logs_.begin(); it != logs_.end(); ++it)
delete (*it);
delete consoleLog_;
......@@ -311,7 +311,7 @@ void LogManager::log(const std::string &cat, LogLevel level, const std::string &
const std::string &extendedInfo)
{
vector<Log*>::iterator it;
for (it = logs_.begin(); it != logs_.end(); it++) {
for (it = logs_.begin(); it != logs_.end(); ++it) {
if (*it != 0)
(*it)->log(cat, level, msg, extendedInfo);
}
......
......@@ -121,10 +121,9 @@ int NaturalCubicSpline::lookup(float x) const {
else {
int i1 = 0;
int i2 = size - 2;
int i3 = 0;
while (i2 - i1 > 1) {
i3 = i1 + ((i2 - i1) >> 1);
int i3 = i1 + ((i2 - i1) >> 1);
if (points_[i3].x > x)
i2 = i3;
else
......
......@@ -56,7 +56,8 @@ namespace campvis {
, p_url("url", "Image URL", "")
, p_targetImageID("targetImageName", "Target Image ID", "DevilImageReader.output", DataNameProperty::WRITE)
, p_importType("ImportType", "Import Type", importOptions, 3)
, _devilTextureReader(0)
, _shader(nullptr)
, _devilTextureReader(nullptr)
{
addProperty(&p_url);
addProperty(&p_targetImageID);
......
......@@ -46,7 +46,7 @@ namespace campvis {
void AbstractImageReader::setTargetImageId(DataNameProperty& targetImageId) {
this->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator it = sharedProperties.begin(); it != sharedProperties.end(); it++) {
for(std::set<AbstractProperty*>::iterator it = sharedProperties.begin(); it != sharedProperties.end(); ++it) {
this->p_targetImageID.addSharedProperty(*it);
}
}
......@@ -60,7 +60,7 @@ namespace campvis {
}
bool AbstractImageReader::acceptsExtension(const std::string& extension) {
for(std::vector<std::string>::iterator it = this->_ext.begin(); it != this->_ext.end(); it++) {
for(std::vector<std::string>::iterator it = this->_ext.begin(); it != this->_ext.end(); ++it) {
if(*it == extension) {
return true;
}
......
......@@ -78,8 +78,6 @@ namespace campvis {
protected:
std::vector<std::string> _ext;
static const std::string loggerCat_;
private:
......
......@@ -66,7 +66,6 @@ namespace campvis {
size_t dimensionality = 3;
tgt::svec3 size;
WeaklyTypedPointer::BaseType pt;
size_t numChannels = 1;
tgt::vec3 voxelSize(1.f);
tgt::vec3 imageOffset(0.f);
......@@ -138,6 +137,8 @@ namespace campvis {
file.close(); \
} \
rep = GenericImageRepresentationLocal<C_TYPE, 1>::create(image, dataArray); \
if (rep == 0) \
delete [] dataArray; \
}
DISPATCH_PARSING(WeaklyTypedPointer::UINT8 , uint8_t, uint16_t)
......
......@@ -67,7 +67,7 @@ namespace campvis {
}
void GenericImageReader::deinit() {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); ++it) {
if (nullptr != it->first) delete it->first;
if (nullptr != it->second) delete it->second;
}
......@@ -128,7 +128,7 @@ namespace campvis {
if(it != this->_readers.end()) {
(it->first)->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator jt = sharedProperties.begin(); jt != sharedProperties.end(); jt++) {
for(std::set<AbstractProperty*>::iterator jt = sharedProperties.begin(); jt != sharedProperties.end(); ++jt) {
(it->first)->p_targetImageID.addSharedProperty(*jt);
}
}
......
......@@ -78,7 +78,7 @@ namespace campvis {
throw tgt::FileException("Unknown identifier in vtk file.", p_url.getValue());
// next line is the header - contains only unimportant data
curLine = getTrimmedLine(file);
getTrimmedLine(file);
// this line is the format
curLine = StringUtils::lowercase(getTrimmedLine(file));
......@@ -117,7 +117,6 @@ namespace campvis {
void VtkImageReader::parseStructuredPoints(DataContainer& data, std::ifstream& file) throw (tgt::Exception, std::exception) {
// init optional parameters with sane default values
std::string url;
size_t dimensionality = 3;
tgt::svec3 size(static_cast<size_t>(0));
......
......@@ -40,6 +40,8 @@ namespace campvis {
, _imageReader()
, _resampler(&_canvasSize)
, _ve(&_canvasSize)
, _glr(nullptr)
, _glr2(nullptr)
{
addProcessor(&_imageReader);
addProcessor(&_resampler);
......
......@@ -53,7 +53,6 @@ namespace campvis {
void operator() (const tbb::blocked_range<size_t>& range) const {
for (size_t i = range.begin(); i != range.end(); ++i) {
tgt::svec3 pos = _intensities->getParent()->indexToPosition(i);
const tgt::svec3& size = _intensities->getSize();
const tgt::vec4& gradient = _gradients->getElement(i);
float fl = _intensities->getElementNormalized(i, 0);
......@@ -183,7 +182,7 @@ namespace campvis {
WeaklyTypedPointer wtp(WeaklyTypedPointer::FLOAT, 1, tmp);
ImageData* imgTex = new ImageData(2, tgt::svec3(256, 256, 1), 1);
ImageRepresentationGL* tex = ImageRepresentationGL::create(imgTex, wtp);
ImageRepresentationGL::create(imgTex, wtp);
delete [] tmp;
data.addData("foo", imgTex);
......
......@@ -81,7 +81,6 @@ namespace campvis {
if (img != 0) {
if (img->getDimensionality() == 3) {
const tgt::Camera& cam = p_camera.getValue();
const tgt::svec3& imgSize = img->getSize();
// Creating the slice proxy geometry works as follows:
// Create the cube proxy geometry for the volume, then clip the cube against the slice plane.
......
......@@ -189,7 +189,6 @@ namespace campvis {
_shader->setUniform("_renderBackground", true);
vrImage->bind(_shader, colorUnit, depthUnit);
float ratio = static_cast<float>(vrs.x) / static_cast<float>(rts.x);
_shader->setUniform("_modelMatrix", tgt::mat4::createScale(tgt::vec3(vrs.x, vrs.y, .5f)));
_shader->setUniform("_viewMatrix", tgt::mat4::createTranslation(tgt::vec3(srs.x, 0.f, 0.f)));
_quad->render(GL_POLYGON);
......
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