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