diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/CMakeLists.txt index 19e67cb1a..51b30e6fe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/CMakeLists.txt @@ -19,6 +19,7 @@ SET(OVQT_PLUGIN_MATERIAL_EDITOR_HDR material_property_editor.h material_widget.h render_passes.h + shader_editor.h ) SET(OVQT_PLUGIN_MATERIAL_EDITOR_UIS @@ -27,6 +28,7 @@ SET(OVQT_PLUGIN_MATERIAL_EDITOR_UIS material_property_editor.ui material_widget.ui render_passes.ui + shader_editor.ui ) SET(QT_USE_QTGUI TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp index 33ba4debf..c88b70d2a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp @@ -16,6 +16,7 @@ #include "material_widget.h" #include "render_passes.h" +#include "shader_editor.h" namespace MaterialEditor { @@ -25,6 +26,7 @@ namespace MaterialEditor { setupUi( this ); renderPassesWidget = new RenderPassesWidget(); + shaderEditorWidget = new ShaderEditorWidget(); setupConnections(); } @@ -32,19 +34,31 @@ namespace MaterialEditor { delete renderPassesWidget; renderPassesWidget = NULL; + delete shaderEditorWidget; + shaderEditorWidget = NULL; } void MaterialWidget::setupConnections() { connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) ); + connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) ); + + connect( renderPassesWidget, SIGNAL( passAdded( const QString& ) ), + this, SLOT( onPassAdded( const QString& ) ) ); + + connect( renderPassesWidget, SIGNAL( passRemoved( const QString& ) ), + this, SLOT( onPassRemoved( const QString& ) ) ); - connect( renderPassesWidget, SIGNAL( okClicked() ), this, SLOT( onPassOKClicked() ) ); connect( renderPassesWidget, SIGNAL( passRenamed( const QString&, const QString& ) ), this, SLOT( onPassRenamed( const QString&, const QString& ) ) ); + connect( renderPassesWidget, SIGNAL( passPushedUp( const QString& ) ), this, SLOT( onPassPushedUp( const QString& ) ) ); + connect( renderPassesWidget, SIGNAL( passPushedDown( const QString& ) ), this, SLOT( onPassPushedDown( const QString& ) ) ); + + connect( shaderEditorWidget, SIGNAL( okClicked() ), this, SLOT( onShaderEditOKClicked() ) ); } void MaterialWidget::onPassEditClicked() @@ -52,19 +66,68 @@ namespace MaterialEditor renderPassesWidget->show(); } - void MaterialWidget::onPassOKClicked() + void MaterialWidget::onShaderEditClicked() + { + shaderEditorWidget->show(); + } + + void MaterialWidget::onPassAdded( const QString &pass ) + { + passCB->addItem( pass ); + } + + void MaterialWidget::onPassRemoved( const QString &pass ) { + int i = passCB->findText( pass ); + if( i == -1 ) + return; + + passCB->removeItem( i ); } void MaterialWidget::onPassRenamed( const QString &from, const QString &to ) { + int i = passCB->findText( from ); + if( i == -1 ) + return; + passCB->setItemText( i, to ); } void MaterialWidget::onPassPushedUp( const QString &pass ) { + int i = passCB->findText( pass ); + if( i == -1 ) + return; + + if( i == 0 ) + return; + + QString temp = passCB->itemText( i - 1 ); + passCB->setItemText( i - 1, pass ); + passCB->setItemText( i, temp ); + + if( passCB->currentIndex() == i ) + passCB->setCurrentIndex( i - 1 ); } void MaterialWidget::onPassPushedDown( const QString &pass ) + { + int i = passCB->findText( pass ); + if( i == -1 ) + return; + + if( i == ( passCB->count() - 1 ) ) + return; + + QString temp = passCB->itemText( i + 1 ); + passCB->setItemText( i + 1, pass ); + passCB->setItemText( i, temp ); + + if( passCB->currentIndex() == i ) + passCB->setCurrentIndex( i + 1 ); + } + + void MaterialWidget::onShaderEditOKClicked() { } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h index 332b779b7..b2c422e5b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h @@ -23,6 +23,7 @@ namespace MaterialEditor { class RenderPassesWidget; + class ShaderEditorWidget; class MaterialWidget : public QWidget, Ui::MaterialWidget { @@ -34,13 +35,19 @@ namespace MaterialEditor private: void setupConnections(); RenderPassesWidget *renderPassesWidget; + ShaderEditorWidget *shaderEditorWidget; private Q_SLOTS: void onPassEditClicked(); - void onPassOKClicked(); + void onShaderEditClicked(); + + void onPassAdded( const QString &pass ); + void onPassRemoved( const QString &pass ); void onPassRenamed( const QString &from, const QString &to ); void onPassPushedUp( const QString &pass ); void onPassPushedDown( const QString &pass ); + + void onShaderEditOKClicked(); }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp index add812d84..4c7927ea7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp @@ -58,7 +58,6 @@ namespace MaterialEditor void RenderPassesWidget::setupConnections() { connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); - connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) ); @@ -67,12 +66,6 @@ namespace MaterialEditor } void RenderPassesWidget::onOKClicked() - { - close(); - Q_EMIT okClicked(); - } - - void RenderPassesWidget::onCancelClicked() { close(); } @@ -111,6 +104,7 @@ namespace MaterialEditor } listWidget->addItem( label ); + Q_EMIT passAdded( label ); } void RenderPassesWidget::onRemoveClicked() @@ -118,9 +112,13 @@ namespace MaterialEditor int row = listWidget->currentRow(); if( row == -1 ) return; + QString pass; QListWidgetItem *item = listWidget->takeItem( row ); + pass = item->text(); delete item; + + Q_EMIT passRemoved( pass ); } void RenderPassesWidget::onEditClicked() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h index 1bdbe30f4..4608484f0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h @@ -34,6 +34,8 @@ namespace MaterialEditor Q_SIGNALS: void okClicked(); + void passAdded( const QString &pass ); + void passRemoved( const QString &pass ); void passRenamed( const QString &from, const QString &to ); void passPushedUp( const QString &pass ); void passPushedDown( const QString &pass ); @@ -43,7 +45,6 @@ namespace MaterialEditor private Q_SLOTS: void onOKClicked(); - void onCancelClicked(); void onAddClicked(); void onRemoveClicked(); void onEditClicked(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.ui index 815f59810..c8907d4f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.ui @@ -125,19 +125,6 @@ - - - - - 0 - 0 - - - - Cancel - - - diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp new file mode 100644 index 000000000..2430c0b2e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp @@ -0,0 +1,91 @@ +// Object Viewer Qt Material Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "shader_editor.h" + +namespace MaterialEditor +{ + ShaderEditorWidget::ShaderEditorWidget( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + setupConnections(); + } + + ShaderEditorWidget::~ShaderEditorWidget() + { + } + + void ShaderEditorWidget::getName( QString &name ) + { + name = nameEdit->text(); + } + + void ShaderEditorWidget::getDescription( QString &desc ) + { + desc = descriptionEdit->toPlainText(); + } + + void ShaderEditorWidget::getVertexShader( QString &vs ) + { + vs = vsEdit->toPlainText(); + } + + void ShaderEditorWidget::getFragmentShader( QString &fs ) + { + fs = fsEdit->toPlainText(); + } + + void ShaderEditorWidget::setName( const QString &name ) + { + nameEdit->setText( name ); + } + + void ShaderEditorWidget::setDescription( const QString &desc ) + { + descriptionEdit->setPlainText( desc ); + } + + void ShaderEditorWidget::setVertexShader( const QString &vs ) + { + vsEdit->setPlainText( vs ); + } + + void ShaderEditorWidget::setFragmentShader( const QString &fs ) + { + fsEdit->setPlainText( fs ); + } + + void ShaderEditorWidget::setupConnections() + { + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ) ; + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + } + + void ShaderEditorWidget::onOKClicked() + { + close(); + Q_EMIT okClicked(); + } + + void ShaderEditorWidget::onCancelClicked() + { + close(); + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h new file mode 100644 index 000000000..b63032aa4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h @@ -0,0 +1,55 @@ +// Object Viewer Qt Material Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef SHADER_EDITOR_H +#define SHADER_EDITOR_H + +#include "ui_shader_editor.h" + +namespace MaterialEditor +{ + class ShaderEditorWidget : public QWidget, public Ui::ShaderEditorWidget + { + Q_OBJECT + public: + ShaderEditorWidget( QWidget *parent = NULL ); + ~ShaderEditorWidget(); + + void getName( QString &name ); + void getDescription( QString &desc ); + void getVertexShader( QString &vs ); + void getFragmentShader( QString &fs ); + + void setName( const QString &name ); + void setDescription( const QString &desc ); + void setVertexShader( const QString &vs ); + void setFragmentShader( const QString &fs ); + + private Q_SLOTS: + void onOKClicked(); + void onCancelClicked(); + + Q_SIGNALS: + void okClicked(); + + private: + void setupConnections(); + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.ui new file mode 100644 index 000000000..db0ca7fd7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.ui @@ -0,0 +1,123 @@ + + + ShaderEditorWidget + + + Qt::ApplicationModal + + + + 0 + 0 + 750 + 729 + + + + Shader Editor + + + + + + + + Name + + + + + + + + + + + + + + Description + + + + + + + + + + + + + + Vertex Shader + + + + + + + + + + + + + + Fragment Shader + + + + + + + + + + + + + + + 0 + 0 + + + + OK + + + + + + + + 0 + 0 + + + + Cancel + + + + + + + Qt::Horizontal + + + + 468 + 20 + + + + + + + + + + +