WQt4Gui.cpp 2.93 KB
Newer Older
1 2
//---------------------------------------------------------------------------
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5 6
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
7
//
wiebel's avatar
wiebel committed
8
// This file is part of OpenWalnut.
9
//
wiebel's avatar
wiebel committed
10
// OpenWalnut is free software: you can redistribute it and/or modify
11 12 13 14
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
wiebel's avatar
wiebel committed
15
// OpenWalnut is distributed in the hope that it will be useful,
16 17 18 19 20
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
wiebel's avatar
wiebel committed
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 23 24
//
//---------------------------------------------------------------------------

ebaum's avatar
ebaum committed
25
#include <iostream>
26 27
#include <string>
#include <vector>
28

29
#include <QtGui/QApplication>
30 31 32
#include <QtGui/QFileDialog>

#include "WMainWindow.h"
33 34
#include "../../kernel/WKernel.h"
#include "../../graphicsEngine/WGraphicsEngine.h"
35

36
#include "WQt4Gui.h"
ebaum's avatar
ebaum committed
37

38 39
WQt4Gui::WQt4Gui( int argc, char** argv ):
    WGUI( argc, argv )
ebaum's avatar
ebaum committed
40 41 42
{
}

43
WQt4Gui::~WQt4Gui()
44
{
ebaum's avatar
ebaum committed
45 46
}

47
int WQt4Gui::run()
ebaum's avatar
ebaum committed
48
{
49 50
    WLogger::getLogger()->addLogMessage( "Bringing up GUI", "GUI", LL_DEBUG );

51
    QApplication appl( argc, argv, true );
52

53 54
    // startup graphics engine
    m_ge = boost::shared_ptr< WGraphicsEngine >( new WGraphicsEngine() );
55

56 57 58
    // and startup kernel
    m_kernel = boost::shared_ptr< WKernel >( new WKernel( m_ge, shared_from_this() ) );
    m_kernel->run();
ebaum's avatar
ebaum committed
59

60 61 62
    // create the window
    m_gui = new WMainWindow;
    m_gui->show();
63

64 65
    // connect out loader signal with krnel
    getLoadButtonSignal()->connect( boost::bind( &WKernel::doLoadDataSets, m_kernel, _1 ) );
66

67 68 69 70 71 72
    // bind the GUI's slot with the ready signal
    t_ModuleGenericSignalHandlerType f = boost::bind( &WGUI::slotAddDatasetToBrowser, this, _1 );
    m_kernel->getRootContainer()->addDefaultNotifier( READY, f );

    // now we are initialized
    m_isInitialized = true;
73
    m_isInitializedCondition.notify();
74 75 76 77

    // run
    // NOTE: kernel shutdown is implemented in WMainWindow
    return appl.exec();
78 79
}

80
void WQt4Gui::addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId )
81
{
82
    m_gui->getDatasetBrowser()->addDataset( module, subjectId );
83 84
}

85 86 87 88
std::vector< boost::shared_ptr< WModule > >WQt4Gui::getDataSetList( int subjectId )
{
    return m_gui->getDatasetBrowser()->getDataSetList( subjectId );
}
89

90 91 92 93 94
boost::signal1< void, std::vector< std::string > >* WQt4Gui::getLoadButtonSignal()
{
    return m_gui->getLoaderSignal();
}

95
void WQt4Gui::connectProperties( boost::shared_ptr<WProperties> properties )
96
{
97
    m_gui->getPropertyManager()->connectProperties( properties );
98
}