Little bit of refactoring.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent 832178a83f
commit c9605dde57

@ -60,38 +60,7 @@ namespace MaterialEditor
item->setData( 0, Qt::DisplayRole, QString( mp.id.c_str() ) );
item->setData( 1, Qt::DisplayRole, QString( mp.label.c_str() ) );
QString type;
switch( mp.type )
{
case SMatProp::Color:
type = "Color";
break;
case SMatProp::Double:
type = "Double";
break;
case SMatProp::Float:
type = "Float";
break;
case SMatProp::Int:
type = "Int";
break;
case SMatProp::Matrix4:
type = "Matrix4";
break;
case SMatProp::Texture:
type = "Texture";
break;
case SMatProp::Uint:
type = "UInt";
break;
case SMatProp::Vector4:
type = "Vector4";
break;
default:
type = "";
break;
}
QString type = SMatProp::typeIdToString( mp.type ).c_str();
item->setData( 2, Qt::DisplayRole, type );
treeWidget->addTopLevelItem( item );
@ -118,39 +87,16 @@ namespace MaterialEditor
std::vector< SMatProp > v;
SMatProp p;
QTreeWidgetItem *item = NULL;
std::string s;
for( int i = 0; i < treeWidget->topLevelItemCount(); i++ )
{
item = treeWidget->topLevelItem( i );
p.id = item->text( 0 ).toUtf8().data();
p.label = item->text( 1 ).toUtf8().data();
std::string t = item->text( 2 ).toUtf8().data();
if( t == "Color" )
p.type = SMatProp::Color;
else
if( t == "Double" )
p.type = SMatProp::Double;
else
if( t == "Float" )
p.type = SMatProp::Float;
else
if( t == "Int" )
p.type = SMatProp::Int;
else
if( t == "Matrix4" )
p.type = SMatProp::Matrix4;
else
if( t == "Texture" )
p.type = SMatProp::Texture;
else
if( t == "UInt" )
p.type = SMatProp::Uint;
else
if( t == "Vector4" )
p.type = SMatProp::Vector4;
else
p.type = SMatProp::Int;
s = item->text( 2 ).toUtf8().data();
p.type = SMatProp::typeStringToId( s );
v.push_back( p );
}

@ -23,6 +23,34 @@
namespace MaterialEditor
{
const char *SMatProp::idToString[] =
{
"Color",
"Vector4",
"Float",
"Double",
"Int",
"Uint",
"Matrix4",
"Texture"
};
std::string SMatProp::typeIdToString( unsigned char id )
{
if( id >= EType_count )
return std::string();
else
return std::string( idToString[ id ] );
}
unsigned char SMatProp::typeStringToId( const std::string &s )
{
for( unsigned char i = 0; i < EType_count; i++ )
if( s == idToString[ i ] )
return i;
return 0;
}
void CRenderPassProxy::getProperties( std::vector< SMatProp > &v )
{
uint32 count = pass->count();

@ -41,13 +41,20 @@ namespace MaterialEditor
Int,
Uint,
Matrix4,
Texture
Texture,
EType_count
};
static std::string typeIdToString( unsigned char type );
static unsigned char typeStringToId( const std::string &s );
std::string id;
std::string label;
unsigned char type;
std::string value;
private:
static const char *idToString[];
};
class CRenderPassProxy

Loading…
Cancel
Save