00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "PromptGenerationDialog.hpp"
00024
00025 #include <QWidget>
00026 #include <QGridLayout>
00027 #include <QHBoxLayout>
00028 #include <QGroupBox>
00029 #include <QComboBox>
00030 #include <QSpinBox>
00031 #include <QDoubleSpinBox>
00032 #include <QPushButton>
00033 #include <QLabel>
00034
00035 #include "../types.hpp"
00036
00037
00038 #ifndef QT_NO_DEBUG
00039 #include <iostream>
00040 #endif
00041 extern const char* initFCTString[lifctENDOFLIST];
00042 extern const char* accumulateurFCTString[lafctENDOFLIST];
00043
00044 PromptGenerationDialog :: PromptGenerationDialog(QWidget* parent )
00045 :QDialog(parent),
00046
00047
00048 pMainGrid(NULL),
00049 pFunctionsBox(NULL), pZoneBox(NULL), pFunctionsGrid(NULL), pZoneGrid(NULL), pButtonsGrid(NULL),
00050
00051 pLabelInitializorList(NULL), pInitializorList(NULL),
00052 pLabelGeneratorsList(NULL), pGeneratorsList(NULL),
00053 pLabelAccumulatorList(NULL), pAccumulatorList(NULL),
00054
00055 pZoneSizeBox(NULL), pZoneGeneratorBox(NULL), pZoneSizeGrid(NULL), pZoneGeneratorGrid(NULL),
00056 pLabelWidth(NULL), pWidth(NULL),
00057 pLabelHeight(NULL), pHeight(NULL),
00058 pLabelX(NULL), pX(NULL),
00059 pLabelY(NULL), pY(NULL),
00060 pLabelW(NULL), pW(NULL),
00061 pLabelH(NULL), pH(NULL),
00062
00063 pCancelButton(NULL),
00064 pDefaultButton(NULL),
00065 pStartButton(NULL)
00066 {
00067
00068 pMainGrid = new QGridLayout(this);
00069
00070 this->createListsFunctions();
00071
00072 this->createSpinBoxes();
00073
00074 this->createButtons();
00075
00076
00077 #ifndef QT_NO_DEBUG
00078 std::cout << "PromptGenerationDialog created" << std::endl;
00079 #endif
00080 }
00081
00082 void PromptGenerationDialog :: createButtons(void)
00083 {
00084 const int actualRowNumber = pMainGrid->rowCount();
00085
00086 pButtonsGrid = new QHBoxLayout(0);
00087 pMainGrid->addLayout(pButtonsGrid, actualRowNumber, 0, Qt::AlignRight);
00088
00089 pStartButton = new QPushButton(tr("Start"), this);
00090 pButtonsGrid->addWidget(pStartButton);
00091
00092 pDefaultButton = new QPushButton(tr("Default"), this);
00093 pButtonsGrid->addWidget(pDefaultButton);
00094
00095 pCancelButton = new QPushButton(tr("Cancel"), this);
00096 pButtonsGrid->addWidget(pCancelButton);
00097
00098 connect(pStartButton, SIGNAL(clicked()), this, SLOT(startGeneration()));
00099 connect(pDefaultButton, SIGNAL(clicked()), this, SLOT(applyDefaultValues()));
00100 connect(pCancelButton, SIGNAL(clicked()), this, SLOT(cancelSettings()));
00101
00102 #ifndef QT_NO_DEBUG
00103 std::cout << "\tPromptGenerationDialog buttons created" << std::endl;
00104 #endif
00105 }
00106
00107 void PromptGenerationDialog :: createListsFunctions(void)
00108 {
00109 pFunctionsBox = new QGroupBox(tr("Functions:"), this);
00110 pMainGrid->addWidget(pFunctionsBox,0,0,Qt::AlignCenter);
00111
00112 pFunctionsGrid = new QGridLayout(pFunctionsBox);
00113
00114 pLabelInitializorList = new QLabel(tr("List of functions for initialisation of the points:"), this);
00115 pInitializorList = new QComboBox(this);
00116
00117
00118 for ( unsigned int i = 0 ; i < lifctENDOFLIST ; i++ )
00119 {
00120 pInitializorList->addItem(initFCTString[i], i);
00121 }
00122
00123 pFunctionsGrid->addWidget(pLabelInitializorList, 0, 0, Qt::AlignLeft);
00124 pFunctionsGrid->addWidget(pInitializorList, 0, 1, Qt::AlignCenter);
00125
00126
00127 pLabelGeneratorsList = new QLabel(tr("List of functions for fractales:"), this);
00128 pGeneratorsList = new QComboBox(this);
00129
00130
00131 for ( unsigned int i = 0 ; i < lgfctENDOFLIST ; i++ )
00132 {
00133 pGeneratorsList->addItem(generatorFCTString[i].name, i);
00134 }
00135
00136 connect(pGeneratorsList, SIGNAL(currentIndexChanged(int)), this, SLOT(functionSelectedChanged(int)));
00137
00138 pFunctionsGrid->addWidget(pLabelGeneratorsList, 1, 0, Qt::AlignLeft);
00139 pFunctionsGrid->addWidget(pGeneratorsList, 1, 1, Qt::AlignCenter);
00140
00141
00142 pLabelAccumulatorList = new QLabel(tr("List of functions for accumulation:"), this);
00143 pAccumulatorList = new QComboBox(this);
00144
00145
00146 for ( unsigned int i = 0 ; i < lafctENDOFLIST ; i++ )
00147 {
00148 pAccumulatorList->addItem(accumulateurFCTString[i], i);
00149 }
00150
00151 pFunctionsGrid->addWidget(pLabelAccumulatorList, 2, 0, Qt::AlignLeft);
00152 pFunctionsGrid->addWidget(pAccumulatorList, 2, 1, Qt::AlignCenter);
00153
00154 #ifndef QT_NO_DEBUG
00155 std::cout << "\tPromptGenerationDialog: Lists created" << std::endl;
00156 #endif
00157 }
00158
00159 void PromptGenerationDialog :: createSpinBoxes(void)
00160 {
00161 pZoneBox = new QGroupBox(tr("Zone settings:"), this);
00162 pMainGrid->addWidget(pZoneBox,1,0,Qt::AlignCenter);
00163
00164 pZoneGrid = new QHBoxLayout(pZoneBox);
00165
00166
00167 {
00168 pZoneSizeBox = new QGroupBox(tr("Image size:"), this);
00169 pZoneGrid->addWidget(pZoneSizeBox);
00170
00171 pZoneSizeGrid = new QGridLayout(pZoneSizeBox);
00172
00173 pLabelWidth = new QLabel(tr("Image width:"), this);
00174 pWidth = new QSpinBox(this);
00175
00176 pWidth->setMaximum(2147483647);
00177 pWidth->setValue(1000);
00178
00179 pZoneSizeGrid->addWidget(pLabelWidth, 0, 0, Qt::AlignLeft);
00180 pZoneSizeGrid->addWidget(pWidth, 0, 1, Qt::AlignCenter);
00181
00182 pLabelHeight = new QLabel(tr("Image height:"), this);
00183 pHeight = new QSpinBox(this);
00184
00185 pHeight->setMaximum(2147483647);
00186 pHeight->setValue(1000);
00187
00188 pZoneSizeGrid->addWidget(pLabelHeight, 1, 0, Qt::AlignLeft);
00189 pZoneSizeGrid->addWidget(pHeight, 1, 1, Qt::AlignCenter);
00190 }
00191
00192
00193 {
00194 pZoneGeneratorBox = new QGroupBox(tr("Fractale settings:"), this);
00195 pZoneGrid->addWidget(pZoneGeneratorBox);
00196
00197 pZoneGeneratorGrid = new QGridLayout(pZoneGeneratorBox);
00198
00199 pLabelX = new QLabel(tr("X:"), this);
00200 pX = new QDoubleSpinBox(this);
00201
00202 pX->setDecimals(3);
00203 pX->setRange(-2147483647, 2147483647);
00204
00205 pZoneGeneratorGrid->addWidget(pLabelX, 0, 0, Qt::AlignLeft);
00206 pZoneGeneratorGrid->addWidget(pX, 0, 1, Qt::AlignCenter);
00207
00208 pLabelY = new QLabel(tr("Y:"), this);
00209 pY = new QDoubleSpinBox(this);
00210
00211 pY->setDecimals(3);
00212 pY->setRange(-2147483647, 2147483647);
00213
00214 pZoneGeneratorGrid->addWidget(pLabelY, 1, 0, Qt::AlignLeft);
00215 pZoneGeneratorGrid->addWidget(pY, 1, 1, Qt::AlignCenter);
00216
00217 pLabelW = new QLabel(tr("W:"), this);
00218 pW = new QDoubleSpinBox(this);
00219
00220 pW->setDecimals(3);
00221 pW->setRange(-2147483647, 2147483647);
00222
00223 pZoneGeneratorGrid->addWidget(pLabelW, 2, 0, Qt::AlignLeft);
00224 pZoneGeneratorGrid->addWidget(pW, 2, 1, Qt::AlignCenter);
00225
00226 pLabelH = new QLabel(tr("H:"), this);
00227 pH = new QDoubleSpinBox(this);
00228
00229 pH->setDecimals(3);
00230 pH->setRange(-2147483647, 2147483647);
00231
00232 pZoneGeneratorGrid->addWidget(pLabelH, 3, 0, Qt::AlignLeft);
00233 pZoneGeneratorGrid->addWidget(pH, 3, 1, Qt::AlignCenter);
00234 }
00235
00236 this->applyDefaultValues();
00237
00238 #ifndef QT_NO_DEBUG
00239 std::cout << "\tPromptGenerationDialog: Spin Boxes created" << std::endl;
00240 #endif
00241 }
00242
00243 PromptGenerationDialog :: ~PromptGenerationDialog(void)
00244 {
00245
00246 delete pStartButton;
00247 delete pDefaultButton;
00248 delete pCancelButton;
00249
00250
00251 delete pH; delete pLabelH;
00252 delete pW; delete pLabelW;
00253 delete pY; delete pLabelY;
00254 delete pX; delete pLabelX;
00255
00256 delete pHeight; delete pLabelHeight;
00257 delete pWidth; delete pLabelWidth;
00258
00259 delete pZoneGeneratorGrid;
00260 delete pZoneSizeGrid;
00261
00262 delete pZoneGeneratorBox;
00263 delete pZoneSizeBox;
00264
00265
00266 delete pAccumulatorList; delete pLabelAccumulatorList;
00267 delete pGeneratorsList; delete pLabelGeneratorsList;
00268 delete pInitializorList; delete pLabelInitializorList;
00269
00270
00271 delete pZoneGrid;
00272 delete pFunctionsGrid;
00273 delete pButtonsGrid;
00274
00275 delete pZoneBox;
00276 delete pFunctionsBox;
00277
00278 delete pMainGrid;
00279
00280
00281
00282 #ifndef QT_NO_DEBUG
00283 std::cout << "PromptGenerationDialog deleted" << std::endl;
00284 #endif
00285 }
00286
00288
00289 void PromptGenerationDialog :: startGeneration(void)
00290 {
00291
00292
00293
00294 #ifndef QT_NO_DEBUG
00295 std::cout << "Starting of the generation" << std::endl;
00296
00297 #endif
00298
00299 this->done(0);
00300 }
00301
00302 void PromptGenerationDialog :: cancelSettings(void)
00303 {
00304 this->close();
00305 }
00306
00307 void PromptGenerationDialog :: reject(void)
00308 {
00309 this->done(1);
00310
00311 #ifndef QT_NO_DEBUG
00312 std::cout << "PromptGenerationDialog canceled" << std::endl;
00313 #endif
00314 }
00315
00316 void PromptGenerationDialog :: functionSelectedChanged(int index)
00317 {
00318 (void)index;
00319 #ifndef QT_NO_DEBUG
00320 std::cout << "\tPromptGenerationDialog: SLOT(functionSelectedChanged) -> index: " << index << std::endl;
00321 #endif
00322
00323 applyDefaultValues();
00324 }
00325
00326 void PromptGenerationDialog :: applyDefaultValues(void)
00327 {
00328 int index = pGeneratorsList->currentIndex();
00329
00330 pInitializorList->setCurrentIndex(generatorFCTString[index].lifct);
00331 pAccumulatorList->setCurrentIndex(generatorFCTString[index].lafct);
00332
00333 pX->setValue(generatorFCTString[index].x);
00334 pY->setValue(generatorFCTString[index].y);
00335 pW->setValue(generatorFCTString[index].w);
00336 pH->setValue(generatorFCTString[index].h);
00337
00338
00339 #ifndef QT_NO_DEBUG
00340 std::cout << "\tPromptGenerationDialog: SLOT(applyDefaultValues)" << std::endl;
00341 #endif
00342 }
00343
00344 ListInitFCT PromptGenerationDialog :: getInitializor(void)const
00345 {
00346 return static_cast<ListInitFCT>(pInitializorList->currentIndex());
00347 }
00348
00349 ListGeneratorFCT PromptGenerationDialog :: getGenerator(void)const
00350 {
00351 return static_cast<ListGeneratorFCT>(pGeneratorsList->currentIndex());
00352 }
00353
00354 ListAccumulateurFCT PromptGenerationDialog :: getAccumulator(void)const
00355 {
00356 return static_cast<ListAccumulateurFCT>(pAccumulatorList->currentIndex());
00357 }
00358
00359 unsigned int PromptGenerationDialog :: getImageW(void)const
00360 {
00361 return pWidth->value();
00362 }
00363
00364 unsigned int PromptGenerationDialog :: getImageH(void)const
00365 {
00366 return pHeight->value();
00367 }
00368
00369 double PromptGenerationDialog :: getZoneX(void)const
00370 {
00371 return pX->value();
00372 }
00373
00374 double PromptGenerationDialog :: getZoneY(void)const
00375 {
00376 return pY->value();
00377 }
00378
00379 double PromptGenerationDialog :: getZoneW(void)const
00380 {
00381 return pW->value();
00382 }
00383
00384 double PromptGenerationDialog :: getZoneH(void)const
00385 {
00386 return pH->value();
00387 }