00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "EditNeuronParametersDialog.h"
00025 #include "Debug.h"
00026
00027
00028 #include <qlabel.h>
00029 #include <qpushbutton.h>
00030
00031
00032 #include <mysql++.h>
00033 #include <map>
00034 #include <iostream>
00035 using namespace std;
00036 using namespace mysqlpp;
00037
00038
00039
00040 EditNeuronParametersDialog::EditNeuronParametersDialog(QWidget *parent, map<const char*, double, charKeyCompare> descValueMap, map<const char*, double, charKeyCompare> *defValMap, unsigned int neuronGrpID) : QDialog(parent, "EdNeurParamDlg", true){
00041
00042 this->setCaption("Neuron group " + QString::number(neuronGrpID));
00043
00044
00045 defaultValueMap = defValMap;
00046
00047
00048 paramValidator = new QDoubleValidator(-100000.0, 100000.0, 4, this);
00049
00050
00051 QVBoxLayout *verticalBox = new QVBoxLayout(this, 5, 10);
00052 verticalBox->addSpacing(5);
00053
00054
00055 for(map<const char*, double>::iterator iter = descValueMap.begin(); iter != descValueMap.end(); ++iter){
00056
00057 QLineEdit *parameterText = new QLineEdit(this);
00058 parameterText->setText(QString::number(iter->second));
00059
00060
00061 descriptionLineEditMap[iter->first] = parameterText;
00062
00063
00064 addNeuronParameter(QString(iter->first), parameterText, verticalBox);
00065 }
00066
00067 verticalBox->addSpacing(5);
00068
00069
00070 QHBoxLayout *buttonBox = new QHBoxLayout();
00071 QPushButton *okButton = new QPushButton("Ok", this);
00072 connect (okButton, SIGNAL(clicked()), this, SLOT(okButtonPressed()));
00073 buttonBox->addWidget(okButton);
00074
00075 QPushButton *loadDefaultsButton = new QPushButton("Load Defaults", this);
00076 connect (loadDefaultsButton, SIGNAL(clicked()), this, SLOT(loadDefaultsButtonPressed()));
00077 buttonBox->addWidget(loadDefaultsButton);
00078
00079 QPushButton *makeDefaultsButton = new QPushButton("Make Defaults", this);
00080 connect (makeDefaultsButton, SIGNAL(clicked()), this, SLOT(makeDefaultsButtonPressed()));
00081 buttonBox->addWidget(makeDefaultsButton);
00082
00083 QPushButton *cancelButton = new QPushButton("Cancel", this);
00084 connect (cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonPressed()));
00085 buttonBox->addWidget(cancelButton);
00086 verticalBox->addLayout(buttonBox);
00087 }
00088
00089
00090
00091 EditNeuronParametersDialog::~ EditNeuronParametersDialog(){
00092 #ifdef MEMORY_DEBUG
00093 cout<<"DESTROYING EDIT NEURON PARAMETERS DIALOG"<<endl;
00094 #endif//MEMORY_DEBUG
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 map<const char*, QLineEdit*, charKeyCompare>* EditNeuronParametersDialog::getDescriptionLineEditMap(){
00104 return &descriptionLineEditMap;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113 void EditNeuronParametersDialog::cancelButtonPressed(){
00114 reject();
00115 }
00116
00117
00118
00119 void EditNeuronParametersDialog::loadDefaultsButtonPressed(){
00120 for(map<const char*, double, charKeyCompare>::iterator iter = defaultValueMap->begin(); iter != defaultValueMap->end(); ++iter){
00121 if(descriptionLineEditMap.count(iter->first))
00122 descriptionLineEditMap[iter->first]->setText(QString::number(iter->second));
00123 else
00124 cerr<<"EditNeuronParametersDialog: MAP KEY NOT FOUND LOADING DEFAULTS"<<endl;
00125 }
00126 }
00127
00128
00129
00130
00131 void EditNeuronParametersDialog::makeDefaultsButtonPressed(){
00132 }
00133
00134
00135
00136 void EditNeuronParametersDialog::okButtonPressed(){
00137 accept();
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147 void EditNeuronParametersDialog::addNeuronParameter(QString labelText, QLineEdit *lineEdit, QVBoxLayout *vBox){
00148 lineEdit->setMaximumSize(50, 20);
00149 lineEdit->setValidator(paramValidator);
00150 QHBoxLayout *hBoxLayout = new QHBoxLayout();
00151 hBoxLayout->addSpacing(10);
00152 hBoxLayout->addWidget(new QLabel(labelText, this));
00153 hBoxLayout->addWidget(lineEdit);
00154 hBoxLayout->addStretch(5);
00155 vBox->addLayout(hBoxLayout);
00156 }
00157
00158
00159