+ included a few files left out of last checkin.
+ Creating new shader parameters UI objects using shader info. (WIP)
+ Moved shaderInfo to start using shString instead of std::string
+ fixed a couple of warnings
http://code.google.com/p/shaderz/source/detail?r=20
Added:
/trunk/include/shparameterwidgetui.h
/trunk/include/shshaderparametercontainer.h
/trunk/src/shshaderparametercontainer.cpp
Modified:
/trunk/Makefile
/trunk/include/shdefs.h
/trunk/include/shshaderinfo.h
/trunk/shaderz.pro
/trunk/src/shmaterialeditordialog.cpp
/trunk/src/shshaderinfo.cpp
/trunk/ui/shmaterialeditordialog.ui
=======================================
--- /dev/null
+++ /trunk/include/shparameterwidgetui.h Sun Mar 21 14:48:06 2010
@@ -0,0 +1,25 @@
+#ifndef SHPARAMETERWIDGETUI_H
+#define SHPARAMETERWIDGETUI_H
+
+#include "shdefs.h"
+#include "shshaderinfo.h"
+
+class shParameterWidgetUI : public Shaderz::shWidget
+{
+public:
+ shParameterWidgetUI(Shaderz::shWidget* pParent, const
Shaderz::shShaderInfo::shShaderParameter& paramInfo);
+ ~shParameterWidgetUI();
+
+public slots:
+ void resizeEvent( Shaderz::shResizeEvent* pEventInfo );
+
+protected:
+ const Shaderz::shShaderInfo::shShaderParameter& m_paramInfo;
+ int m_iBorder;
+ Shaderz::shLabel* m_pLabel;
+
+private:
+ typedef Shaderz::shWidget ParentClass;
+};
+
+#endif // SHPARAMETERWIDGETUI_H
=======================================
--- /dev/null
+++ /trunk/include/shshaderparametercontainer.h Sun Mar 21 14:48:06 2010
@@ -0,0 +1,20 @@
+#ifndef SHSHADERPARAMETERCONTAINER_H
+#define SHSHADERPARAMETERCONTAINER_H
+
+#include "qtwidgets/shcontainerwidget.h"
+#include "shshaderinfo.h"
+
+class shShaderParameterContainer : public shContainerWidget
+{
+ Q_OBJECT
+
+public:
+ shShaderParameterContainer(Shaderz::shWidget* pParent);
+
+ void setupUI( const Shaderz::shShaderInfo* pShaderInfo );
+
+private:
+ typedef shContainerWidget ParentClass;
+};
+
+#endif // SHSHADERPARAMETERCONTAINER_H
=======================================
--- /dev/null
+++ /trunk/src/shshaderparametercontainer.cpp Sun Mar 21 14:48:06 2010
@@ -0,0 +1,33 @@
+#include "include/shshaderparametercontainer.h"
+#include "shdefs.h"
+#include "shparameterwidgetui.h"
+#include "shlogger.h"
+
+using namespace Shaderz;
+
+shShaderParameterContainer::shShaderParameterContainer(shWidget* pParent)
+ : ParentClass(pParent)
+{
+}
+
+void shShaderParameterContainer::setupUI( const shShaderInfo* pShaderInfo )
+{
+ if( !pShaderInfo )
+ {
+ return;
+ }
+
+ const std::vector<shShaderInfo::shShaderParameter>& paramList =
pShaderInfo->getParameters();
+ unsigned int index;
+ int widgetWidth = 30;
+ int spacing = 10;
+
+ for( index=0; index<paramList.size(); ++index )
+ {
+ shRect rect( 20, spacing + index*widgetWidth, 100, widgetWidth );
+ shParameterWidgetUI* pLabel = new shParameterWidgetUI(
getContainer(), paramList[index]);
+ pLabel->setGeometry(rect);
+ pLabel->setVisible(true);
+ addChildWidget( pLabel );
+ }
+}
=======================================
--- /trunk/Makefile Thu Mar 11 14:28:24 2010
+++ /trunk/Makefile Sun Mar 21 14:48:06 2010
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: shaderz.app/Contents/MacOS/shaderz
-# Generated by qmake (2.01a) (Qt 4.5.3) on: Fri Mar 12 06:10:12 2010
+# Generated by qmake (2.01a) (Qt 4.5.3) on: Wed Mar 17 22:48:13 2010
# Project: shaderz.pro
# Template: app
# Command: /usr/bin/qmake -spec /usr/local/Qt4.5/mkspecs/macx-g++ -macx -o
Makefile shaderz.pro
@@ -54,10 +54,13 @@
src/shmaterialeditordialog.cpp \
src/shshaderprogram.cpp \
src/shshaderinfo.cpp \
- src/qtwidgets/shcontainerwidget.cpp moc_shaderzmain.cpp \
+ src/qtwidgets/shcontainerwidget.cpp \
+ src/shshaderparametercontainer.cpp \
+ src/shparameterwidgetui.cpp moc_shaderzmain.cpp \
moc_shmaterialcontainer.cpp \
moc_shmaterialeditordialog.cpp \
- moc_shcontainerwidget.cpp
+ moc_shcontainerwidget.cpp \
+ moc_shshaderparametercontainer.cpp
OBJECTS = obj/main.o \
obj/shaderzmain.o \
obj/osgadapterwidget.o \
@@ -70,10 +73,13 @@
obj/shshaderprogram.o \
obj/shshaderinfo.o \
obj/shcontainerwidget.o \
+ obj/shshaderparametercontainer.o \
+ obj/shparameterwidgetui.o \
obj/moc_shaderzmain.o \
obj/moc_shmaterialcontainer.o \
obj/moc_shmaterialeditordialog.o \
- obj/moc_shcontainerwidget.o
+ obj/moc_shcontainerwidget.o \
+ obj/moc_shshaderparametercontainer.o
DIST = /usr/local/Qt4.5/mkspecs/common/unix.conf \
/usr/local/Qt4.5/mkspecs/common/mac.conf \
/usr/local/Qt4.5/mkspecs/common/mac-g++.conf \
@@ -222,7 +228,7 @@
@sed -e "s,@ICON@,,g" -e "s,@EXECUTABLE@,shaderz,g"
-e "s,@TYPEINFO@,????,g" /usr/local/Qt4.5/mkspecs/macx-g++/Info.plist.app
>shaderz.app/Contents/Info.plist
dist:
@$(CHK_DIR_EXISTS) obj/shaderz1.0.0 || $(MKDIR) obj/shaderz1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/shaderz1.0.0/ &&
$(COPY_FILE) --parents include/shaderzmain.h
include/qtwidgets/osgadapterwidget.h include/shlogger.h
include/shmaterialinstance.h include/shmaterialcontainer.h include/shhud.h
include/qtwidgets/shaderz_qtviewwidget.h include/shmaterialeditordialog.h
include/shshaderprogram.h include/shshaderinfo.h
include/qtwidgets/shcontainerwidget.h include/shdefs.h obj/shaderz1.0.0/ &&
$(COPY_FILE) --parents src/main.cpp src/shaderzmain.cpp
src/qtwidgets/osgadapterwidget.cpp src/shlogger.cpp
src/shmaterialinstance.cpp src/shmaterialcontainer.cpp src/shhud.cpp
src/qtwidgets/shaderz_qtviewwidget.cpp src/shmaterialeditordialog.cpp
src/shshaderprogram.cpp src/shshaderinfo.cpp
src/qtwidgets/shcontainerwidget.cpp obj/shaderz1.0.0/ && $(COPY_FILE)
--parents ui/shaderzmain.ui ui/shmaterialeditordialog.ui obj/shaderz1.0.0/
&& (cd `dirname obj/shaderz1.0.0` && $(TAR) shaderz1.0.0.tar shaderz1.0.0
&& $(COMPRESS) shaderz1.0.0.tar) && $(MOVE) `dirname
obj/shaderz1.0.0`/shaderz1.0.0.tar.gz . && $(DEL_FILE) -r obj/shaderz1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/shaderz1.0.0/ &&
$(COPY_FILE) --parents include/shaderzmain.h
include/qtwidgets/osgadapterwidget.h include/shlogger.h
include/shmaterialinstance.h include/shmaterialcontainer.h include/shhud.h
include/qtwidgets/shaderz_qtviewwidget.h include/shmaterialeditordialog.h
include/shshaderprogram.h include/shshaderinfo.h
include/qtwidgets/shcontainerwidget.h include/shdefs.h
include/shshaderparametercontainer.h include/shparameterwidgetui.h
obj/shaderz1.0.0/ && $(COPY_FILE) --parents src/main.cpp
src/shaderzmain.cpp src/qtwidgets/osgadapterwidget.cpp src/shlogger.cpp
src/shmaterialinstance.cpp src/shmaterialcontainer.cpp src/shhud.cpp
src/qtwidgets/shaderz_qtviewwidget.cpp src/shmaterialeditordialog.cpp
src/shshaderprogram.cpp src/shshaderinfo.cpp
src/qtwidgets/shcontainerwidget.cpp src/shshaderparametercontainer.cpp
src/shparameterwidgetui.cpp obj/shaderz1.0.0/ && $(COPY_FILE) --parents
ui/shaderzmain.ui ui/shmaterialeditordialog.ui obj/shaderz1.0.0/ && (cd
`dirname obj/shaderz1.0.0` && $(TAR) shaderz1.0.0.tar shaderz1.0.0 &&
$(COMPRESS) shaderz1.0.0.tar) && $(MOVE) `dirname
obj/shaderz1.0.0`/shaderz1.0.0.tar.gz . && $(DEL_FILE) -r obj/shaderz1.0.0
clean:compiler_clean
@@ -243,9 +249,9 @@
compiler_objective_c_make_all:
compiler_objective_c_clean:
-compiler_moc_header_make_all: moc_shaderzmain.cpp
moc_shmaterialcontainer.cpp moc_shmaterialeditordialog.cpp
moc_shcontainerwidget.cpp
+compiler_moc_header_make_all: moc_shaderzmain.cpp
moc_shmaterialcontainer.cpp moc_shmaterialeditordialog.cpp
moc_shcontainerwidget.cpp moc_shshaderparametercontainer.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) moc_shaderzmain.cpp moc_shmaterialcontainer.cpp
moc_shmaterialeditordialog.cpp moc_shcontainerwidget.cpp
+ -$(DEL_FILE) moc_shaderzmain.cpp moc_shmaterialcontainer.cpp
moc_shmaterialeditordialog.cpp moc_shcontainerwidget.cpp
moc_shshaderparametercontainer.cpp
moc_shaderzmain.cpp: include/shaderzmain.h
/Developer/Tools/Qt/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__
include/shaderzmain.h -o moc_shaderzmain.cpp
@@ -258,6 +264,11 @@
moc_shcontainerwidget.cpp: include/qtwidgets/shcontainerwidget.h
/Developer/Tools/Qt/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__
include/qtwidgets/shcontainerwidget.h -o moc_shcontainerwidget.cpp
+moc_shshaderparametercontainer.cpp: include/qtwidgets/shcontainerwidget.h \
+ include/shshaderinfo.h \
+ include/shshaderparametercontainer.h
+ /Developer/Tools/Qt/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__
include/shshaderparametercontainer.h -o moc_shshaderparametercontainer.cpp
+
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
@@ -273,8 +284,7 @@
ui_shaderzmain.h: ui/shaderzmain.ui
/Developer/Tools/Qt/uic ui/shaderzmain.ui -o ui_shaderzmain.h
-ui_shmaterialeditordialog.h: ui/shmaterialeditordialog.ui \
- include/qtwidgets/shcontainerwidget.h
+ui_shmaterialeditordialog.h: ui/shmaterialeditordialog.ui
/Developer/Tools/Qt/uic ui/shmaterialeditordialog.ui -o
ui_shmaterialeditordialog.h
compiler_yacc_decl_make_all:
@@ -311,8 +321,7 @@
obj/shaderz_qtviewwidget.o: src/qtwidgets/shaderz_qtviewwidget.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/shaderz_qtviewwidget.o
src/qtwidgets/shaderz_qtviewwidget.cpp
-obj/shmaterialeditordialog.o: src/shmaterialeditordialog.cpp
ui_shmaterialeditordialog.h \
- include/qtwidgets/shcontainerwidget.h
+obj/shmaterialeditordialog.o: src/shmaterialeditordialog.cpp
ui_shmaterialeditordialog.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/shmaterialeditordialog.o
src/shmaterialeditordialog.cpp
obj/shshaderprogram.o: src/shshaderprogram.cpp
@@ -324,6 +333,15 @@
obj/shcontainerwidget.o: src/qtwidgets/shcontainerwidget.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/shcontainerwidget.o
src/qtwidgets/shcontainerwidget.cpp
+obj/shshaderparametercontainer.o: src/shshaderparametercontainer.cpp
include/shshaderparametercontainer.h \
+ include/qtwidgets/shcontainerwidget.h \
+ include/shshaderinfo.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/shshaderparametercontainer.o
src/shshaderparametercontainer.cpp
+
+obj/shparameterwidgetui.o: src/shparameterwidgetui.cpp
include/shparameterwidgetui.h \
+ include/shdefs.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/shparameterwidgetui.o
src/shparameterwidgetui.cpp
+
obj/moc_shaderzmain.o: moc_shaderzmain.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_shaderzmain.o
moc_shaderzmain.cpp
@@ -336,6 +354,9 @@
obj/moc_shcontainerwidget.o: moc_shcontainerwidget.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_shcontainerwidget.o
moc_shcontainerwidget.cpp
+obj/moc_shshaderparametercontainer.o: moc_shshaderparametercontainer.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_shshaderparametercontainer.o
moc_shshaderparametercontainer.cpp
+
####### Install
install: FORCE
=======================================
--- /trunk/include/shdefs.h Thu Mar 11 14:28:24 2010
+++ /trunk/include/shdefs.h Sun Mar 21 14:48:06 2010
@@ -4,6 +4,11 @@
#include <QtGui/QWidget>
#include <QtGui/QScrollArea>
#include <QtGui/QResizeEvent>
+#include <QtGui/QLabel>
+#include <QtCore/QString>
+#include <QtGui/QLineEdit>
+#include <QtGui/QTreeWidget>
+#include <QtGui/QTreeWIdgetItem>
namespace Shaderz
{
@@ -11,5 +16,10 @@
typedef QWidget shWidget;
typedef QScrollArea shScrollAreaWidget;
typedef QResizeEvent shResizeEvent;
+ typedef QLabel shLabel;
+ typedef QString shString;
+ typedef QLineEdit shLineEdit;
+ typedef QTreeWidget shTreeWidget;
+ typedef QTreeWidgetItem shTreeItem;
}
#endif // SHWIDGET_H
=======================================
--- /trunk/include/shshaderinfo.h Tue Mar 2 13:01:51 2010
+++ /trunk/include/shshaderinfo.h Sun Mar 21 14:48:06 2010
@@ -1,9 +1,9 @@
#ifndef SHSHADERINFO_H
#define SHSHADERINFO_H
+#include "shdefs.h"
#include <CG/cg.h>
#include <CG/cggl.h>
-#include <string>
#include <vector>
namespace Shaderz
@@ -46,7 +46,7 @@
public:
struct shShaderParameter
{
- std::string name; // name of the parameter
as it exists in the shader
+ Shaderz::shString name; // name of the parameter
as it exists in the shader
shParameterClass paramClass; // the class this
parameter belongs to
shParameterType paramType; // the type this
parameter belongs to
int rows; // the number of
rows (default=1 for all, >1 for matrix/vectors)
@@ -61,6 +61,7 @@
void setFile(const std::string sShaderFile);
virtual bool parseShader(void);
+ virtual const std::vector<shShaderParameter>& getParameters()
const { return m_parameterList; }
virtual void dumpParameterInfo(std::vector<shShaderParameter>*
pInParameterList = 0, int indentLevel=0);
protected:
=======================================
--- /trunk/shaderz.pro Thu Mar 11 14:28:24 2010
+++ /trunk/shaderz.pro Sun Mar 21 14:48:06 2010
@@ -67,7 +67,9 @@
src/shmaterialeditordialog.cpp \
src/shshaderprogram.cpp \
src/shshaderinfo.cpp \
- src/qtwidgets/shcontainerwidget.cpp
+ src/qtwidgets/shcontainerwidget.cpp \
+ src/shshaderparametercontainer.cpp \
+ src/shparameterwidgetui.cpp
HEADERS += include/shaderzmain.h \
include/qtwidgets/osgadapterwidget.h \
include/shlogger.h \
@@ -79,6 +81,8 @@
include/shshaderprogram.h \
include/shshaderinfo.h \
include/qtwidgets/shcontainerwidget.h \
- include/shdefs.h
+ include/shdefs.h \
+ include/shshaderparametercontainer.h \
+ include/shparameterwidgetui.h
FORMS += ui/shaderzmain.ui \
ui/shmaterialeditordialog.ui
=======================================
--- /trunk/src/shmaterialeditordialog.cpp Thu Mar 11 14:28:24 2010
+++ /trunk/src/shmaterialeditordialog.cpp Sun Mar 21 14:48:06 2010
@@ -32,19 +32,13 @@
shMaterialInstance* pMatInst =
m_ui->materialContainerView->getMaterial(0);
pMatInst->setShader(sh);
-
+*/
// test shader info
std::string sFile = QFileDialog::getOpenFileName( this, "Open Shader
file" ).toStdString();
Shaderz::shShaderInfo* pShaderInfo = new
Shaderz::shShaderInfoCG(sFile);
pShaderInfo->parseShader();
- m_ui->shaderParametersUI->createParameterUI(pShaderInfo);
+
+ m_ui->testContainerWidget->setupUI(pShaderInfo);
+
delete pShaderInfo;
-*/
- static int i = 0;
- QLineEdit* pNewLineEdit = new
QLineEdit(m_ui->testContainerWidget->getContainer());
- QRect geo( 0+i*40, 0+i*40, 40, 30);
- pNewLineEdit->setGeometry(geo);
- pNewLineEdit->setVisible(true);
- m_ui->testContainerWidget->addChildWidget(pNewLineEdit);
- i++;
-}
+}
=======================================
--- /trunk/src/shshaderinfo.cpp Tue Mar 2 13:01:51 2010
+++ /trunk/src/shshaderinfo.cpp Sun Mar 21 14:48:06 2010
@@ -29,12 +29,12 @@
void shShaderInfo::dumpParameterInfo(std::vector<shShaderParameter>*
pInParameterList, int indentLevel)
{
- int index;
+ unsigned int index;
std::vector<shShaderParameter> parameterRoot = pInParameterList ?
*pInParameterList : m_parameterList;
for( index=0; index < parameterRoot.size(); ++index )
{
for( int indentIndex=0; indentIndex<indentLevel; ++indentIndex )
LOG<<"\t";
- LOG<<parameterRoot[index].name<<" ";
+ LOG<<parameterRoot[index].name.toAscii().constData()<<" ";
LOG<<"Class="<<parameterRoot[index].paramClass<<" ";
LOG<<"Type="<<parameterRoot[index].paramType<<" ";
LOG<<"Size="<<parameterRoot[index].columns<<"
x "<<parameterRoot[index].rows;
@@ -162,7 +162,7 @@
#undef CG_DATATYPE_MACRO
CGtype paramType = cgGetParameterType(cgParam);
- int mapIndex;
+ unsigned int mapIndex;
for( mapIndex=0; mapIndex < sizeof(map)/sizeof(map[0]); ++mapIndex )
{
if( paramType == map[mapIndex]._type )
@@ -193,7 +193,7 @@
bool shShaderInfoCG::getParameterInfo( const CGparameter& currentParam,
shShaderParameter& paramInfo ) const
{
- paramInfo.name = std::string(cgGetParameterName(currentParam));
+ paramInfo.name = cgGetParameterName(currentParam);
paramInfo.paramClass = translateCGParamClass(
cgGetParameterClass(currentParam) );
paramInfo.paramType =
translateCGParamType(cgGetParameterBaseType(currentParam));
getParamSizeInfo( currentParam, paramInfo.columns, paramInfo.rows );
=======================================
--- /trunk/ui/shmaterialeditordialog.ui Thu Mar 11 14:28:24 2010
+++ /trunk/ui/shmaterialeditordialog.ui Sun Mar 21 14:48:06 2010
@@ -61,13 +61,13 @@
<string>Generate paramInfo</string>
</property>
</widget>
- <widget class="shContainerWidget" name="testContainerWidget"
native="true">
+ <widget class="shShaderParameterContainer" name="testContainerWidget"
native="true">
<property name="geometry">
<rect>
<x>60</x>
<y>400</y>
- <width>121</width>
- <height>61</height>
+ <width>351</width>
+ <height>101</height>
</rect>
</property>
</widget>
@@ -83,9 +83,9 @@
</slots>
</customwidget>
<customwidget>
- <class>shContainerWidget</class>
+ <class>shShaderParameterContainer</class>
<extends>QWidget</extends>
- <header>include/qtwidgets/shcontainerwidget.h</header>
+ <header>shshaderparametercontainer.h</header>
<container>1</container>
</customwidget>
</customwidgets>