SpikeStream Application Library
0.2
|
00001 //SpikeStream includes 00002 #include "SimulationLoaderWidget.h" 00003 #include "Globals.h" 00004 #include "PluginManager.h" 00005 using namespace spikestream; 00006 00007 //Qt includes 00008 #include <QLabel> 00009 #include <QDebug> 00010 00011 00013 SimulationLoaderWidget::SimulationLoaderWidget(QWidget* parent) : QWidget(parent) { 00014 //Create vertical box to organize layout 00015 mainVerticalBox = new QVBoxLayout(this); 00016 00017 try{ 00018 //Get list of available analysis plugins 00019 QString pluginPath = Globals::getSpikeStreamRoot() + "/plugins/simulation"; 00020 PluginManager* pluginManager = new PluginManager(pluginPath); 00021 pluginManager->loadPlugins(); 00022 QStringList pluginList = pluginManager->getPluginNames(); 00023 00024 //Add list to combo box 00025 QComboBox* pluginsCombo = new QComboBox(this); 00026 pluginsCombo->addItems(pluginList); 00027 00028 //Add combo to layout 00029 QHBoxLayout *comboBox = new QHBoxLayout(); 00030 comboBox->addWidget(new QLabel("Simulation plugins: ")); 00031 comboBox->addWidget(pluginsCombo); 00032 comboBox->addStretch(5); 00033 mainVerticalBox->addLayout(comboBox); 00034 00035 //Add the widgets to a stacked widget 00036 stackedWidget = new QStackedWidget(); 00037 for(QList<QString>::iterator iter = pluginList.begin(); iter != pluginList.end(); ++iter){ 00038 QWidget* tmpWidget = pluginManager->getPlugin(*iter); 00039 pluginWidgetMap[*iter] = stackedWidget->addWidget(tmpWidget); 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(showSimulationWidget(int)) ); 00047 } 00048 catch(SpikeStreamException& ex){ 00049 qCritical()<<ex.getMessage(); 00050 } 00051 catch(...){ 00052 qCritical()<<"An unknown exception occurred."; 00053 } 00054 } 00055 00056 00058 SimulationLoaderWidget::~SimulationLoaderWidget(){ 00059 } 00060 00061 00062 /*-------------------------------------------------------------------*/ 00063 /*---------- PRIVATE SLOTS -------------*/ 00064 /*-------------------------------------------------------------------*/ 00065 00068 void SimulationLoaderWidget::showSimulationWidget(int layerID){ 00069 if(layerID != stackedWidget->currentIndex()){ 00070 stackedWidget->setCurrentIndex(layerID); 00071 } 00072 } 00073