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( 0, Qt::DisplayRole, QString( mp.id.c_str() ) );
item->setData( 1, Qt::DisplayRole, QString( mp.label.c_str() ) ); item->setData( 1, Qt::DisplayRole, QString( mp.label.c_str() ) );
QString type; QString type = SMatProp::typeIdToString( mp.type ).c_str();
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;
}
item->setData( 2, Qt::DisplayRole, type ); item->setData( 2, Qt::DisplayRole, type );
treeWidget->addTopLevelItem( item ); treeWidget->addTopLevelItem( item );
@ -118,39 +87,16 @@ namespace MaterialEditor
std::vector< SMatProp > v; std::vector< SMatProp > v;
SMatProp p; SMatProp p;
QTreeWidgetItem *item = NULL; QTreeWidgetItem *item = NULL;
std::string s;
for( int i = 0; i < treeWidget->topLevelItemCount(); i++ ) for( int i = 0; i < treeWidget->topLevelItemCount(); i++ )
{ {
item = treeWidget->topLevelItem( i ); item = treeWidget->topLevelItem( i );
p.id = item->text( 0 ).toUtf8().data(); p.id = item->text( 0 ).toUtf8().data();
p.label = item->text( 1 ).toUtf8().data(); p.label = item->text( 1 ).toUtf8().data();
std::string t = item->text( 2 ).toUtf8().data(); s = item->text( 2 ).toUtf8().data();
if( t == "Color" ) p.type = SMatProp::typeStringToId( s );
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;
v.push_back( p ); v.push_back( p );
} }

@ -23,6 +23,34 @@
namespace MaterialEditor 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 ) void CRenderPassProxy::getProperties( std::vector< SMatProp > &v )
{ {
uint32 count = pass->count(); uint32 count = pass->count();

@ -41,13 +41,20 @@ namespace MaterialEditor
Int, Int,
Uint, Uint,
Matrix4, 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 id;
std::string label; std::string label;
unsigned char type; unsigned char type;
std::string value; std::string value;
private:
static const char *idToString[];
}; };
class CRenderPassProxy class CRenderPassProxy

Loading…
Cancel
Save