SpikeStream Application Library  0.2
AnalysisLoaderWidget.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "AnalysisLoaderWidget.h"
00003 #include "AbstractAnalysisWidget.h"
00004 #include "Globals.h"
00005 #include "PluginManager.h"
00006 using namespace spikestream;
00007 
00008 //Qt includes
00009 #include <QLabel>
00010 #include <QDebug>
00011 
00012 
00014 AnalysisLoaderWidget::AnalysisLoaderWidget(QWidget* parent) : QWidget(parent) {
00015         //Create vertical box to organize layout
00016         mainVerticalBox = new QVBoxLayout(this);
00017 
00018         try{
00019                 //Get list of available analysis plugins
00020                 QString pluginPath = Globals::getSpikeStreamRoot() + "/plugins/analysis";
00021                 PluginManager* pluginManager = new PluginManager(pluginPath);
00022                 pluginManager->loadPlugins();
00023                 QStringList pluginList = pluginManager->getPluginNames();
00024 
00025                 //Add list to combo box
00026                 QComboBox* pluginsCombo = new QComboBox(this);
00027                 pluginsCombo->addItems(pluginList);
00028 
00029                 //Add combo to layout
00030                 QHBoxLayout *comboBox = new QHBoxLayout();
00031                 comboBox->addWidget(new QLabel("Analysis plugins: "));
00032                 comboBox->addWidget(pluginsCombo);
00033                 comboBox->addStretch(5);
00034                 mainVerticalBox->addLayout(comboBox);
00035 
00036                 //Add the widgets to a stacked widget
00037                 stackedWidget = new QStackedWidget();
00038                 for(QList<QString>::iterator iter = pluginList.begin(); iter != pluginList.end(); ++iter){
00039                         pluginWidgetMap[*iter] = stackedWidget->addWidget(pluginManager->getPlugin(*iter));
00040                 }
00041 
00042                 //Add stacked widget to layout
00043                 mainVerticalBox->addWidget(stackedWidget);
00044 
00045                 //Connect combo changed signal to slot loading appropriate analysis widget
00046                 connect(pluginsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(showAnalysisWidget(int)) );
00047         }
00048         catch(SpikeStreamException& ex){
00049                 qCritical()<<ex.getMessage();
00050         }
00051 }
00052 
00053 
00055 AnalysisLoaderWidget::~AnalysisLoaderWidget(){
00056 }
00057 
00058 
00059 /*------------------------------------------------------------*/
00060 /*------               PRIVATE SLOTS                    ------*/
00061 /*------------------------------------------------------------*/
00062 
00065 void AnalysisLoaderWidget::showAnalysisWidget(int layerID){
00066         if(layerID != stackedWidget->currentIndex()){
00067                 ((AbstractAnalysisWidget*)stackedWidget->currentWidget())->hideAnalysisResults();
00068                 stackedWidget->setCurrentIndex(layerID);
00069         }
00070 }
00071 
00072 
00073 
 All Classes Files Functions Variables Typedefs Friends Defines