55 #include "QtShaderDialog.hh" 56 #include "../Scenegraph/ShaderNode.hh" 57 #include "../Scenegraph/DrawModes.hh" 71 QtShaderDialog::QtShaderDialog( QWidget * _parent,
82 ui_.drawModeBox->addItem( QString( drawmode.
description().c_str() ) );
86 ui_.shaderDir->setText( QString(_node->shaderDir().c_str()) );
90 connect( ui_.okButton, SIGNAL( clicked() ),
91 this, SLOT( applyChanges() ) );
92 connect( ui_.cancelButton, SIGNAL( clicked() ),
93 this, SLOT( reject() ) );
95 connect( ui_.drawModeBox, SIGNAL( currentIndexChanged(
int ) ),
96 this, SLOT( comboChanged(
int ) ) );
103 void QtShaderDialog::reject()
105 std::cerr <<
"reject" << std::endl;
114 void QtShaderDialog::applyChanges()
117 std::string shaderDirectory(
"");
119 QString shaderDir = ui_.shaderDir->text();
122 if ( dir.exists() ) {
123 if ( ! shaderDir.endsWith(
'/' ) && ! shaderDir.endsWith(
'\\' ) ) {
127 shaderDirectory = std::string( shaderDir.toUtf8() );
128 node_->setShaderDir( shaderDirectory );
131 std::cerr <<
"Shader directory does not exist" << std::string( shaderDir.toUtf8() ) << std::endl;
135 SceneGraph::DrawModes::DrawMode
drawMode = SceneGraph::DrawModes::DrawMode(1);
137 for (
int i = 0 ; i < ui_.drawModeBox->currentIndex() ; ++i )
140 node_->setShader(drawMode,
141 std::string( ui_.vertexShader->text().toUtf8() ),
142 std::string( ui_.fragmentShader->text().toUtf8() ) );
153 void QtShaderDialog::undoChanges()
155 std::cerr <<
"undo" << std::endl;
159 void QtShaderDialog::comboChanged (
int index ) {
162 for (
int i = 0 ; i < index; ++i )
165 QString vertexShader(node_->vertexShaderName(drawMode).c_str());
166 QString fragmentShader(node_->fragmentShaderName(drawMode).c_str());
169 QString shaderDir( node_->shaderDir().c_str() );
170 vertexShader = vertexShader.remove( shaderDir );
171 fragmentShader = fragmentShader.remove( shaderDir );
173 ui_.vertexShader->setText( vertexShader );
174 ui_.fragmentShader->setText( fragmentShader );
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.
DrawMode UNUSED
marks the last used ID
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
std::string description() const
void signalNodeChanged(ACG::SceneGraph::BaseNode *_node)