Property browser will now show the properties.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent ed267a6587
commit 9ee24b3b93

@ -43,6 +43,7 @@ namespace MaterialEditor
void MatPropWidget::load( CRenderPassProxy *proxy )
{
clear();
changed = false;
this->proxy = new CRenderPassProxy( *proxy );
std::string n;
@ -74,7 +75,6 @@ namespace MaterialEditor
{
treeWidget->clear();
nameEdit->clear();
changed = false;
if( this->proxy != NULL )
{
delete this->proxy;

@ -47,6 +47,7 @@ namespace MaterialEditor
void MaterialSplitter::setupConnections()
{
connect( materialWidget, SIGNAL( propsChanged() ), this, SLOT( onPropsChanged() ) );
connect( materialWidget, SIGNAL( passChanged( const QString& ) ), this, SLOT( onPassChanged( const QString& ) ) );
}
void MaterialSplitter::setup()
@ -104,5 +105,10 @@ namespace MaterialEditor
materialWidget->getCurrentPass( pass );
browserCtrl->onPropsChanged();
}
void MaterialSplitter::onPassChanged( const QString &pass )
{
browserCtrl->loadPropsForPass( pass );
}
}

@ -58,6 +58,8 @@ namespace MaterialEditor
private Q_SLOTS:
void onPropsChanged();
void onPassChanged( const QString &pass );
};
}

@ -128,6 +128,7 @@ namespace MaterialEditor
{
connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) );
connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) );
connect( passCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onPassCBChanged( const QString& ) ) );
connect( shaderEditorWidget, SIGNAL( okClicked() ), this, SLOT( onShaderEditOKClicked() ) );
}
@ -153,5 +154,12 @@ namespace MaterialEditor
{
}
void MaterialWidget::onPassCBChanged( const QString &text )
{
if( text.isEmpty() )
return;
Q_EMIT passChanged( text );
}
}

@ -48,6 +48,7 @@ namespace MaterialEditor
Q_SIGNALS:
void propsChanged();
void passChanged( const QString &pass );
private:
void setupConnections();
@ -59,6 +60,7 @@ namespace MaterialEditor
void onPassEditClicked();
void onShaderEditClicked();
void onShaderEditOKClicked();
void onPassCBChanged( const QString &text );
};
}

@ -17,24 +17,163 @@
#include "prop_browser_ctrl.h"
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
#include "nel3d_interface.h"
namespace MaterialEditor
{
int propToQVariant( unsigned char t )
{
int type = 0;
switch( t )
{
case SMatProp::Color:
type = QVariant::String;
break;
case SMatProp::Double:
type = QVariant::Double;
break;
case SMatProp::Float:
type = QVariant::Double;
break;
case SMatProp::Int:
type = QVariant::Int;
break;
case SMatProp::Matrix4:
type = QVariant::String;
break;
case SMatProp::Texture:
type = QVariant::String;
break;
case SMatProp::Uint:
type = QVariant::UInt;
break;
case SMatProp::Vector4:
type = QVariant::String;
break;
default:
type = QVariant::String;
break;
}
return type;
}
void propValToQVariant( const SMatProp &p, QVariant &v )
{
bool ok = false;
QString s;
switch( p.type )
{
case SMatProp::Color:
v = p.value.c_str();
break;
case SMatProp::Double:
double d;
s = p.value.c_str();
d = s.toDouble( &ok );
if( ok )
v = d;
else
v = 0.0;
break;
case SMatProp::Float:
float f;
s = p.value.c_str();
f = s.toFloat( &ok );
if( ok )
v = f;
else
v = 0.0f;
break;
case SMatProp::Int:
int i;
s = p.value.c_str();
i = s.toInt( &ok );
if( ok )
v = i;
else
v = 0;
break;
case SMatProp::Matrix4:
v = p.value.c_str();
break;
case SMatProp::Texture:
v = p.value.c_str();
break;
case SMatProp::Uint:
unsigned int u;
s = p.value.c_str();
u = s.toUInt( &ok );
if( ok )
v = u;
else
v = 0u;
break;
case SMatProp::Vector4:
v = p.value.c_str();
break;
default:
v = "";
break;
}
}
CPropBrowserCtrl::CPropBrowserCtrl( QObject *parent ) :
QObject( parent )
{
browser = NULL;
nel3dIface = NULL;
manager = new QtVariantPropertyManager();
factory = new QtVariantEditorFactory();
}
CPropBrowserCtrl::~CPropBrowserCtrl()
{
browser = NULL;
nel3dIface = NULL;
delete manager;
manager = NULL;
delete factory;
factory = NULL;
}
void CPropBrowserCtrl::setBrowser( QtTreePropertyBrowser *b )
{
browser = b;
browser->setFactoryForManager( manager, factory );
}
void CPropBrowserCtrl::setNel3DIface( CNel3DInterface *iface )
@ -60,8 +199,37 @@ namespace MaterialEditor
void CPropBrowserCtrl::loadPropsForPass( const QString &pass )
{
currentPass = pass;
clearProps();
if( pass.isEmpty() )
return;
CNelMaterialProxy m = nel3dIface->getMaterial();
CRenderPassProxy p = m.getPass( pass.toUtf8().data() );
std::vector< SMatProp > v;
p.getProperties( v );
QtVariantProperty *vp = NULL;
int type = 0;
QVariant qv;
std::vector< SMatProp >::const_iterator itr = v.begin();
while( itr != v.end() )
{
const SMatProp &prop = *itr;
type = propToQVariant( prop.type );
vp = manager->addProperty( type, prop.label.c_str() );
propValToQVariant( prop, qv );
vp->setValue( qv );
browser->addProperty( vp );
++itr;
}
}
}

@ -21,6 +21,8 @@
#include <QObject>
class QtTreePropertyBrowser;
class QtVariantPropertyManager;
class QtVariantEditorFactory;
namespace MaterialEditor
{
@ -41,6 +43,9 @@ namespace MaterialEditor
private:
QtTreePropertyBrowser *browser;
QtVariantPropertyManager *manager;
QtVariantEditorFactory *factory;
CNel3DInterface *nel3dIface;
QString currentPass;
};

Loading…
Cancel
Save