Commit 3cc95064 authored by Martin Schultz's avatar Martin Schultz
Browse files

ran cppcheck and fixed some warnings

DrawModes constructor is now explicit which causes some changes:
e.g. if you used ACG::SceneGraph::DrawModes::TEXCOORD_PER_VERTEX
you now have to use
ACG::SceneGraph::DrawModes::DrawMode(ACG::SceneGraph::DrawModes::TEXCOORD_PER_VERTEX)
parent 58f9ec28
......@@ -611,7 +611,6 @@ ACG::Vec3f GLCone::normalOnCone(int _sliceNumber, int _stackNumber)
double beta = ((2.0 * M_PI) / slices_) * _sliceNumber;
double relativeHeight = _stackNumber / (double) stacks_;
double ringRadius = (1.0 - relativeHeight) * bottomRadius_ + relativeHeight * topRadius_;
normal[0] = sin(beta);
normal[1] = cos(beta);
......
......@@ -60,6 +60,7 @@
#include "QtShaderDialog.hh"
#include "../Scenegraph/ShaderNode.hh"
#include "../Scenegraph/DrawModes.hh"
#include <QFileInfo>
#include <QDir>
......@@ -137,10 +138,10 @@ void QtShaderDialog::applyChanges()
return;
}
unsigned int drawMode = 1;
SceneGraph::DrawModes::DrawMode drawMode = SceneGraph::DrawModes::DrawMode(1);
for ( int i = 0 ; i < ui_.drawModeBox->currentIndex() ; ++i )
drawMode *= 2;
++drawMode;
node_->setShader(drawMode,
std::string( ui_.vertexShader->text().toUtf8() ),
......@@ -162,10 +163,10 @@ void QtShaderDialog::undoChanges()
}
void QtShaderDialog::comboChanged ( int index ) {
unsigned int drawMode = 1;
ACG::SceneGraph::DrawModes::DrawMode drawMode = ACG::SceneGraph::DrawModes::DrawMode(1);
for ( int i = 0 ; i < index; ++i )
drawMode *= 2;
++drawMode;
QString vertexShader(node_->vertexShaderName(drawMode).c_str());
QString fragmentShader(node_->fragmentShaderName(drawMode).c_str());
......
......@@ -74,41 +74,41 @@ namespace DrawModes {
// == Default Draw Mode initialization ======================================
DrawMode NONE = ModeFlagSet(0);
DrawMode DEFAULT = ModeFlagSet(1);
DrawMode POINTS = ModeFlagSet(1) << 1;
DrawMode POINTS_COLORED = ModeFlagSet(1) << 2;
DrawMode POINTS_SHADED = ModeFlagSet(1) << 3;
DrawMode EDGES = ModeFlagSet(1) << 4;
DrawMode EDGES_COLORED = ModeFlagSet(1) << 5;
DrawMode WIREFRAME = ModeFlagSet(1) << 6;
DrawMode FACES = ModeFlagSet(1) << 7;
DrawMode HIDDENLINE = ModeFlagSet(1) << 8;
DrawMode SOLID_FLAT_SHADED = ModeFlagSet(1) << 9;
DrawMode SOLID_SMOOTH_SHADED = ModeFlagSet(1) << 10;
DrawMode SOLID_PHONG_SHADED = ModeFlagSet(1) << 11;
DrawMode SOLID_FACES_COLORED = ModeFlagSet(1) << 12;
DrawMode SOLID_POINTS_COLORED = ModeFlagSet(1) << 13;
DrawMode SOLID_POINTS_COLORED_SHADED = ModeFlagSet(1) << 14;
DrawMode SOLID_ENV_MAPPED = ModeFlagSet(1) << 15;
DrawMode SOLID_TEXTURED = ModeFlagSet(1) << 16;
DrawMode SOLID_TEXTURED_SHADED = ModeFlagSet(1) << 17;
DrawMode SOLID_1DTEXTURED = ModeFlagSet(1) << 18;
DrawMode SOLID_1DTEXTURED_SHADED = ModeFlagSet(1) << 19;
DrawMode SOLID_3DTEXTURED = ModeFlagSet(1) << 20;
DrawMode SOLID_3DTEXTURED_SHADED = ModeFlagSet(1) << 21;
DrawMode SOLID_FACES_COLORED_FLAT_SHADED = ModeFlagSet(1) << 22;
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED = ModeFlagSet(1) << 23;
DrawMode SOLID_2DTEXTURED_FACE = ModeFlagSet(1) << 24;
DrawMode SOLID_2DTEXTURED_FACE_SHADED = ModeFlagSet(1) << 25;
DrawMode SOLID_SHADER = ModeFlagSet(1) << 26;
DrawMode SOLID_SMOOTH_SHADED_FEATURES = ModeFlagSet(1) << 27;
DrawMode CELLS = ModeFlagSet(1) << 28;
DrawMode CELLS_COLORED = ModeFlagSet(1) << 29;
DrawMode HALFEDGES = ModeFlagSet(1) << 30;
DrawMode HALFEDGES_COLORED = ModeFlagSet(1) << 31;
DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED = ModeFlagSet(1) << 32;
DrawMode UNUSED = ModeFlagSet(1) << 33;
DrawMode NONE = DrawMode( ModeFlagSet(0) );
DrawMode DEFAULT = DrawMode( ModeFlagSet(1) );
DrawMode POINTS = DrawMode( ModeFlagSet(1) << 1 );
DrawMode POINTS_COLORED = DrawMode( ModeFlagSet(1) << 2 );
DrawMode POINTS_SHADED = DrawMode( ModeFlagSet(1) << 3 );
DrawMode EDGES = DrawMode( ModeFlagSet(1) << 4 );
DrawMode EDGES_COLORED = DrawMode( ModeFlagSet(1) << 5 );
DrawMode WIREFRAME = DrawMode( ModeFlagSet(1) << 6 );
DrawMode FACES = DrawMode( ModeFlagSet(1) << 7 );
DrawMode HIDDENLINE = DrawMode( ModeFlagSet(1) << 8 );
DrawMode SOLID_FLAT_SHADED = DrawMode( ModeFlagSet(1) << 9 );
DrawMode SOLID_SMOOTH_SHADED = DrawMode( ModeFlagSet(1) << 10 );
DrawMode SOLID_PHONG_SHADED = DrawMode( ModeFlagSet(1) << 11 );
DrawMode SOLID_FACES_COLORED = DrawMode( ModeFlagSet(1) << 12 );
DrawMode SOLID_POINTS_COLORED = DrawMode( ModeFlagSet(1) << 13 );
DrawMode SOLID_POINTS_COLORED_SHADED = DrawMode( ModeFlagSet(1) << 14 );
DrawMode SOLID_ENV_MAPPED = DrawMode( ModeFlagSet(1) << 15 );
DrawMode SOLID_TEXTURED = DrawMode( ModeFlagSet(1) << 16 );
DrawMode SOLID_TEXTURED_SHADED = DrawMode( ModeFlagSet(1) << 17 );
DrawMode SOLID_1DTEXTURED = DrawMode( ModeFlagSet(1) << 18 );
DrawMode SOLID_1DTEXTURED_SHADED = DrawMode( ModeFlagSet(1) << 19 );
DrawMode SOLID_3DTEXTURED = DrawMode( ModeFlagSet(1) << 20 );
DrawMode SOLID_3DTEXTURED_SHADED = DrawMode( ModeFlagSet(1) << 21 );
DrawMode SOLID_FACES_COLORED_FLAT_SHADED = DrawMode( ModeFlagSet(1) << 22 );
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED = DrawMode( ModeFlagSet(1) << 23 );
DrawMode SOLID_2DTEXTURED_FACE = DrawMode( ModeFlagSet(1) << 24 );
DrawMode SOLID_2DTEXTURED_FACE_SHADED = DrawMode( ModeFlagSet(1) << 25 );
DrawMode SOLID_SHADER = DrawMode( ModeFlagSet(1) << 26 );
DrawMode SOLID_SMOOTH_SHADED_FEATURES = DrawMode( ModeFlagSet(1) << 27 );
DrawMode CELLS = DrawMode( ModeFlagSet(1) << 28 );
DrawMode CELLS_COLORED = DrawMode( ModeFlagSet(1) << 29 );
DrawMode HALFEDGES = DrawMode( ModeFlagSet(1) << 30 );
DrawMode HALFEDGES_COLORED = DrawMode( ModeFlagSet(1) << 31 );
DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED = DrawMode( ModeFlagSet(1) << 32 );
DrawMode UNUSED = DrawMode( ModeFlagSet(1) << 33 );
//== IMPLEMENTATION ==========================================================
......@@ -299,7 +299,7 @@ DrawMode& DrawMode::operator++() {
}
DrawMode DrawMode::operator&(const DrawMode& _mode) const {
DrawMode andMode = (modeFlags_ & _mode.modeFlags_);
DrawMode andMode = DrawMode(modeFlags_ & _mode.modeFlags_);
andMode.setDrawModeProperties(getDrawModeProperties());
......@@ -347,7 +347,7 @@ DrawMode& DrawMode::operator&=( const DrawMode& _mode2 ) {
}
DrawMode DrawMode::operator|( const DrawMode& _mode2 ) const {
DrawMode combined = ( modeFlags_ | _mode2.modeFlags_ );
DrawMode combined = DrawMode( modeFlags_ | _mode2.modeFlags_ );
combined.setDrawModeProperties(getDrawModeProperties());
......@@ -362,7 +362,7 @@ DrawMode DrawMode::operator|( const DrawMode& _mode2 ) const {
DrawMode DrawMode::operator^( const DrawMode& _mode2 ) const {
DrawMode xorMode = ( modeFlags_ ^ _mode2.modeFlags_ );
DrawMode xorMode = DrawMode( modeFlags_ ^ _mode2.modeFlags_ );
// xor on properties
......@@ -432,7 +432,7 @@ DrawMode DrawMode::operator^( const DrawMode& _mode2 ) const {
}
DrawMode DrawMode::operator~( ) const {
return( ~modeFlags_ );
return( DrawMode(~modeFlags_) );
}
......
......@@ -307,7 +307,7 @@ namespace DrawModes {
*
* @param _index Index of the new DrawMode
*/
DrawMode(size_t _index);
explicit DrawMode(size_t _index);
/** \brief constructor for ModeFlags.
*
......@@ -316,7 +316,7 @@ namespace DrawModes {
*
* @param _flags Flags for the new drawmode defined by a bitset
*/
DrawMode( const ModeFlagSet& _flags );
explicit DrawMode( const ModeFlagSet& _flags );
/* \brief Returns a registered draw mode based on the description passed or if none could be found the default one.
*
......
......@@ -72,8 +72,8 @@ namespace SceneGraph {
//== IMPLEMENTATION ==========================================================
GlutPrimitiveNode::GlutPrimitiveNode( BaseNode* _parent,
std::string _name )
GlutPrimitiveNode::GlutPrimitiveNode( BaseNode* _parent,
const std::string & _name )
: BaseNode(_parent, _name),
setColor_(true)
{
......@@ -85,9 +85,9 @@ GlutPrimitiveNode::GlutPrimitiveNode( BaseNode* _parent,
//----------------------------------------------------------------------------
GlutPrimitiveNode::GlutPrimitiveNode(GlutPrimitiveType _type,
BaseNode* _parent,
std::string _name) :
GlutPrimitiveNode::GlutPrimitiveNode(GlutPrimitiveType _type,
BaseNode* _parent,
const std::string & _name) :
BaseNode(_parent, _name),
setColor_(true)
{
......
......@@ -175,13 +175,13 @@ public:
};
GlutPrimitiveNode( BaseNode* _parent=0,
std::string _name="<GlutPrimitive>" );
GlutPrimitiveNode( BaseNode* _parent=0,
const std::string & _name="<GlutPrimitive>" );
GlutPrimitiveNode( GlutPrimitiveType _type,
BaseNode* _parent=0,
std::string _name="<GlutPrimitive>" );
GlutPrimitiveNode( GlutPrimitiveType _type,
BaseNode* _parent=0,
const std::string & _name="<GlutPrimitive>" );
/// destructor
......
......@@ -127,7 +127,7 @@ void
ShaderNode::enter(GLState& /*_state*/, const DrawModes::DrawMode& _drawmode )
{
for ( std::map<size_t,ShaderInfo>::iterator it = shaders.begin(); it != shaders.end(); ++it) {
if ( _drawmode.containsAtomicDrawMode(it->first) && it->second.initialized ) {
if ( _drawmode.containsAtomicDrawMode(DrawModes::DrawMode(it->first)) && it->second.initialized ) {
it->second.program->use();
}
}
......@@ -139,7 +139,7 @@ void
ShaderNode::enterPick(GLState& /*_state*/, PickTarget /*_target*/, const DrawModes::DrawMode& _drawmode )
{
for ( std::map<size_t,ShaderInfo>::iterator it = pickShaders.begin(); it != pickShaders.end(); ++it) {
if ( _drawmode.containsAtomicDrawMode(it->first) && it->second.initialized ) {
if ( _drawmode.containsAtomicDrawMode(DrawModes::DrawMode(it->first)) && it->second.initialized ) {
it->second.program->use();
}
}
......@@ -206,7 +206,7 @@ ShaderNode::fragmentShaderName(DrawModes::DrawMode _drawmode, bool _pick) {
void ShaderNode::leave(GLState& /*_state*/, const DrawModes::DrawMode& _drawmode )
{
for ( std::map<size_t,ShaderInfo>::iterator it = shaders.begin(); it != shaders.end(); ++it)
if ( _drawmode.containsAtomicDrawMode(it->first) && it->second.initialized )
if ( _drawmode.containsAtomicDrawMode(DrawModes::DrawMode(it->first)) && it->second.initialized )
it->second.program->disable();
}
......@@ -216,7 +216,7 @@ void ShaderNode::leave(GLState& /*_state*/, const DrawModes::DrawMode& _drawmode
void ShaderNode::leavePick(GLState& /*_state*/, PickTarget /*_target*/, const DrawModes::DrawMode& _drawmode )
{
for ( std::map<size_t,ShaderInfo>::iterator it = pickShaders.begin(); it != pickShaders.end(); ++it)
if ( _drawmode.containsAtomicDrawMode(it->first) && it->second.initialized )
if ( _drawmode.containsAtomicDrawMode(DrawModes::DrawMode(it->first)) && it->second.initialized )
it->second.program->disable();
}
......
......@@ -113,7 +113,7 @@ SliceNode::boundingBox( Vec3d & _bbMin, Vec3d & _bbMax )
DrawModes::DrawMode
SliceNode::availableDrawModes() const
{
return 0;
return DrawModes::DrawMode(0);
/*
return ( DrawModes::POINTS |
DrawModes::WIREFRAME |
......
......@@ -878,7 +878,7 @@ void CoreWidget::slotViewerDrawMenu(QAction * _action) {
//======================================================================================
// Get the mode toggled
//======================================================================================
ACG::SceneGraph::DrawModes::DrawMode mode = 0;
ACG::SceneGraph::DrawModes::DrawMode mode = ACG::SceneGraph::DrawModes::DrawMode(0);
std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes();
for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
......
......@@ -101,7 +101,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
ACG::SceneGraph::DrawModes::ModeFlagSet mode(2);
for (uint i=1; i < 22; i++) {
std::vector< QString > dm = drawModeToDescriptions( mode );
std::vector< QString > dm = drawModeToDescriptions( ACG::SceneGraph::DrawModes::DrawMode(mode) );
if ( !dm.empty() && dm[0].trimmed() != ""){
QListWidgetItem* item = new QListWidgetItem(dm[0]);
......
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