00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "PromptCurveDialog.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 #ifndef QT_NO_DEBUG
00038 #include <iostream>
00039 #endif
00040
00041 extern const char* initFCTString[lifctENDOFLIST];
00042 extern const char* accumulateurFCTString[lafctENDOFLIST];
00043
00044 PromptCurveDialog :: PromptCurveDialog(QWidget* parent )
00045 :QDialog(parent),
00046
00047
00048 pMainGrid(NULL),
00049 pFunctionsBox(NULL), pZoneBox(NULL), pFunctionsGrid(NULL), pZoneGrid(NULL), pButtonsGrid(NULL),
00050
00051 pLabelCurvesList(NULL), pCurvesList(NULL),
00052
00053
00054 pPointBox(NULL), pParamBox(NULL), pZoneSizeBox(NULL), pZoneGeneratorBox(NULL), pPointGrid(NULL), pParamGrid(NULL), pZoneSizeGrid(NULL), pZoneGeneratorGrid(NULL),
00055
00056 pLabelNbPoints(NULL), pNbPoints(NULL),
00057 pLabelPointX(NULL), pPointX(NULL),
00058 pLabelPointY(NULL), pPointY(NULL),
00059
00060
00061 pLabelPA(NULL), pPA(NULL),
00062 pLabelPB(NULL), pPB(NULL),
00063 pLabelPC(NULL), pPC(NULL),
00064 pLabelPD(NULL), pPD(NULL),
00065
00066 pLabelWidth(NULL), pWidth(NULL),
00067 pLabelHeight(NULL), pHeight(NULL),
00068 pLabelX(NULL), pX(NULL),
00069 pLabelY(NULL), pY(NULL),
00070 pLabelW(NULL), pW(NULL),
00071 pLabelH(NULL), pH(NULL),
00072
00073 pCancelButton(NULL),
00074 pDefaultButton(NULL),
00075 pStartButton(NULL)
00076 {
00077
00078 pMainGrid = new QGridLayout(this);
00079
00080 this->createListsFunctions();
00081
00082 this->createSpinBoxes();
00083
00084 this->createButtons();
00085
00086
00087 #ifndef QT_NO_DEBUG
00088 std::cout << "PromptCurveDialog created" << std::endl;
00089 #endif
00090 }
00091
00092 void PromptCurveDialog :: createButtons(void)
00093 {
00094 const int actualRowNumber = pMainGrid->rowCount();
00095
00096 pButtonsGrid = new QHBoxLayout(0);
00097 pMainGrid->addLayout(pButtonsGrid, actualRowNumber, 0, Qt::AlignRight);
00098
00099 pStartButton = new QPushButton(tr("Start"), this);
00100 pButtonsGrid->addWidget(pStartButton);
00101
00102 pDefaultButton = new QPushButton(tr("Default"), this);
00103 pButtonsGrid->addWidget(pDefaultButton);
00104
00105 pCancelButton = new QPushButton(tr("Cancel"), this);
00106 pButtonsGrid->addWidget(pCancelButton);
00107
00108 connect(pStartButton, SIGNAL(clicked()), this, SLOT(startGeneration()));
00109 connect(pDefaultButton, SIGNAL(clicked()), this, SLOT(applyDefaultValues()));
00110 connect(pCancelButton, SIGNAL(clicked()), this, SLOT(cancelSettings()));
00111
00112 #ifndef QT_NO_DEBUG
00113 std::cout << "\tPromptCurveDialog buttons created" << std::endl;
00114 #endif
00115 }
00116
00117 void PromptCurveDialog :: createListsFunctions(void)
00118 {
00119 pFunctionsBox = new QGroupBox(tr("Functions:"), this);
00120 pMainGrid->addWidget(pFunctionsBox,1,0,Qt::AlignCenter);
00121
00122 pFunctionsGrid = new QGridLayout(pFunctionsBox);
00123
00124 pLabelCurvesList = new QLabel(tr("List of functions for fractales:"), this);
00125 pCurvesList = new QComboBox(this);
00126
00127
00128 for ( unsigned int i = 0 ; i < lcfctENDOFLIST ; i++ )
00129 {
00130 pCurvesList->addItem(curveFCTString[i].name, i);
00131 }
00132
00133 connect(pCurvesList, SIGNAL(currentIndexChanged(int)), this, SLOT(functionSelectedChanged(int)));
00134
00135 pFunctionsGrid->addWidget(pLabelCurvesList, 1, 0, Qt::AlignLeft);
00136 pFunctionsGrid->addWidget(pCurvesList, 1, 1, Qt::AlignCenter);
00137
00138 #ifndef QT_NO_DEBUG
00139 std::cout << "\tPromptCurveDialog: Lists created" << std::endl;
00140 #endif
00141 }
00142
00143 void PromptCurveDialog :: createSpinBoxes(void)
00144 {
00145 pPointBox = new QGroupBox(tr("Point settings:"), this);
00146 pMainGrid->addWidget(pPointBox,1,1,Qt::AlignLeft);
00147
00148 pParamBox = new QGroupBox(tr("Param settings:"), this);
00149 pMainGrid->addWidget(pParamBox,2,1,Qt::AlignCenter);
00150
00151 pZoneBox = new QGroupBox(tr("Zone settings:"), this);
00152 pMainGrid->addWidget(pZoneBox,2,0,Qt::AlignCenter);
00153
00154 pZoneGrid = new QHBoxLayout(pZoneBox);
00155
00156
00157 {
00158 pPointGrid = new QGridLayout(pPointBox);
00159
00160 pLabelNbPoints = new QLabel(tr("Number of points:"), this);
00161 pNbPoints = new QSpinBox(this);
00162
00163 pNbPoints->setMaximum(2147483647);
00164 pNbPoints->setValue(10000);
00165
00166 pPointGrid->addWidget(pLabelNbPoints, 0, 0, Qt::AlignLeft);
00167 pPointGrid->addWidget(pNbPoints, 0, 1, Qt::AlignCenter);
00168
00169 pLabelPointX = new QLabel(tr("Point X:"), this);
00170 pPointX = new QDoubleSpinBox(this);
00171
00172 pPointX->setDecimals(3);
00173 pPointX->setRange(-2147483647, 2147483647);
00174
00175 pPointGrid->addWidget(pLabelPointX, 1, 0, Qt::AlignLeft);
00176 pPointGrid->addWidget(pPointX, 1, 1, Qt::AlignCenter);
00177
00178 pLabelPointY = new QLabel(tr("Point Y:"), this);
00179 pPointY = new QDoubleSpinBox(this);
00180
00181 pPointY->setDecimals(3);
00182 pPointY->setRange(-2147483647, 2147483647);
00183
00184 pPointGrid->addWidget(pLabelPointY, 2, 0, Qt::AlignLeft);
00185 pPointGrid->addWidget(pPointY, 2, 1, Qt::AlignCenter);
00186 }
00187
00188
00189 {
00190 pParamGrid = new QGridLayout(pParamBox);
00191
00192 pLabelPA = new QLabel(tr("PA:"), this);
00193 pPA = new QDoubleSpinBox(this);
00194
00195 pPA->setDecimals(3);
00196 pPA->setRange(-2147483647, 2147483647);
00197
00198 pParamGrid->addWidget(pLabelPA, 0, 0, Qt::AlignLeft);
00199 pParamGrid->addWidget(pPA, 0, 1, Qt::AlignCenter);
00200
00201 pLabelPB = new QLabel(tr("PB:"), this);
00202 pPB = new QDoubleSpinBox(this);
00203
00204 pPB->setDecimals(3);
00205 pPB->setRange(-2147483647, 2147483647);
00206
00207 pParamGrid->addWidget(pLabelPB, 1, 0, Qt::AlignLeft);
00208 pParamGrid->addWidget(pPB, 1, 1, Qt::AlignCenter);
00209
00210 pLabelPC = new QLabel(tr("PC:"), this);
00211 pPC = new QDoubleSpinBox(this);
00212
00213 pPC->setDecimals(3);
00214 pPC->setRange(-2147483647, 2147483647);
00215
00216 pParamGrid->addWidget(pLabelPC, 2, 0, Qt::AlignLeft);
00217 pParamGrid->addWidget(pPC, 2, 1, Qt::AlignCenter);
00218
00219 pLabelPD = new QLabel(tr("PD:"), this);
00220 pPD = new QDoubleSpinBox(this);
00221
00222 pPD->setDecimals(3);
00223 pPD->setRange(-2147483647, 2147483647);
00224
00225 pParamGrid->addWidget(pLabelPD, 3, 0, Qt::AlignLeft);
00226 pParamGrid->addWidget(pPD, 3, 1, Qt::AlignCenter);
00227 }
00228
00229
00230 {
00231 pZoneSizeBox = new QGroupBox(tr("Image size:"), this);
00232 pZoneGrid->addWidget(pZoneSizeBox);
00233
00234 pZoneSizeGrid = new QGridLayout(pZoneSizeBox);
00235
00236 pLabelWidth = new QLabel(tr("Image width:"), this);
00237 pWidth = new QSpinBox(this);
00238
00239 pWidth->setMaximum(2147483647);
00240 pWidth->setValue(1000);
00241
00242 pZoneSizeGrid->addWidget(pLabelWidth, 0, 0, Qt::AlignLeft);
00243 pZoneSizeGrid->addWidget(pWidth, 0, 1, Qt::AlignCenter);
00244
00245 pLabelHeight = new QLabel(tr("Image height:"), this);
00246 pHeight = new QSpinBox(this);
00247
00248 pHeight->setMaximum(2147483647);
00249 pHeight->setValue(1000);
00250
00251 pZoneSizeGrid->addWidget(pLabelHeight, 1, 0, Qt::AlignLeft);
00252 pZoneSizeGrid->addWidget(pHeight, 1, 1, Qt::AlignCenter);
00253 }
00254
00255
00256 {
00257 pZoneGeneratorBox = new QGroupBox(tr("Fractale settings:"), this);
00258 pZoneGrid->addWidget(pZoneGeneratorBox);
00259
00260 pZoneGeneratorGrid = new QGridLayout(pZoneGeneratorBox);
00261
00262 pLabelX = new QLabel(tr("X:"), this);
00263 pX = new QDoubleSpinBox(this);
00264
00265 pX->setDecimals(3);
00266 pX->setRange(-2147483647, 2147483647);
00267
00268 pZoneGeneratorGrid->addWidget(pLabelX, 0, 0, Qt::AlignLeft);
00269 pZoneGeneratorGrid->addWidget(pX, 0, 1, Qt::AlignCenter);
00270
00271 pLabelY = new QLabel(tr("Y:"), this);
00272 pY = new QDoubleSpinBox(this);
00273
00274 pY->setDecimals(3);
00275 pY->setRange(-2147483647, 2147483647);
00276
00277 pZoneGeneratorGrid->addWidget(pLabelY, 1, 0, Qt::AlignLeft);
00278 pZoneGeneratorGrid->addWidget(pY, 1, 1, Qt::AlignCenter);
00279
00280 pLabelW = new QLabel(tr("W:"), this);
00281 pW = new QDoubleSpinBox(this);
00282
00283 pW->setDecimals(3);
00284 pW->setRange(-2147483647, 2147483647);
00285
00286 pZoneGeneratorGrid->addWidget(pLabelW, 2, 0, Qt::AlignLeft);
00287 pZoneGeneratorGrid->addWidget(pW, 2, 1, Qt::AlignCenter);
00288
00289 pLabelH = new QLabel(tr("H:"), this);
00290 pH = new QDoubleSpinBox(this);
00291
00292 pH->setDecimals(3);
00293 pH->setRange(-2147483647, 2147483647);
00294
00295 pZoneGeneratorGrid->addWidget(pLabelH, 3, 0, Qt::AlignLeft);
00296 pZoneGeneratorGrid->addWidget(pH, 3, 1, Qt::AlignCenter);
00297 }
00298
00299 this->applyDefaultValues();
00300
00301 #ifndef QT_NO_DEBUG
00302 std::cout << "\tPromptDialog: Spin Boxes created" << std::endl;
00303 #endif
00304 }
00305
00306 PromptCurveDialog :: ~PromptCurveDialog(void)
00307 {
00308
00309 delete pStartButton;
00310 delete pDefaultButton;
00311 delete pCancelButton;
00312
00313
00314 delete pH; delete pLabelH;
00315 delete pW; delete pLabelW;
00316 delete pY; delete pLabelY;
00317 delete pX; delete pLabelX;
00318
00319 delete pHeight; delete pLabelHeight;
00320 delete pWidth; delete pLabelWidth;
00321
00322
00323
00324 delete pLabelPA; delete pPA;
00325 delete pLabelPB; delete pPB;
00326 delete pLabelPC; delete pPC;
00327 delete pLabelPD; delete pPD;
00328
00329
00330 delete pPointY; delete pLabelPointY;
00331 delete pPointX; delete pLabelPointX;
00332 delete pNbPoints; delete pLabelNbPoints;
00333
00334 delete pZoneGeneratorGrid;
00335 delete pZoneSizeGrid;
00336
00337 delete pZoneGeneratorBox;
00338 delete pZoneSizeBox;
00339
00340
00341 delete pCurvesList; delete pLabelCurvesList;
00342
00343
00344 delete pPointGrid;
00345 delete pParamGrid;
00346 delete pZoneGrid;
00347 delete pFunctionsGrid;
00348 delete pButtonsGrid;
00349
00350 delete pPointBox;
00351 delete pParamBox;
00352 delete pZoneBox;
00353 delete pFunctionsBox;
00354
00355 delete pMainGrid;
00356
00357
00358
00359 #ifndef QT_NO_DEBUG
00360 std::cout << "PromptCurveDialog deleted" << std::endl;
00361 #endif
00362 }
00363
00365
00366 void PromptCurveDialog :: startGeneration(void)
00367 {
00368
00369
00370
00371 #ifndef QT_NO_DEBUG
00372 std::cout << "Starting of the generation" << std::endl;
00373
00374 #endif
00375
00376 this->done(0);
00377 }
00378
00379 void PromptCurveDialog :: cancelSettings(void)
00380 {
00381 this->close();
00382 }
00383
00384 void PromptCurveDialog :: reject(void)
00385 {
00386 this->done(1);
00387
00388 #ifndef QT_NO_DEBUG
00389 std::cout << "PromptDialog canceled" << std::endl;
00390 #endif
00391 }
00392
00393 void PromptCurveDialog :: functionSelectedChanged(int index)
00394 {
00395 (void)index;
00396 #ifndef QT_NO_DEBUG
00397 std::cout << "\t\tPromptDialog: SLOT(functionSelectedChanged) -> index: " << index << std::endl;
00398 #endif
00399
00400 applyDefaultValues();
00401 }
00402
00403 void PromptCurveDialog :: applyDefaultValues(void)
00404 {
00405 int index = pCurvesList->currentIndex();
00406
00407 pX->setValue(curveFCTString[index].x);
00408 pY->setValue(curveFCTString[index].y);
00409 pW->setValue(curveFCTString[index].w);
00410 pH->setValue(curveFCTString[index].h);
00411
00412 pNbPoints->setValue(curveFCTString[index].nbPoints);
00413
00414 pPointX->setValue(curveFCTString[index].pX);
00415 pPointY->setValue(curveFCTString[index].pY);
00416
00417 pPA->setValue(curveFCTString[index].paramA);
00418 pPB->setValue(curveFCTString[index].paramB);
00419 pPC->setValue(curveFCTString[index].paramC);
00420 pPD->setValue(curveFCTString[index].paramD);
00421
00422
00423 #ifndef QT_NO_DEBUG
00424 std::cout << "\tPromptCurveDialog: SLOT(applyDefaultValues)" << std::endl;
00425 #endif
00426 }
00427
00428 ListCurveFCT PromptCurveDialog :: getCurve(void)const
00429 {
00430 return static_cast<ListCurveFCT>(pCurvesList->currentIndex());
00431 }
00432
00433 unsigned int PromptCurveDialog :: getNbPoints(void)const
00434 {
00435 return pNbPoints->value();
00436 }
00437
00438 double PromptCurveDialog :: getPointX(void)const
00439 {
00440 return pPointX->value();
00441 }
00442
00443 double PromptCurveDialog :: getPointY(void)const
00444 {
00445 return pPointY->value();
00446 }
00447
00448 double PromptCurveDialog :: getPA(void)const
00449 {
00450 return pPA->value();
00451 }
00452
00453 double PromptCurveDialog :: getPB(void)const
00454 {
00455 return pPB->value();
00456 }
00457
00458 double PromptCurveDialog :: getPC(void)const
00459 {
00460 return pPC->value();
00461 }
00462
00463 double PromptCurveDialog :: getPD(void)const
00464 {
00465 return pPD->value();
00466 }
00467
00468 unsigned int PromptCurveDialog :: getImageW(void)const
00469 {
00470 return pWidth->value();
00471 }
00472
00473 unsigned int PromptCurveDialog :: getImageH(void)const
00474 {
00475 return pHeight->value();
00476 }
00477
00478 double PromptCurveDialog :: getZoneX(void)const
00479 {
00480 return pX->value();
00481 }
00482
00483 double PromptCurveDialog :: getZoneY(void)const
00484 {
00485 return pY->value();
00486 }
00487
00488 double PromptCurveDialog :: getZoneW(void)const
00489 {
00490 return pW->value();
00491 }
00492
00493 double PromptCurveDialog :: getZoneH(void)const
00494 {
00495 return pH->value();
00496 }