61 #include "QtShaderDialog.hh"
62 #include "../Scenegraph/ShaderNode.hh"
76 QtShaderDialog::QtShaderDialog( QWidget * _parent,
87 ui_.drawModeBox->addItem( QString( drawmode.
description().c_str() ) );
91 ui_.shaderDir->setText( QString(_node->shaderDir().c_str()) );
95 connect( ui_.okButton, SIGNAL( clicked() ),
96 this, SLOT( applyChanges() ) );
97 connect( ui_.cancelButton, SIGNAL( clicked() ),
98 this, SLOT( reject() ) );
100 connect( ui_.drawModeBox, SIGNAL( currentIndexChanged(
int ) ),
101 this, SLOT( comboChanged(
int ) ) );
108 void QtShaderDialog::reject()
110 std::cerr <<
"reject" << std::endl;
119 void QtShaderDialog::applyChanges()
122 std::string shaderDirectory(
"");
124 QString shaderDir = ui_.shaderDir->text();
127 if ( dir.exists() ) {
128 if ( ! shaderDir.endsWith(
'/' ) && ! shaderDir.endsWith(
'\\' ) ) {
132 shaderDirectory = std::string( shaderDir.toUtf8() );
136 std::cerr <<
"Shader directory does not exist" << std::string( shaderDir.toUtf8() ) << std::endl;
142 for (
int i = 0 ; i < ui_.drawModeBox->currentIndex() ; ++i )
146 std::string( ui_.vertexShader->text().toUtf8() ),
147 std::string( ui_.fragmentShader->text().toUtf8() ) );
149 emit signalNodeChanged(node_);
158 void QtShaderDialog::undoChanges()
160 std::cerr <<
"undo" << std::endl;
161 emit signalNodeChanged(node_);
164 void QtShaderDialog::comboChanged (
int index ) {
165 unsigned int drawMode = 1;
167 for (
int i = 0 ; i < index; ++i )
170 QString vertexShader(node_->vertexShaderName(drawMode).c_str());
171 QString fragmentShader(node_->fragmentShaderName(drawMode).c_str());
174 QString shaderDir( node_->shaderDir().c_str() );
175 vertexShader = vertexShader.remove( shaderDir );
176 fragmentShader = fragmentShader.remove( shaderDir );
178 ui_.vertexShader->setText( vertexShader );
179 ui_.fragmentShader->setText( fragmentShader );
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
Namespace providing different geometric functions concerning angles.
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
std::string description() const
void setShader(DrawModes::DrawMode _drawmode, std::string _vertexShader, std::string _fragmentShader, std::string _pickVertexShader="", std::string _pickFragmentShader="")
DrawMode UNUSED
marks the last used ID
void setShaderDir(std::string _shaderDir)
Sets the shader dir.