Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string>
00023 #include <vector>
00024
00025 #include "Config.h"
00026 #include "MainWindow.h"
00027
00028 MainWindow::MainWindow( QWidget* parent ) : QWidget( parent, Qt::FramelessWindowHint ), talking_head_( 0 )
00029 {
00030 setContentsMargins ( 0, 0, 0, 0 );
00031
00032 QPalette custom_palette = palette();
00033 custom_palette.setColor ( QPalette::Window, Qt::black );
00034 custom_palette.setColor ( QPalette::WindowText, Qt::white );
00035 setPalette( custom_palette );
00036 setAutoFillBackground ( true );
00037
00038
00039 QWidget* center_widget = new QWidget();
00040 center_widget->setContentsMargins ( 0, 0, 0, 0 );
00041
00042 QVBoxLayout* center_layout = new QVBoxLayout( );
00043 center_layout->setSpacing( 0 );
00044 center_layout->setContentsMargins ( 0, 0, 0, 0 );
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 int width = 480;
00065 int height = 640;
00066
00067 try
00068 {
00069 std::vector< std::vector<float> > material_colors;
00070 const char* cfgFilename = "../config.cfg";
00071
00072 Config cfg(cfgFilename);
00073 width = cfg.get("Window Width");
00074 height = cfg.get("Window Height");
00075 std::string mesh_filename = cfg.get("Mesh Filename");
00076 material_colors.push_back(cfg.get("Head Color"));
00077 material_colors.push_back(cfg.get("Iris Color"));
00078 material_colors.push_back(cfg.get("Outline Color"));
00079 talking_head_ = new TalkingHead( this, mesh_filename, material_colors );
00080
00081 std::cout << "Mesh Filename : " << mesh_filename << std::endl;
00082 }
00083 catch( const std::exception& e )
00084 {
00085 std::cerr << e.what() << std::endl;
00086 }
00087
00088 setMinimumSize( width, height );
00089
00090 festival_generator_ = new FestivalGenerator();
00091
00092
00093 text_out_display_= new TextOutDisplay( 0, 27, false, this );
00094 text_out_display_->setMaximumSize( width, (height)/4 );
00095
00096
00097 text_rec_display_= new TextOutDisplay( 0, 20, true, this );
00098 custom_palette.setColor ( QPalette::WindowText, QColor( 200, 200, 200 ) );
00099 text_rec_display_->setPalette( custom_palette );
00100 text_rec_display_->setMaximumSize( width, (height)/4 );
00101
00102 center_layout->addWidget( text_out_display_ );
00103 center_layout->addStretch();
00104 center_layout->addWidget( text_rec_display_ );
00105
00106 center_layout->setStretchFactor( text_out_display_, 1 );
00107
00108 center_widget->setFixedSize( width, height/4 );
00109 center_widget->setLayout( center_layout );
00110
00111
00112 QVBoxLayout* main_layout = new QVBoxLayout( );
00113 main_layout->setSpacing( 0 );
00114 main_layout->setContentsMargins ( 0, 0, 0, 0 );
00115
00116 main_layout->addWidget( talking_head_ );
00117 talking_head_->setMinimumSize( width, height/4 );
00118 talking_head_->setMaximumSize( width, (height*3)/4 );
00119
00120 main_layout->setStretchFactor( talking_head_, 1 );
00121
00122 QHBoxLayout* h_layout = new QHBoxLayout( );
00123 h_layout->setSpacing( 0 );
00124 h_layout->setContentsMargins ( 0, 0, 0, 0 );
00125
00126 h_layout->addStretch();
00127 h_layout->addWidget( center_widget );
00128 h_layout->addStretch();
00129
00130 main_layout->addStretch();
00131 main_layout->addLayout( h_layout );
00132 main_layout->addStretch();
00133
00134 setLayout( main_layout );
00135
00136 ostringstream next_command;
00137 next_command << "Info: " << qApp->desktop()->screenNumber( talking_head_ ) << endl;
00138 ROS_INFO( next_command.str().c_str() );
00139 }
00140
00141 MainWindow::~MainWindow() {}
00142
00143 void MainWindow::setNodeHandle(ros::NodeHandle* node_handle)
00144 {
00145 talking_head_->subscribeWithNodeHandle( *node_handle );
00146
00147 text_out_display_->subscribeWithNodeHandle( *node_handle );
00148
00149 festival_generator_->subscribeWithNodeHandle( *node_handle );
00150
00151 text_rec_display_->subscribeWithNodeHandle( *node_handle );
00152 }