SceneUnderstandingForm.cpp

00001 /****************************************************************************
00002 ** Form implementation generated from reading ui file 'Qt/SceneUnderstandingForm.ui'
00003 **
00004 **
00005 ** WARNING! All changes made in this file will be lost!
00006 ****************************************************************************/
00007 
00008 #include "Qt/ui/SceneUnderstandingForm.h"
00009 
00010 #include <qvariant.h>
00011 #include <qfiledialog.h>
00012 #include <qlineedit.h>
00013 #include <qimage.h>
00014 #include <qpixmap.h>
00015 #include <qmessagebox.h>
00016 #include <qpushbutton.h>
00017 #include <qtabwidget.h>
00018 #include <qwidget.h>
00019 #include <qlabel.h>
00020 #include <qspinbox.h>
00021 #include <qlayout.h>
00022 #include <qtooltip.h>
00023 #include <qwhatsthis.h>
00024 #include <qaction.h>
00025 #include <qmenubar.h>
00026 #include <qpopupmenu.h>
00027 #include <qtoolbar.h>
00028 #include <qimage.h>
00029 #include <qpixmap.h>
00030 
00031 #include "Raster/Raster.H"
00032 #include "QtUtil/ImageConvert.H"
00033 #include "SIFT/Histogram.H"
00034 #include "Image/FilterOps.H"
00035 #include "Image/ShapeOps.H"
00036 #include "Qt/ImageCanvas.h"
00037 #include "Qt/SceneUnderstandingForm.ui.h"
00038 static const unsigned char image1_data[] = {
00039     0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
00040     0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16,
00041     0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0xb4, 0x6c, 0x3b, 0x00, 0x00, 0x00,
00042     0x99, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xed, 0x94, 0x41, 0x0e, 0x85,
00043     0x20, 0x0c, 0x44, 0x5f, 0x89, 0xc7, 0x36, 0x7f, 0x61, 0xbc, 0x77, 0x5d,
00044     0x28, 0x48, 0xa4, 0x28, 0x60, 0xff, 0xce, 0xd9, 0x54, 0x8b, 0xbe, 0x8e,
00045     0x13, 0x04, 0x3e, 0x1d, 0x92, 0x81, 0x77, 0xf4, 0x81, 0xa1, 0x23, 0xdc,
00046     0x2b, 0x34, 0xf6, 0xf4, 0x7a, 0x3d, 0xe2, 0xb8, 0x65, 0xa8, 0x84, 0x3f,
00047     0x40, 0x01, 0x98, 0x2a, 0x0b, 0x3d, 0x5f, 0x62, 0xc5, 0x83, 0x00, 0xaa,
00048     0x1a, 0xd7, 0x05, 0x50, 0x44, 0x9a, 0xb9, 0xd5, 0x07, 0xa7, 0x73, 0xa8,
00049     0xa4, 0xba, 0x4f, 0x92, 0xa2, 0xdf, 0x33, 0x3c, 0x64, 0xc6, 0x3b, 0xeb,
00050     0xbd, 0x82, 0xe5, 0xb8, 0xad, 0xde, 0xcb, 0xcc, 0x78, 0x20, 0xeb, 0x42,
00051     0x66, 0xc6, 0x39, 0x74, 0x5d, 0xfa, 0x80, 0xf3, 0x6f, 0xaf, 0x66, 0xc6,
00052     0x6f, 0xa1, 0x9c, 0x3f, 0x88, 0x2f, 0xb4, 0x70, 0xec, 0x05, 0xcd, 0xc0,
00053     0xbe, 0xd0, 0x78, 0x93, 0xf6, 0x8e, 0x17, 0x14, 0x92, 0x63, 0x5f, 0x68,
00054     0x6c, 0x3e, 0xef, 0xf6, 0xba, 0x3c, 0x8f, 0xdd, 0x36, 0x6d, 0xc4, 0xc0,
00055     0x45, 0x2c, 0x87, 0x81, 0xf8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
00056     0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
00057 };
00058 
00059 
00060 /*
00061  *  Constructs a SceneUnderstandingForm as a child of 'parent', with the
00062  *  name 'name' and widget flags set to 'f'.
00063  *
00064  */
00065 SceneUnderstandingForm::SceneUnderstandingForm( QWidget* parent, const char* name, WFlags fl )
00066     : QMainWindow( parent, name, fl )
00067 {
00068     (void)statusBar();
00069     QImage img;
00070     img.loadFromData( image1_data, sizeof( image1_data ), "PNG" );
00071     image1 = img;
00072     if ( !name )
00073         setName( "SceneUnderstandingForm" );
00074     setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) );
00075     setCentralWidget( new QWidget( this, "qt_central_widget" ) );
00076     SceneUnderstandingFormLayout = new QVBoxLayout( centralWidget(), 11, 6, "SceneUnderstandingFormLayout");
00077 
00078     tabDisp = new QTabWidget( centralWidget(), "tabDisp" );
00079 
00080     tab = new QWidget( tabDisp, "tab" );
00081     tabLayout = new QHBoxLayout( tab, 11, 6, "tabLayout");
00082 
00083     imgDisp = new ImageCanvas( tab, "imgDisp" );
00084     tabLayout->addWidget( imgDisp );
00085     tabDisp->insertTab( tab, QString::fromLatin1("") );
00086     SceneUnderstandingFormLayout->addWidget( tabDisp );
00087 
00088     layout2 = new QHBoxLayout( 0, 0, 6, "layout2");
00089     spacer9 = new QSpacerItem( 70, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00090     layout2->addItem( spacer9 );
00091 
00092     EvolveBrainButton = new QPushButton( centralWidget(), "EvolveBrainButton" );
00093     layout2->addWidget( EvolveBrainButton );
00094     spacer3 = new QSpacerItem( 110, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00095     layout2->addItem( spacer3 );
00096 
00097     runButton = new QPushButton( centralWidget(), "runButton" );
00098     layout2->addWidget( runButton );
00099 
00100     textLabel1 = new QLabel( centralWidget(), "textLabel1" );
00101     layout2->addWidget( textLabel1 );
00102 
00103     timesSpinBox = new QSpinBox( centralWidget(), "timesSpinBox" );
00104     timesSpinBox->setMaxValue( 1000 );
00105     timesSpinBox->setMinValue( 0 );
00106     timesSpinBox->setValue( 1 );
00107     layout2->addWidget( timesSpinBox );
00108     spacer3_2 = new QSpacerItem( 161, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00109     layout2->addItem( spacer3_2 );
00110 
00111     GenScenepushButton = new QPushButton( centralWidget(), "GenScenepushButton" );
00112     layout2->addWidget( GenScenepushButton );
00113     SceneUnderstandingFormLayout->addLayout( layout2 );
00114 
00115     layout3 = new QHBoxLayout( 0, 0, 6, "layout3");
00116 
00117     textLabel1_2 = new QLabel( centralWidget(), "textLabel1_2" );
00118     layout3->addWidget( textLabel1_2 );
00119 
00120     dialogText = new QLineEdit( centralWidget(), "dialogText" );
00121     layout3->addWidget( dialogText );
00122     SceneUnderstandingFormLayout->addLayout( layout3 );
00123 
00124     layout6 = new QHBoxLayout( 0, 0, 6, "layout6");
00125 
00126     textLabel2 = new QLabel( centralWidget(), "textLabel2" );
00127     textLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, textLabel2->sizePolicy().hasHeightForWidth() ) );
00128     layout6->addWidget( textLabel2 );
00129 
00130     msgLabel = new QLabel( centralWidget(), "msgLabel" );
00131     layout6->addWidget( msgLabel );
00132     SceneUnderstandingFormLayout->addLayout( layout6 );
00133 
00134     // actions
00135     fileOpenAction = new QAction( this, "fileOpenAction" );
00136     fileOpenAction->setIconSet( QIconSet( image1 ) );
00137     fileSaveAsAction = new QAction( this, "fileSaveAsAction" );
00138     fileExitAction = new QAction( this, "fileExitAction" );
00139     editConfigureAction = new QAction( this, "editConfigureAction" );
00140     editConfigureAction->setToggleAction( TRUE );
00141     editConfigureAction->setOn( FALSE );
00142     editBias_SettingsAction = new QAction( this, "editBias_SettingsAction" );
00143     viewActionGroup = new QActionGroup( this, "viewActionGroup" );
00144     viewActionGroup->setOn( FALSE );
00145     viewActionGroup->setExclusive( FALSE );
00146     viewActionGroup->setUsesDropDown( FALSE );
00147     viewTrajAction = new QAction( viewActionGroup, "viewTrajAction" );
00148     viewTrajAction->setToggleAction( TRUE );
00149     viewSMapAction = new QAction( viewActionGroup, "viewSMapAction" );
00150     viewSMapAction->setToggleAction( TRUE );
00151     viewChannelsAction = new QAction( viewActionGroup, "viewChannelsAction" );
00152     viewChannelsAction->setToggleAction( TRUE );
00153     editDescriptor_VecAction = new QAction( this, "editDescriptor_VecAction" );
00154     editBayes_NetworkAction = new QAction( this, "editBayes_NetworkAction" );
00155     editBayes_NetworkViewAction = new QAction( this, "editBayes_NetworkViewAction" );
00156     editBayes_NetworkLoad_NetworkAction = new QAction( this, "editBayes_NetworkLoad_NetworkAction" );
00157     editBayes_NetworkSave_NetworkAction = new QAction( this, "editBayes_NetworkSave_NetworkAction" );
00158     editConfigureBias_ImageAction = new QAction( this, "editConfigureBias_ImageAction" );
00159     editConfigureBias_ImageAction->setToggleAction( TRUE );
00160     editConfigureBias_ImageAction->setOn( FALSE );
00161     editConfigureScene_SettingsAction = new QAction( this, "editConfigureScene_SettingsAction" );
00162     editConfigureTrainAction = new QAction( this, "editConfigureTrainAction" );
00163     editConfigureTrainAction->setToggleAction( TRUE );
00164     editConfigureTestAction = new QAction( this, "editConfigureTestAction" );
00165     editConfigureTestAction->setToggleAction( TRUE );
00166     fileOpen_WorkspaceAction = new QAction( this, "fileOpen_WorkspaceAction" );
00167 
00168 
00169     // toolbars
00170 
00171 
00172     // menubar
00173     MenuBar = new QMenuBar( this, "MenuBar" );
00174 
00175 
00176     fileMenu = new QPopupMenu( this );
00177     fileOpenAction->addTo( fileMenu );
00178     fileOpen_WorkspaceAction->addTo( fileMenu );
00179     fileSaveAsAction->addTo( fileMenu );
00180     fileMenu->insertSeparator();
00181     fileMenu->insertSeparator();
00182     fileExitAction->addTo( fileMenu );
00183     MenuBar->insertItem( QString(""), fileMenu, 1 );
00184 
00185     Edit = new QPopupMenu( this );
00186     popupMenu_6 = new QPopupMenu( this );
00187     Edit->insertItem( editConfigureAction->iconSet(), tr( "&Configure" ), popupMenu_6 );
00188     editConfigureBias_ImageAction->addTo( popupMenu_6 );
00189     editConfigureScene_SettingsAction->addTo( popupMenu_6 );
00190     editConfigureTestAction->addTo( popupMenu_6 );
00191     editBias_SettingsAction->addTo( Edit );
00192     editDescriptor_VecAction->addTo( Edit );
00193     popupMenu_12 = new QPopupMenu( this );
00194     Edit->insertItem( editBayes_NetworkAction->iconSet(), tr( "&Bayes Network" ), popupMenu_12 );
00195     editBayes_NetworkViewAction->addTo( popupMenu_12 );
00196     editBayes_NetworkLoad_NetworkAction->addTo( popupMenu_12 );
00197     editBayes_NetworkSave_NetworkAction->addTo( popupMenu_12 );
00198     MenuBar->insertItem( QString(""), Edit, 2 );
00199 
00200     View = new QPopupMenu( this );
00201     viewChannelsAction->addTo( View );
00202     viewSMapAction->addTo( View );
00203     viewTrajAction->addTo( View );
00204     MenuBar->insertItem( QString(""), View, 3 );
00205 
00206     languageChange();
00207     resize( QSize(763, 784).expandedTo(minimumSizeHint()) );
00208     clearWState( WState_Polished );
00209 
00210     // signals and slots connections
00211     connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
00212     connect( fileExitAction, SIGNAL( activated() ), this, SLOT( close() ) );
00213     connect( editBias_SettingsAction, SIGNAL( activated() ), this, SLOT( showBiasSettings() ) );
00214     connect( viewActionGroup, SIGNAL( selected(QAction*) ), this, SLOT( configureView(QAction*) ) );
00215     connect( imgDisp, SIGNAL( mousePressed(int,int) ), this, SLOT( getDescriptor(int,int) ) );
00216     connect( editDescriptor_VecAction, SIGNAL( activated() ), this, SLOT( showDescriptorVec() ) );
00217     connect( GenScenepushButton, SIGNAL( clicked() ), this, SLOT( genScene() ) );
00218     connect( runButton, SIGNAL( clicked() ), this, SLOT( run() ) );
00219     connect( editBayes_NetworkLoad_NetworkAction, SIGNAL( activated() ), this, SLOT( loadBayesNetwork() ) );
00220     connect( editBayes_NetworkSave_NetworkAction, SIGNAL( activated() ), this, SLOT( saveBayesNetwork() ) );
00221     connect( editBayes_NetworkViewAction, SIGNAL( activated() ), this, SLOT( viewBayesNetwork() ) );
00222     connect( editConfigureBias_ImageAction, SIGNAL( toggled(bool) ), this, SLOT( setBiasImage(bool) ) );
00223     connect( EvolveBrainButton, SIGNAL( pressed() ), this, SLOT( evolveBrain() ) );
00224     connect( editConfigureScene_SettingsAction, SIGNAL( activated() ), this, SLOT( showSceneSettings() ) );
00225     connect( dialogText, SIGNAL( returnPressed() ), this, SLOT( submitDialog() ) );
00226     connect( fileOpen_WorkspaceAction, SIGNAL( activated() ), this, SLOT( fileOpenWorkspace() ) );
00227 }
00228 
00229 /*
00230  *  Destroys the object and frees any allocated resources
00231  */
00232 SceneUnderstandingForm::~SceneUnderstandingForm()
00233 {
00234     // no need to delete child widgets, Qt does it all for us
00235 }
00236 
00237 /*
00238  *  Sets the strings of the subwidgets using the current
00239  *  language.
00240  */
00241 void SceneUnderstandingForm::languageChange()
00242 {
00243     setCaption( tr( "Bias Image" ) );
00244     tabDisp->changeTab( tab, tr( "Original" ) );
00245     EvolveBrainButton->setText( tr( "Evolve Brain" ) );
00246     runButton->setText( tr( "Run" ) );
00247     textLabel1->setText( tr( "Epochs:" ) );
00248     GenScenepushButton->setText( tr( "Generate\n"
00249 "Scene" ) );
00250     textLabel1_2->setText( tr( "Dialog:" ) );
00251     textLabel2->setText( tr( "Mesg:" ) );
00252     msgLabel->setText( QString::null );
00253     fileOpenAction->setText( tr( "Open" ) );
00254     fileOpenAction->setMenuText( tr( "&Open..." ) );
00255     fileOpenAction->setAccel( tr( "Ctrl+O" ) );
00256     fileSaveAsAction->setText( tr( "Save As" ) );
00257     fileSaveAsAction->setMenuText( tr( "Save &As..." ) );
00258     fileSaveAsAction->setAccel( QString::null );
00259     fileExitAction->setText( tr( "Exit" ) );
00260     fileExitAction->setMenuText( tr( "E&xit" ) );
00261     fileExitAction->setAccel( QString::null );
00262     editConfigureAction->setText( tr( "Configure" ) );
00263     editConfigureAction->setMenuText( tr( "&Configure" ) );
00264     editBias_SettingsAction->setText( tr( "&Bias Settings" ) );
00265     editBias_SettingsAction->setMenuText( tr( "&Bias Settings" ) );
00266     viewActionGroup->setText( tr( "View" ) );
00267     viewActionGroup->setAccel( tr( "Alt+F, S" ) );
00268     viewTrajAction->setText( tr( "View Traj" ) );
00269     viewTrajAction->setMenuText( tr( "View &Traj" ) );
00270     viewTrajAction->setAccel( tr( "Ctrl+T" ) );
00271     viewSMapAction->setText( tr( "View SMap" ) );
00272     viewSMapAction->setAccel( tr( "Ctrl+S" ) );
00273     viewChannelsAction->setText( tr( "view Channels" ) );
00274     editDescriptor_VecAction->setText( tr( "&Descriptor Vec" ) );
00275     editDescriptor_VecAction->setMenuText( tr( "&Descriptor Vec" ) );
00276     editBayes_NetworkAction->setText( tr( "&Bayes Network" ) );
00277     editBayes_NetworkAction->setMenuText( tr( "&Bayes Network" ) );
00278     editBayes_NetworkViewAction->setText( tr( "View" ) );
00279     editBayes_NetworkViewAction->setMenuText( tr( "View" ) );
00280     editBayes_NetworkLoad_NetworkAction->setText( tr( "Load Network" ) );
00281     editBayes_NetworkLoad_NetworkAction->setMenuText( tr( "Load Network" ) );
00282     editBayes_NetworkSave_NetworkAction->setText( tr( "Save Network" ) );
00283     editBayes_NetworkSave_NetworkAction->setMenuText( tr( "Save Network" ) );
00284     editConfigureBias_ImageAction->setText( tr( "Bias Image" ) );
00285     editConfigureBias_ImageAction->setMenuText( tr( "Bias Image" ) );
00286     editConfigureScene_SettingsAction->setText( tr( "Scene Settings" ) );
00287     editConfigureScene_SettingsAction->setMenuText( tr( "Scene Settings" ) );
00288     editConfigureTrainAction->setText( tr( "Train" ) );
00289     editConfigureTrainAction->setMenuText( tr( "Train" ) );
00290     editConfigureTestAction->setText( tr( "Test" ) );
00291     editConfigureTestAction->setMenuText( tr( "Test" ) );
00292     fileOpen_WorkspaceAction->setText( tr( "Open &Workspace" ) );
00293     fileOpen_WorkspaceAction->setMenuText( tr( "Open &Workspace" ) );
00294     if (MenuBar->findItem(1))
00295         MenuBar->findItem(1)->setText( tr( "&File" ) );
00296     Edit->changeItem( Edit->idAt( 0 ), tr( "&Configure" ) );
00297     Edit->changeItem( Edit->idAt( 3 ), tr( "&Bayes Network" ) );
00298     if (MenuBar->findItem(2))
00299         MenuBar->findItem(2)->setText( tr( "&Edit" ) );
00300     if (MenuBar->findItem(3))
00301         MenuBar->findItem(3)->setText( tr( "&View" ) );
00302 }
00303 
Generated on Sun May 8 08:05:33 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3