00001 /*************************************************************************** 00002 * SpikeStream Application * 00003 * Copyright (C) 2007 by David Gamez * 00004 * david@davidgamez.eu * 00005 * Version 0.1 * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 00023 #ifndef NEURONPARAMETERSDIALOG_H 00024 #define NEURONPARAMETERSDIALOG_H 00025 00026 //SpikeStream includes 00027 #include "DBInterface.h" 00028 #include "EditNeuronParametersDialog.h" 00029 #include "ParameterTable.h" 00030 #include "SimulationManager.h" 00031 00032 //Other includes 00033 #include <qdialog.h> 00034 #include <qstringlist.h> 00035 #include <qpixmap.h> 00036 #include <qpushbutton.h> 00037 #include <qtable.h> 00038 00039 00040 //------------------------- Neuron Parameters Dialog ---------------------- 00041 /*! Displays all the neuron parameters in a table with an edit button that 00042 launches an edit neuron parameters dialog. The parameters are changed in 00043 the dialog by EditNeuronParameters, but they are only saved when ok, or 00044 apply are pressed. */ 00045 //------------------------------------------------------------------------- 00046 00047 class NeuronParametersDialog : public QDialog { 00048 Q_OBJECT 00049 00050 public: 00051 NeuronParametersDialog(QWidget *parent, DBInterface* networkDBInterface, SimulationManager* simMan); 00052 ~NeuronParametersDialog(); 00053 bool loadNeuronParameters(); 00054 00055 00056 private slots: 00057 void applyButtonPressed(); 00058 void cancelButtonPressed(); 00059 void defaultsButtonPressed(); 00060 void okButtonPressed(); 00061 void parameterTableClicked(int row, int col, unsigned short typeID); 00062 void parameterTableValueChanged(int row, int col, unsigned short typeID); 00063 00064 00065 private: 00066 //============================ VARIABLES ================================ 00067 /*! Store reference to database interfaces.*/ 00068 DBInterface *networkDBInterface; 00069 00070 /*! Store reference to simulation manager to inform tasks about changes.*/ 00071 SimulationManager *simulationManager; 00072 00073 //Table and its header for displaying parameters 00074 map<unsigned short, ParameterTable*> paramTableMap; 00075 map<unsigned short, QHeader*> paramTableHeaderMap; 00076 map<unsigned short, QLabel*> tableLabelMap; 00077 00078 /*! Applies the parameters without closing the dialog.*/ 00079 QPushButton *applyButton; 00080 00081 //The column containing the edit pixmap that is clicked on to launch the edit dialog 00082 int editColumn; 00083 int neurGrpIDColumn; 00084 int nameColumn; 00085 int paramStartColumn; 00086 00087 /*! Image displayed in the edit column.*/ 00088 QPixmap *editPixmap; 00089 00090 /*! List of all the field names of the parameters, used for loading them from 00091 the database.*/ 00092 map<unsigned short, QStringList*> fieldNamesMap; 00093 00094 /*! List of all the value names.*/ 00095 map<unsigned short, QStringList*> valueNamesMap; 00096 00097 /*! Links descriptions of the parameter with the default value.*/ 00098 map<unsigned short, map<const char*, double, charKeyCompare> > defaultValueMap; 00099 00100 /*! Links descriptions of the parameter with a column for loading up parameters.*/ 00101 map<unsigned short, map<const char*, int, charKeyCompare> > descriptionColumnMap; 00102 00103 /*! Records whether a value is a check box type. Only check box values are 00104 included in this map.*/ 00105 map<unsigned short, map<const char*, bool, charKeyCompare> > checkBoxMap; 00106 00107 /*! Stores the link between a description and a parameter name.*/ 00108 map<unsigned short, map<const char*, const char*, charKeyCompare> > descParamMap; 00109 00110 /*! Stores the link between a parameter name and a description.*/ 00111 map<unsigned short, map<const char*, const char*, charKeyCompare> > paramDescMap; 00112 00113 /*! Variable recording whether the parameter table has been changed 00114 Used to enable or disable the apply button and prevent updating parameters 00115 unnecessarily.*/ 00116 bool parameterValuesChanged; 00117 00118 00119 //========================== METHODS ================================ 00120 /*! Declare copy constructor private so it cannot be used inadvertently.*/ 00121 NeuronParametersDialog (const NeuronParametersDialog&); 00122 00123 /*! Declare assignment private so it cannot be used inadvertently.*/ 00124 NeuronParametersDialog operator = (const NeuronParametersDialog&); 00125 00126 void storeNeuronParameters(); 00127 00128 }; 00129 00130 00131 #endif //NEURONPARAMETERSDIALOG_H 00132
1.4.4