Commit d5499f4f authored by Jan Möbius's avatar Jan Möbius

Fixed a lot of cppcheck warnings and some minor bugs

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13301 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c653fb01
......@@ -47,6 +47,9 @@
TreeItem::TreeItem(int _id, QString _name, DataType _type, TreeItem* _parent) :
id_(_id),
dataType_(_type),
target_(true),
source_(false),
visible_(true),
name_(_name),
parentItem_(_parent)
{
......
......@@ -65,6 +65,13 @@
//== IMPLEMENTATION ==========================================================
DecimaterPlugin::DecimaterPlugin() :
tool_(0),
toolIcon_(0)
{
}
void DecimaterPlugin::initializePlugin()
{
tool_ = new DecimaterToolbarWidget();
......
......@@ -127,7 +127,7 @@ private slots:
public :
/// Default constructor
DecimaterPlugin() : tool_(0) {};
DecimaterPlugin();
/// Default destructor
~DecimaterPlugin() {};
......
......@@ -90,20 +90,6 @@ int FileLightPlugin::loadObject(QString _filename)
LightSource* light = PluginFunctions::lightSource(lightObject);
QString name = lightObject->name();
ACG::Vec3d position;
ACG::Vec3d direction;
ACG::Vec3d spotDirection;
ACG::Vec4f ambientColor;
ACG::Vec4f diffuseColor;
ACG::Vec4f specularColor;
bool fixedPosition;
float spotExponent;
float spotCutOff;
float cAttenuation;
float lAttenuation;
float qAttenuation;
float radius;
bool enabled;
QSettings settings(_filename, QSettings::IniFormat);
settings.beginGroup("LIGHT");
......@@ -117,126 +103,126 @@ int FileLightPlugin::loadObject(QString _filename)
lightObject->setFromFileName(_filename);
}
if ( settings.contains("PositionX") ) {
position[0] = settings.value("PositionX").toDouble();
position[1] = settings.value("PositionY").toDouble();
position[2] = settings.value("PositionZ").toDouble();
if (settings.contains("PositionX")) {
ACG::Vec3d position;
position[0] = settings.value("PositionX").toDouble();
position[1] = settings.value("PositionY").toDouble();
position[2] = settings.value("PositionZ").toDouble();
light->position( position );
light->position(position);
}
if ( settings.contains("DirectionX") ){
direction[0] = settings.value("DirectionX").toDouble();
direction[1] = settings.value("DirectionY").toDouble();
direction[2] = settings.value("DirectionZ").toDouble();
light->direction( direction );
if (settings.contains("DirectionX")) {
ACG::Vec3d direction;
direction[0] = settings.value("DirectionX").toDouble();
direction[1] = settings.value("DirectionY").toDouble();
direction[2] = settings.value("DirectionZ").toDouble();
light->direction(direction);
}
if ( settings.contains("SpotDirectionX") ){
spotDirection[0] = settings.value("SpotDirectionX").toDouble();
spotDirection[1] = settings.value("SpotDirectionY").toDouble();
spotDirection[2] = settings.value("SpotDirectionZ").toDouble();
if (settings.contains("SpotDirectionX")) {
ACG::Vec3d spotDirection;
spotDirection[0] = settings.value("SpotDirectionX").toDouble();
spotDirection[1] = settings.value("SpotDirectionY").toDouble();
spotDirection[2] = settings.value("SpotDirectionZ").toDouble();
light->spotDirection( spotDirection );
light->spotDirection(spotDirection);
}
if ( settings.contains("AmbientColorR") ){
ambientColor[0] = settings.value("AmbientColorR").toDouble();
ambientColor[1] = settings.value("AmbientColorG").toDouble();
ambientColor[2] = settings.value("AmbientColorB").toDouble();
if(settings.contains("AmbientColorA"))
ambientColor[3] = settings.value("AmbientColorA").toDouble();
else
ambientColor[3] = 1.0f;
light->ambientColor( ambientColor );
if (settings.contains("AmbientColorR")) {
ACG::Vec4f ambientColor;
ambientColor[0] = settings.value("AmbientColorR").toDouble();
ambientColor[1] = settings.value("AmbientColorG").toDouble();
ambientColor[2] = settings.value("AmbientColorB").toDouble();
if (settings.contains("AmbientColorA"))
ambientColor[3] = settings.value("AmbientColorA").toDouble();
else
ambientColor[3] = 1.0f;
light->ambientColor(ambientColor);
}
if ( settings.contains("DiffuseColorR") ){
diffuseColor[0] = settings.value("DiffuseColorR").toDouble();
diffuseColor[1] = settings.value("DiffuseColorG").toDouble();
diffuseColor[2] = settings.value("DiffuseColorB").toDouble();
if(settings.contains("DiffuseColorA"))
diffuseColor[3] = settings.value("DiffuseColorA").toDouble();
else
diffuseColor[3] = 1.0f;
if (settings.contains("DiffuseColorR")) {
ACG::Vec4f diffuseColor;
diffuseColor[0] = settings.value("DiffuseColorR").toDouble();
diffuseColor[1] = settings.value("DiffuseColorG").toDouble();
diffuseColor[2] = settings.value("DiffuseColorB").toDouble();
if (settings.contains("DiffuseColorA"))
diffuseColor[3] = settings.value("DiffuseColorA").toDouble();
else
diffuseColor[3] = 1.0f;
light->diffuseColor(diffuseColor);
}
light->diffuseColor( diffuseColor );
if (settings.contains("SpecularColorR")) {
ACG::Vec4f specularColor;
specularColor[0] = settings.value("SpecularColorR").toDouble();
specularColor[1] = settings.value("SpecularColorG").toDouble();
specularColor[2] = settings.value("SpecularColorB").toDouble();
if (settings.contains("SpecularColorA"))
specularColor[3] = settings.value("SpecularColorA").toDouble();
else
specularColor[3] = 1.0f;
light->specularColor(specularColor);
}
if ( settings.contains("SpecularColorR") ){
specularColor[0] = settings.value("SpecularColorR").toDouble();
specularColor[1] = settings.value("SpecularColorG").toDouble();
specularColor[2] = settings.value("SpecularColorB").toDouble();
if(settings.contains("SpecularColorA"))
specularColor[3] = settings.value("SpecularColorA").toDouble();
else
specularColor[3] = 1.0f;
if (settings.contains("FixedPosition")) {
light->specularColor( specularColor );
}
if ( settings.contains("FixedPosition") ){
fixedPosition = settings.value("FixedPosition").toBool();
bool fixedPosition = settings.value("FixedPosition").toBool();
light->fixedPosition( fixedPosition );
light->fixedPosition(fixedPosition);
}
if ( settings.contains("SpotExponent") ){
spotExponent = settings.value("SpotExponent").toDouble();
if (settings.contains("SpotExponent")) {
light->spotExponent( spotExponent );
float spotExponent = settings.value("SpotExponent").toDouble();
light->spotExponent(spotExponent);
}
if ( settings.contains("SpotCutOff") ){
spotCutOff = settings.value("SpotCutOff").toDouble();
if (settings.contains("SpotCutOff")) {
float spotCutOff = settings.value("SpotCutOff").toDouble();
light->spotCutoff( spotCutOff );
light->spotCutoff(spotCutOff);
}
if ( settings.contains("ConstantAttenuation") ){
cAttenuation = settings.value("ConstantAttenuation").toDouble();
if (settings.contains("ConstantAttenuation")) {
float cAttenuation = settings.value("ConstantAttenuation").toDouble();
light->constantAttenuation( cAttenuation );
light->constantAttenuation(cAttenuation);
}
if ( settings.contains("LinearAttenuation") ){
lAttenuation = settings.value("LinearAttenuation").toDouble();
if (settings.contains("LinearAttenuation")) {
float lAttenuation = settings.value("LinearAttenuation").toDouble();
light->linearAttenuation( lAttenuation );
light->linearAttenuation(lAttenuation);
}
if ( settings.contains("QuadraticAttenuation") ){
qAttenuation = settings.value("QuadraticAttenuation").toDouble();
if (settings.contains("QuadraticAttenuation")) {
float qAttenuation = settings.value("QuadraticAttenuation").toDouble();
light->quadraticAttenuation( qAttenuation );
light->quadraticAttenuation(qAttenuation);
}
if ( settings.contains("Radius") ){
radius = settings.value("Radius").toDouble();
light->radius( radius );
if (settings.contains("Radius")) {
float radius = settings.value("Radius").toDouble();
light->radius(radius);
}
if ( settings.contains("Enabled") ){
enabled = settings.value("Enabled").toBool();
if (settings.contains("Enabled")) {
bool enabled = settings.value("Enabled").toBool();
enabled ? light->enable() : light->disable();
enabled ? light->enable() : light->disable();
}
settings.endGroup();
......
......@@ -422,7 +422,6 @@ void FileOBJPlugin::addTextures(OBJImporter& _importer, int _objectID ){
while ( options.size() > 1 ) {
if ( options[0] == "-blendu" ) {
} else if ( options[0] == "-blendu" ) {
options.pop_front();
options.pop_front();
} else if ( options[0] == "-blendv" ) {
......@@ -835,7 +834,7 @@ void FileOBJPlugin::readOBJFile(QString _filename, OBJImporter& _importer)
if( !vhandles.empty() ){
if ( face_texcoords.size() > 0 )
if ( !face_texcoords.empty() )
//if we have texCoords add face+texCoords
_importer.addFace(vhandles, face_texcoords );
else
......
......@@ -272,7 +272,7 @@ bool FileOFFPlugin::readFileOptions(QString _filename, OFFImporter& _importer) {
std::ifstream ifs(_filename.toUtf8());
if (!ifs.is_open() | !ifs.good()) {
if ( (!ifs.is_open()) || (!ifs.good())) {
emit log(LOGERR, tr("Error: Could not read file options of specified OFF-file! Aborting."));
return false;
......@@ -335,7 +335,6 @@ bool FileOFFPlugin::readFileOptions(QString _filename, OFFImporter& _importer) {
// the face valences
unsigned int nV, nF, dummy_uint;
float dummy_f;
unsigned int vertexCount = 0;
unsigned int tmp_count = 0;
std::string trash;
......@@ -344,6 +343,7 @@ bool FileOFFPlugin::readFileOptions(QString _filename, OFFImporter& _importer) {
if(_importer.isBinary()) {
// Parse BINARY file
float dummy_f;
// + #Vertices, #Faces, #Edges
readValue(ifs, nV);
......@@ -665,7 +665,6 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
default:
std::cerr << "Error in file format (colorType = " << colorType << ")\n";
break;
break;
}
}
......
......@@ -119,7 +119,7 @@ size_t FilePLYPlugin::getTypeSize(std::string _type) {
return sizeof(float);
else if(_type == "int" || _type == "int32" || _type == "uint" || _type == "uint32")
return sizeof(int);
else if(_type == "double" || _type == "int64" || _type == "uint64" || _type == "uint64")
else if(_type == "double" || _type == "int64" || _type == "uint64")
return sizeof(double);
else
std::cerr << "Unable to parse SizeType. I got " << _type << std::endl;
......@@ -496,7 +496,7 @@ int FilePLYPlugin::loadObject(QString _filename) {
//-----------------------------------------------------------------------------------------------------
/// load a triangle-mesh with given filename
int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader _header){
int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader& _header){
int id = -1;
emit addEmptyObject(DATA_TRIANGLE_MESH, id);
......@@ -552,7 +552,7 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader _header)
//-----------------------------------------------------------------------------------------------------
/// load a poly-mesh with given filename
int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader _header){
int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _header){
int id = -1;
emit addEmptyObject(DATA_POLY_MESH, id);
......
......@@ -148,10 +148,10 @@ class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
int loadObject(QString _filename, DataType _type);
/// Always loads mesh as polymesh
int loadPolyMeshObject(QString _filename, const PLYHeader _header);
int loadPolyMeshObject(QString _filename, const PLYHeader& _header);
/// Loads a triangle mesh
int loadTriMeshObject(QString _filename, const PLYHeader _header);
int loadTriMeshObject(QString _filename, const PLYHeader& _header);
bool saveObject(int _id, QString _filename);
......
......@@ -104,12 +104,11 @@ int FileSPHPlugin::loadObject(QString _filename)
sphereObject->setFromFileName(_filename);
}
ACG::Vec3d position;
double size;
int slices,stacks;
if ( settings.contains("PositionX") ) {
ACG::Vec3d position;
position[0] = settings.value("PositionX").toDouble();
position[1] = settings.value("PositionY").toDouble();
position[2] = settings.value("PositionZ").toDouble();
......@@ -119,21 +118,21 @@ int FileSPHPlugin::loadObject(QString _filename)
if ( settings.contains("Size") ){
size = settings.value("Size").toDouble();
double size = settings.value("Size").toDouble();
sphere->get_primitive(0).size = size;
}
if ( settings.contains("Slices") ){
slices = settings.value("Slices").toDouble();
int slices = settings.value("Slices").toDouble();
sphere->get_primitive(0).slices = slices;
}
if ( settings.contains("Stacks") ){
stacks = settings.value("Stacks").toDouble();
int stacks = settings.value("Stacks").toDouble();
sphere->get_primitive(0).stacks = stacks;
}
......
......@@ -416,6 +416,9 @@ void MovePlugin::slotPickModeChanged( const std::string& _mode)
{
switch (manMode_)
{
case QtTranslationManipulatorNode::Rotation:
PluginFunctions::setViewObjectMarker (PluginFunctions::defaultViewObjectMarker ());
break;
case QtTranslationManipulatorNode::Resize:
PluginFunctions::setViewObjectMarker (PluginFunctions::defaultViewObjectMarker ());
break;
......@@ -536,6 +539,10 @@ void MovePlugin::setManipMode (QtTranslationManipulatorNode::ManipulatorMode _mo
if (!hide_)
switch (manMode_)
{
case QtTranslationManipulatorNode::Rotation:
PluginFunctions::setViewObjectMarker (PluginFunctions::defaultViewObjectMarker ());
placeMode_ = false;
break;
case QtTranslationManipulatorNode::Resize:
PluginFunctions::setViewObjectMarker (PluginFunctions::defaultViewObjectMarker ());
placeMode_ = false;
......@@ -706,8 +713,8 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
bool successfullyPicked = false;
int data = -1;
/*
* Snap manipulator to nearest geometry
* element depending on which selection type is
......@@ -764,6 +771,8 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
object->manipPlaced(true);
/// TODO: Whats this?
int data = -1;
if (data != -1)
object->manipulatorNode()->setData( data );
......@@ -1582,7 +1591,7 @@ void MovePlugin::updateManipulatorDialog() {
movePropsWidget* MovePlugin::getDialogWidget(BaseObjectData* _obj) {
for(QList<movePropsWidget*>::iterator it = propsWindows_.begin();
it != propsWindows_.end(); it++) {
it != propsWindows_.end(); ++it) {
if ( (*it)->getBaseObjectDataId() == _obj->id() )
return *it;
}
......
......@@ -111,7 +111,7 @@ void BSplineCurveSelectionPlugin::deleteSelectedControlPoints(int _objectId) {
void BSplineCurveSelectionPlugin::selectControlPoints(int _objectId, const IdList _ids, bool _deselect) {
if(_ids.size() == 0) return;
if( _ids.empty()) return;
BaseObjectData* object = 0;
......@@ -279,7 +279,7 @@ void BSplineCurveSelectionPlugin::deleteSelectedKnots(int _objectId) {
void BSplineCurveSelectionPlugin::selectKnots(int _objectId, const IdList _ids, bool _deselect) {
if(_ids.size() == 0) return;
if(_ids.empty()) return;
BaseObjectData* object = 0;
......@@ -330,4 +330,4 @@ IdList BSplineCurveSelectionPlugin::getKnotSelection(int _objectId) {
}
return list;
}
\ No newline at end of file
}
......@@ -54,7 +54,7 @@
void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList ) {
if(_edgeList.size() == 0) return;
if(_edgeList.empty() ) return;
BaseObjectData* object = 0;
if ( ! PluginFunctions::getObject(objectId,object) ) {
......@@ -62,9 +62,6 @@ void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList ) {
return;
}
if ( _edgeList.size() == 0 )
return;
if ( object->dataType() == DATA_TRIANGLE_MESH )
MeshSelection::selectEdges(PluginFunctions::triMesh(object), _edgeList);
else if ( object->dataType() == DATA_POLY_MESH )
......@@ -90,7 +87,7 @@ void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList ) {
void MeshObjectSelectionPlugin::unselectEdges( int objectId , IdList _edgeList ) {
if(_edgeList.size() == 0) return;
if(_edgeList.empty()) return;
BaseObjectData* object;
if ( ! PluginFunctions::getObject(objectId,object) ) {
......@@ -98,9 +95,6 @@ void MeshObjectSelectionPlugin::unselectEdges( int objectId , IdList _edgeList )
return;
}
if ( _edgeList.size() == 0 )
return;
if ( object->dataType() == DATA_TRIANGLE_MESH )
MeshSelection::unselectEdges(PluginFunctions::triMesh(object), _edgeList);
else if ( object->dataType() == DATA_POLY_MESH )
......
......@@ -55,7 +55,7 @@
void MeshObjectSelectionPlugin::selectFaces(int objectId , IdList _faceList) {
if(_faceList.size() == 0) return;
if(_faceList.empty() ) return;
BaseObjectData* object = 0;
if (! PluginFunctions::getObject(objectId,object)) {
......@@ -63,9 +63,6 @@ void MeshObjectSelectionPlugin::selectFaces(int objectId , IdList _faceList) {
return;
}
if (_faceList.size() == 0)
return;
if (object->dataType() == DATA_TRIANGLE_MESH)
MeshSelection::selectFaces(PluginFunctions::triMesh(object), _faceList);
else if (object->dataType() == DATA_POLY_MESH)
......@@ -91,7 +88,7 @@ void MeshObjectSelectionPlugin::selectFaces(int objectId , IdList _faceList) {
void MeshObjectSelectionPlugin::unselectFaces(int objectId , IdList _faceList) {
if(_faceList.size() == 0) return;
if(_faceList.empty() ) return;
BaseObjectData* object = 0;
if (! PluginFunctions::getObject(objectId,object)) {
......@@ -99,9 +96,6 @@ void MeshObjectSelectionPlugin::unselectFaces(int objectId , IdList _faceList) {
return;
}
if (_faceList.size() == 0)
return;
if (object->dataType() == DATA_TRIANGLE_MESH)
MeshSelection::unselectFaces(PluginFunctions::triMesh(object), _faceList);
else if (object->dataType() == DATA_POLY_MESH)
......
......@@ -54,7 +54,7 @@
void MeshObjectSelectionPlugin::selectHalfedges(int objectId , IdList _halfedgeList) {
if(_halfedgeList.size() == 0) return;
if(_halfedgeList.empty() ) return;
BaseObjectData* object = 0;
if (! PluginFunctions::getObject(objectId,object)) {
......@@ -62,9 +62,6 @@ void MeshObjectSelectionPlugin::selectHalfedges(int objectId , IdList _halfedgeL
return;
}
if (_halfedgeList.size() == 0)
return;
if (object->dataType() == DATA_TRIANGLE_MESH)
MeshSelection::selectHalfedges(PluginFunctions::triMesh(object), _halfedgeList);
else if (object->dataType() == DATA_POLY_MESH)
......@@ -90,7 +87,7 @@ void MeshObjectSelectionPlugin::selectHalfedges(int objectId , IdList _halfedgeL
void MeshObjectSelectionPlugin::unselectHalfedges(int objectId , IdList _halfedgeList) {
if(_halfedgeList.size() == 0) return;
if(_halfedgeList.empty() ) return;
BaseObjectData* object = 0;
if (! PluginFunctions::getObject(objectId,object)) {
......@@ -98,9 +95,6 @@ void MeshObjectSelectionPlugin::unselectHalfedges(int objectId , IdList _halfedg
return;
}
if (_halfedgeList.size() == 0)
return;
if (object->dataType() == DATA_TRIANGLE_MESH)
MeshSelection::unselectHalfedges(PluginFunctions::triMesh(object), _halfedgeList);
else if (object->dataType() == DATA_POLY_MESH)
......
......@@ -54,7 +54,7 @@
void MeshObjectSelectionPlugin::selectVertices(int _objectId, IdList _vertexList) {
if(_vertexList.size() == 0) return;
if(_vertexList.empty() ) return;
BaseObjectData* object = 0;
if (!PluginFunctions::getObject(_objectId,object)) {
......@@ -62,9 +62,6 @@ void MeshObjectSelectionPlugin::selectVertices(int _objectId, IdList _vertexList
return;
}