Commit 7bbafaed authored by schurade's avatar schurade
Browse files

[ADD] more work on basic gui and navigation slices

parent f1390f1f
......@@ -29,7 +29,7 @@
#include "common/WLogger.h"
#include "gui/WGUI.h"
#include "gui/qt4/WMainApplication.h"
#include "gui/qt4/WQt4Gui.h"
#include "kernel/WKernel.h"
......@@ -56,7 +56,7 @@ int main( int argc, char* argv[] )
WSegmentationFault::installSignalHandler();
// initialize GUI
boost::shared_ptr< WGUI > gui = boost::shared_ptr< WGUI >( new WMainApplication() );
boost::shared_ptr< WGUI > gui = boost::shared_ptr< WGUI >( new WQt4Gui() );
// init logger
WLogger logger;
......
......@@ -25,7 +25,11 @@
#ifndef WGUI_H
#define WGUI_H
#include <string>
#include <vector>
#include "../common/WThreadedRunner.h"
#include "qt4/signalslib.hpp"
/**
* This class prescribes the interface to the GUI.
......@@ -39,8 +43,29 @@ public:
* Default destructor.
*/
virtual ~WGUI();
virtual bool isInitalized() = 0;
/**
*
*/
virtual boost::signal0 < void >* addDatasetToBrowser( std::string name, int subjectId ) = 0;
/**
* getter functions for all signals provided by the gui
*/
virtual boost::signal1< void, std::vector< std::string > >* getLoadButtonSignal() = 0;
virtual boost::signal1< void, int >* getAxialSliderSignal() = 0;
virtual boost::signal1< void, int >* getCoronalSliderSignal() = 0;
virtual boost::signal1< void, int >* getSagittalSliderSignal() = 0;
virtual boost::signal1< void, bool >* getAxialButtonSignal() = 0;
virtual boost::signal1< void, bool >* getCoronalButtonSignal() = 0;
virtual boost::signal1< void, bool >* getSagittalButtonSignal() = 0;
protected:
bool m_isInitialized;
};
/**
* \defgroup gui GUI
*
......
......@@ -31,5 +31,8 @@
#include "disc.xpm"
#include "fileopen.xpm"
#include "quit.xpm"
#include "axial.xpm"
#include "cor.xpm"
#include "sag.xpm"
#endif // WICONS_H
......@@ -12,11 +12,12 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
WMainWindow.h
WQtNavGLWidget.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
)
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
......
......@@ -25,113 +25,94 @@
#include <iostream>
#include <string>
#include <vector>
#include <QtGui/QApplication>
#include <QtGui/QDockWidget>
#include <QtGui/QFileDialog>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include "WMainWindow.h"
#include "WQtGLWidget.h"
#include "WQtRibbonMenu.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
#include "../../kernel/WKernel.h"
#include "WQtNavGLWidget.h"
#include "../icons/logoIcon.xpm"
WMainWindow::~WMainWindow()
WMainWindow::WMainWindow()
{
// clean up list with views
m_glWidgets.clear();
}
void WMainWindow::connectSlots( QMainWindow *MainWindow )
WMainWindow::~WMainWindow()
{
QObject::connect( m_toolBar->getQuitButton(), SIGNAL( pressed() ), MainWindow, SLOT( close() ) );
QObject::connect( m_toolBar->getLoadButton(), SIGNAL( pressed() ), this, SLOT( load() ) );
QMetaObject::connectSlotsByName( MainWindow );
// clean up list with views
m_glWidgets.clear();
}
void WMainWindow::setupGUI( QMainWindow *MainWindow )
void WMainWindow::setupGUI( QMainWindow *mainWindow )
{
m_mainWindowIcon.addPixmap( QPixmap( logoIcon_xpm ) );
if( MainWindow->objectName().isEmpty() )
if( mainWindow->objectName().isEmpty() )
{
MainWindow->setObjectName( QString::fromUtf8( "MainWindow" ) );
mainWindow->setObjectName( QString::fromUtf8( "MainWindow" ) );
}
MainWindow->resize( 946, 632 );
MainWindow->setWindowIcon( m_mainWindowIcon );
mainWindow->resize( 946, 632 );
mainWindow->setWindowIcon( m_mainWindowIcon );
m_centralwidget = new QWidget( MainWindow );
m_centralwidget = new QWidget( mainWindow );
m_centralwidget->setObjectName( QString::fromUtf8( "centralwidget" ) );
MainWindow->setCentralWidget( m_centralwidget );
mainWindow->setCentralWidget( m_centralwidget );
m_toolBar = new WQtRibbonMenu( MainWindow );
MainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
m_toolBar = new WQtRibbonMenu( mainWindow );
mainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( MainWindow ) );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( mainWindow ) );
m_glWidgets.push_back( widget );
MainWindow->setCentralWidget( widget.get() );
mainWindow->setCentralWidget( widget.get() );
// initially 3 views
addNavigationGLWidget( MainWindow, QString( "axial" ) );
addNavigationGLWidget( MainWindow, QString( "coronal" ) );
addNavigationGLWidget( MainWindow, QString( "sagittal" ) );
m_navAxial = new WQtNavGLWidget( "axial", 160 );
m_glWidgets.push_back( m_navAxial->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial );
m_navCoronal = new WQtNavGLWidget( "coronal", 200 );
m_glWidgets.push_back( m_navCoronal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal );
m_navSagittal = new WQtNavGLWidget( "sagittal", 160 );
m_glWidgets.push_back( m_navSagittal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal );
m_datasetBrowser = new WQtDatasetBrowser();
MainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
mainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "subject1" );
m_datasetBrowser->addDataset( 0, "mr188_t1" );
m_datasetBrowser->addDataset( 0, "mr188_evec" );
m_datasetBrowser->addDataset( 0, "mr188_t2" );
m_datasetBrowser->addDataset( 0, "mr188_rgb" );
MainWindow->setWindowTitle( QApplication::translate( "MainWindow",
"OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
mainWindow->setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
connectSlots( MainWindow );
connect( m_toolBar->getQuitButton(), SIGNAL( pressed() ), mainWindow, SLOT( close() ) );
connect( m_toolBar->getLoadButton(), SIGNAL( pressed() ), this, SLOT( openLoadDialog() ) );
connect( m_toolBar->getAxiButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleAxial( bool ) ) );
connect( m_toolBar->getCorButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleCoronal( bool ) ) );
connect( m_toolBar->getSagButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleSagittal( bool ) ) );
}
QSlider* WMainWindow::addNavigationGLWidget( QMainWindow *MainWindow, QString title )
WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
{
QDockWidget *dockWidget = new QDockWidget( title );
dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
dockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
QSlider *slider = new QSlider( Qt::Horizontal );
QWidget* panel = new QWidget( dockWidget );
QVBoxLayout* layout = new QVBoxLayout();
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( panel ) );
// TODO(all): add some way to remove QtGLWidgets on destruction to delete QtGLWidget
m_glWidgets.push_back( widget );
layout->addWidget( widget.get() );
layout->addWidget( slider );
panel->setLayout( layout );
dockWidget->setWidget( panel );
MainWindow->addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
return slider;
return m_datasetBrowser;
}
WQtRibbonMenu* WMainWindow::getToolBar()
{
return m_toolBar;
}
void WMainWindow::load()
void WMainWindow::openLoadDialog()
{
std::cout << "test output: load function" << std::endl;
QFileDialog fd;
fd.setFileMode( QFileDialog::ExistingFiles );
......@@ -155,12 +136,59 @@ void WMainWindow::load()
{
stdFileNames.push_back( ( *constIterator ).toLocal8Bit().constData() );
}
m_loaderSignal( stdFileNames );
}
WKernel::getRunningKernel()->doLoadDataSets( stdFileNames );
void WMainWindow::toggleAxial( bool check )
{
m_axiSignal( check );
}
void WMainWindow::toggleCoronal( bool check )
{
m_corSignal( check );
}
WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
void WMainWindow::toggleSagittal( bool check )
{
return m_datasetBrowser;
m_sagSignal( check );
}
boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal()
{
return &m_loaderSignal;
}
boost::signal1< void, bool >* WMainWindow::getAxiSignal()
{
return &m_axiSignal;
}
boost::signal1< void, bool >* WMainWindow::getCorSignal()
{
return &m_corSignal;
}
boost::signal1< void, bool >* WMainWindow::getSagSignal()
{
return &m_sagSignal;
}
WQtNavGLWidget* WMainWindow::getNavAxial()
{
return m_navAxial;
}
WQtNavGLWidget* WMainWindow::getNavCoronal()
{
return m_navCoronal;
}
WQtNavGLWidget* WMainWindow::getNavSagittal()
{
return m_navSagittal;
}
......@@ -26,39 +26,36 @@
#define WMAINWINDOW_H
#include <list>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QIcon>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QSlider>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
#include "../WGUI.h"
#include "signalslib.hpp"
#include "WQtNavGLWidget.h"
#include "WQtRibbonMenu.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
// forward declarations
class WQtGLWidget;
class WQtDatasetBrowser;
class WQtRibbonMenu;
/**
* This class contains the main window and the layout
* of the widgets within the window.
* \ingroup gui
*/
class WMainWindow : public QObject, public WGUI
class WMainWindow : public QObject
{
Q_OBJECT
public:
explicit WMainWindow();
/**
* Set up all widgets menus an buttons in the main window.
......@@ -71,37 +68,56 @@ public:
virtual ~WMainWindow();
/**
*
* returns a pointer to the dataset browser object
*/
WQtDatasetBrowser* getDatasetBrowser();
private:
/**
* Helper routine for adding new docks with GL content
* returns a pointer to the toolbar object
*/
WQtRibbonMenu* getToolBar();
/**
*
*/
QSlider* addNavigationGLWidget( QMainWindow *MainWindow, QString title );
boost::signal1< void, std::vector< std::string > >* getLoaderSignal();
boost::signal1< void, bool >* getAxiSignal();
boost::signal1< void, bool >* getCorSignal();
boost::signal1< void, bool >* getSagSignal();
WQtNavGLWidget* getNavAxial();
WQtNavGLWidget* getNavCoronal();
WQtNavGLWidget* getNavSagittal();
public slots:
/**
* Connects some signals with some slots
* gets called when menu option or toolbar button load is activated
*/
void connectSlots( QMainWindow *MainWindow );
void openLoadDialog();
void toggleAxial( bool check );
void toggleCoronal( bool check );
void toggleSagittal( bool check );
private:
QIcon m_mainWindowIcon;
QWidget* m_centralwidget;
QStatusBar* m_statusBar;
WQtRibbonMenu* m_toolBar;
std::list<boost::shared_ptr<WQtGLWidget> > m_glWidgets;
WQtDatasetBrowser* m_datasetBrowser;
WQtNavGLWidget* m_navAxial;
WQtNavGLWidget* m_navCoronal;
WQtNavGLWidget* m_navSagittal;
private slots:
/**
* gets called when menu option or toolbar button load is activated
*/
void load();
boost::signal1< void, std::vector< std::string > > m_loaderSignal;
boost::signal1< void, bool > m_axiSignal;
boost::signal1< void, bool > m_corSignal;
boost::signal1< void, bool > m_sagSignal;
};
#endif // WMAINWINDOW_H
......@@ -23,24 +23,27 @@
//---------------------------------------------------------------------------
#include <iostream>
#include "WMainApplication.h"
#include "WMainWindow.h"
#include <string>
#include <vector>
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
#include "WMainWindow.h"
#include "../../kernel/WKernel.h"
#include "WQt4Gui.h"
WMainApplication::WMainApplication():
WQt4Gui::WQt4Gui():
WGUI()
{
m_isInitialized = false;
}
WMainApplication::~WMainApplication()
WQt4Gui::~WQt4Gui()
{
}
void WMainApplication::threadMain()
void WQt4Gui::threadMain()
{
// TODO(ebaum): currently removed argument stuff. will be done later in conjunction with a better
// option handler.+
......@@ -51,14 +54,63 @@ void WMainApplication::threadMain()
#else
QApplication appl( 0, NULL );
#endif
QMainWindow* widget = new QMainWindow;
WMainWindow gui;
gui.setupGUI( widget );
QMainWindow* mainWindow = new QMainWindow;
m_gui = new WMainWindow;
m_gui->setupGUI( mainWindow );
mainWindow->show();
m_isInitialized = true;
widget->show();
int qtExecResult;
qtExecResult = appl.exec();
// TODO(ebaum): how to handle return codes?
}
boost::signal0 < void >* WQt4Gui::addDatasetToBrowser( std::string name, int subjectId )
{
m_gui->getDatasetBrowser()->addDataset( name, subjectId );
// TODO(schurade): add the return here
return 0;
}
bool WQt4Gui::isInitalized()
{
return m_isInitialized;
}
boost::signal1< void, std::vector< std::string > >* WQt4Gui::getLoadButtonSignal()
{
return m_gui->getLoaderSignal();
}
boost::signal1< void, int >* WQt4Gui::getAxialSliderSignal()
{
return m_gui->getNavAxial()->getboostSignal();
}
boost::signal1< void, int >* WQt4Gui::getCoronalSliderSignal()
{
return m_gui->getNavCoronal()->getboostSignal();
}
boost::signal1< void, int >* WQt4Gui::getSagittalSliderSignal()
{
return m_gui->getNavSagittal()->getboostSignal();
}
boost::signal1< void, bool >* WQt4Gui::getAxialButtonSignal()
{
return m_gui->getAxiSignal();
}
boost::signal1< void, bool >* WQt4Gui::getCoronalButtonSignal()
{
return m_gui->getCorSignal();
}
boost::signal1< void, bool >* WQt4Gui::getSagittalButtonSignal()
{
return m_gui->getSagSignal();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// 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.
//
// OpenWalnut is distributed in the hope that it will be useful,
// 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
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQT4GUI_H
#define WQT4GUI_H
#include <string>
#include <vector>
#include "../WGUI.h"
class WMainWindow;
/**
* Starts up the QT GUI.
* \ingroup gui
*/
class WQt4Gui : public WGUI
{
public:
/**
* Default Constructor.
*/
WQt4Gui();
/**
* Default destructor.
*/
virtual ~WQt4Gui();
/**
* return trues when initialization is finished, otherwise false
*/
bool isInitalized();
boost::signal0 < void >* addDatasetToBrowser( std::string name, int SubjectId = 0 );
/**
* getter functions for the signales proved by the gui
*/
boost::signal1< void, std::vector< std::string > >* getLoadButtonSignal();
boost::signal1< void, int >* getAxialSliderSignal();
boost::signal1< void, int >* getCoronalSliderSignal();
boost::signal1< void, int >* getSagittalSliderSignal();
boost::signal1< void, bool >* getAxialButtonSignal();
boost::signal1< void, bool >* getCoronalButtonSignal();
boost::signal1< void, bool >* getSagittalButtonSignal();
protected:
/**
* Execution loop.
*/
virtual void threadMain();
private:
WMainWindow* m_gui;
};
#endif // WQT4GUI_H
//---------------------------------------------------------------------------
//