SpikeStream Application Library  0.2
NeuronParametersEditDialog.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "Globals.h"
00003 #include "NeuronParametersEditDialog.h"
00004 #include "SpikeStreamException.h"
00005 using namespace spikestream;
00006 
00007 
00009 NeuronParametersEditDialog::NeuronParametersEditDialog(const NeuronGroupInfo& neurGrpInfo, const QList<ParameterInfo>& paramInfoList, const QHash<QString, double>& currParamValueMap, QWidget* parent)
00010                 : AbstractParametersEditDialog(paramInfoList, parent) {
00011 
00012         //Store the neuron group info for when we update the parameters
00013         this->neurGrpInfo = neurGrpInfo;
00014 
00015         //Create layout to organize dialog
00016         QVBoxLayout* mainVBox = new QVBoxLayout(this);
00017 
00018         //Add the parameter edit fields
00019         addParameters(mainVBox);
00020 
00021         //Sets the values of the parameters
00022         setParameterValues(currParamValueMap);
00023 
00024         //Add the buttons
00025         addButtons(mainVBox);
00026 }
00027 
00028 
00030 NeuronParametersEditDialog::~NeuronParametersEditDialog(){
00031 }
00032 
00033 
00034 /*--------------------------------------------------------*/
00035 /*-------              PROTECTED SLOTS             -------*/
00036 /*--------------------------------------------------------*/
00037 
00039 void NeuronParametersEditDialog::defaultButtonClicked(){
00040         try{
00041                 setParameterValues(Globals::getNetworkDao()->getDefaultNeuronParameters(neurGrpInfo.getNeuronTypeID()));
00042         }
00043         catch(SpikeStreamException& ex){
00044                 qCritical()<<ex.getMessage();
00045                 this->accept();
00046         }
00047 }
00048 
00049 
00051 void NeuronParametersEditDialog::okButtonClicked(){
00052         try{
00053                 QHash<QString, double> paramMap = getParameterValues();
00054 
00055                 //Set parameters in the network object stored in memory
00056                 Globals::getNetwork()->setNeuronGroupParameters(neurGrpInfo.getID(), paramMap);
00057 
00058                 /* Parameter change may affect the saved state of the network, so reload list */
00059                 Globals::getEventRouter()->networkListChangedSlot();
00060 
00061                 /* Set parameters in simulation if it is loaded */
00062                 if(Globals::isSimulationLoaded()){
00063                         Globals::getSimulation()->setNeuronParameters(neurGrpInfo.getID(), paramMap);
00064                 }
00065 
00066                 //Close dialog
00067                 this->accept();
00068         }
00069         catch(SpikeStreamException& ex){
00070                 qCritical()<<ex.getMessage();
00071         }
00072 }
 All Classes Files Functions Variables Typedefs Friends Defines