00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "mainwindow.h"
00015 #include <QEvent>
00016
00022 MainWindow::MainWindow(QWidget *parent) :
00023 QMainWindow(parent)
00024 {
00025 qApp->installTranslator(&m_Translator);
00026
00027 setObjectName(QString::fromUtf8("MainWindow"));
00028 resize(800,600);
00029
00030 QWidget* centralWidget = new QWidget(this);
00031 setCentralWidget(centralWidget);
00032
00033 m_pMainLayout = new QHBoxLayout(centralWidget);
00034
00035 m_pToolBox = new QToolBox(centralWidget);
00036 m_pParametersBox = new QWidget(m_pToolBox);
00037
00038 m_pParametersLayout = new QFormLayout(m_pParametersBox);
00039 m_pParametersLayout->setSpacing(2);
00040 m_pParametersLayout->setContentsMargins(11, 11, 11, 11);
00041 m_pParametersLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
00042
00043 m_pZoomLabel = new QLabel(m_pParametersBox);
00044 m_pZoomSpin = new QDoubleSpinBox(m_pParametersBox);
00045 m_pZoomSpin->setObjectName(QString::fromUtf8("SpinZoom"));
00046 m_pZoomSpin->setDecimals(16);
00047 m_pZoomSpin->setSingleStep(0.0001);
00048
00049 m_pPosXLabel = new QLabel(m_pParametersBox);
00050 m_pPosXSpin = new QDoubleSpinBox(m_pParametersBox);
00051 m_pPosXSpin->setObjectName(QString::fromUtf8("SpinPosX"));
00052 m_pPosXSpin->setRange(-99999,99999);
00053 m_pPosXSpin->setDecimals(5);
00054 m_pPosXSpin->setSingleStep(0.01);
00055
00056 m_pPosYLabel = new QLabel(m_pParametersBox);
00057 m_pPosYSpin = new QDoubleSpinBox(m_pParametersBox);
00058 m_pPosYSpin->setObjectName(QString::fromUtf8("SpinPosY"));
00059 m_pPosYSpin->setRange(-99999,99999);
00060 m_pPosYSpin->setDecimals(5);
00061 m_pPosYSpin->setSingleStep(0.0001);
00062
00063 m_pIterationLabel = new QLabel(m_pParametersBox);
00064 m_pIterationSpin = new QSpinBox(m_pParametersBox);
00065 m_pIterationSpin->setObjectName(QString::fromUtf8("SpinPass"));
00066 m_pIterationSpin->setSingleStep(100);
00067 m_pIterationSpin->setMaximum(999999);
00068
00069 m_pFractalLabel = new QLabel(m_pParametersBox);
00070 m_pFractalComboBox = new QComboBox(m_pParametersBox);
00071 m_pFractalComboBox->addItem("MandelBrot",Fractal_MandelBrot);
00072 m_pFractalComboBox->addItem("BuddhaBrot",Fractal_BuddhaBrot);
00073 m_pFractalComboBox->addItem("Julia",Fractal_Julia);
00074 #if QT_VERSION >= 0x040600
00075 m_pFractalComboBox->addItem("MandelBrot - OpenGL",Fractal_MandelBrot_OpenGL);
00076 m_pFractalComboBox->addItem("Julia - OpenGL",Fractal_Julia_OpenGL);
00077 #endif
00078 m_pFractalComboBox->setCurrentIndex(0);
00079
00080
00081 m_pBuddhaBrotParameters = new QWidget(m_pParametersBox);
00082 m_pBuddhaBrotParametersLayout = new QFormLayout(m_pBuddhaBrotParameters);
00083 m_pBuddhaBrotParametersLayout->setSpacing(6);
00084 m_pBuddhaBrotParametersLayout->setContentsMargins(11, 11, 11, 11);
00085 m_pBuddhaBrotParametersLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
00086
00087 m_pPrecisionLabel = new QLabel(m_pBuddhaBrotParameters);
00088 m_pPrecisionSpin = new QDoubleSpinBox(m_pBuddhaBrotParameters);
00089 m_pPrecisionSpin->setObjectName(QString::fromUtf8("SpinPrecision"));
00090 m_pPrecisionSpin->setRange(0.00001,1);
00091 m_pPrecisionSpin->setDecimals(5);
00092 m_pPrecisionSpin->setSingleStep(0.01);
00093
00094 m_pMinIterationLabel = new QLabel(m_pBuddhaBrotParameters);
00095 m_pMinIterationSpin = new QSpinBox(m_pBuddhaBrotParameters);
00096 m_pMinIterationSpin->setObjectName(QString::fromUtf8("SpinMinIteration"));
00097 m_pMinIterationSpin->setRange(0,999999);
00098 m_pMinIterationSpin->setSingleStep(10);
00099
00100 m_pBuddhaBrotParametersLayout->setWidget(0,QFormLayout::LabelRole,m_pPrecisionLabel);
00101 m_pBuddhaBrotParametersLayout->setWidget(0,QFormLayout::FieldRole,m_pPrecisionSpin);
00102 m_pBuddhaBrotParametersLayout->setWidget(1,QFormLayout::LabelRole,m_pMinIterationLabel);
00103 m_pBuddhaBrotParametersLayout->setWidget(1,QFormLayout::FieldRole,m_pMinIterationSpin);
00104
00105 m_pJuliaParameters = new QWidget(m_pParametersBox);
00106 m_pJuliaParameters->setVisible(false);
00107 m_pJuliaParametersLayout = new QFormLayout(m_pJuliaParameters);
00108 m_pJuliaParametersLayout->setSpacing(6);
00109 m_pJuliaParametersLayout->setContentsMargins(11, 11, 11, 11);
00110 m_pJuliaParametersLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
00111
00112 m_pRealLabel = new QLabel(m_pJuliaParameters);
00113 m_pRealSpin = new QDoubleSpinBox(m_pJuliaParameters);
00114 m_pRealSpin->setObjectName(QString::fromUtf8("SpinReal"));
00115 m_pRealSpin->setRange(-99999,99999);
00116 m_pRealSpin->setDecimals(5);
00117 m_pRealSpin->setSingleStep(0.01);
00118
00119 m_pImagLabel = new QLabel(m_pJuliaParameters);
00120 m_pImagSpin = new QDoubleSpinBox(m_pJuliaParameters);
00121 m_pImagSpin->setObjectName(QString::fromUtf8("SpinImaginary"));
00122 m_pImagSpin->setRange(-99999,99999);
00123 m_pImagSpin->setDecimals(5);
00124 m_pImagSpin->setSingleStep(0.01);
00125
00126 m_pJuliaParametersLayout->setWidget(0,QFormLayout::LabelRole,m_pRealLabel);
00127 m_pJuliaParametersLayout->setWidget(0,QFormLayout::FieldRole,m_pRealSpin);
00128 m_pJuliaParametersLayout->setWidget(1,QFormLayout::LabelRole,m_pImagLabel);
00129 m_pJuliaParametersLayout->setWidget(1,QFormLayout::FieldRole,m_pImagSpin);
00130
00131 m_pParametersLayout->setWidget(0, QFormLayout::LabelRole, m_pZoomLabel);
00132 m_pParametersLayout->setWidget(0, QFormLayout::FieldRole, m_pZoomSpin);
00133 m_pParametersLayout->setWidget(1, QFormLayout::LabelRole, m_pPosXLabel);
00134 m_pParametersLayout->setWidget(1, QFormLayout::FieldRole, m_pPosXSpin);
00135 m_pParametersLayout->setWidget(2, QFormLayout::LabelRole, m_pPosYLabel);
00136 m_pParametersLayout->setWidget(2, QFormLayout::FieldRole, m_pPosYSpin);
00137 m_pParametersLayout->setWidget(3, QFormLayout::LabelRole, m_pIterationLabel);
00138 m_pParametersLayout->setWidget(3, QFormLayout::FieldRole, m_pIterationSpin);
00139 m_pParametersLayout->setWidget(4, QFormLayout::LabelRole, m_pFractalLabel);
00140 m_pParametersLayout->setWidget(4, QFormLayout::FieldRole, m_pFractalComboBox);
00141
00142 m_pParametersLayout->setWidget(5, QFormLayout::SpanningRole, m_pBuddhaBrotParameters);
00143 m_pParametersLayout->setWidget(6, QFormLayout::SpanningRole, m_pJuliaParameters);
00144
00145 m_pToolBox->addItem(m_pParametersBox, tr("Parameters"));
00146
00147 m_pColorsBox = new QWidget(m_pToolBox);
00148 m_pColorsLayout = new QFormLayout(m_pColorsBox);
00149 m_pRedShade = new ShadeWidget(ShadeWidget::RedShade,m_pColorsBox);
00150 m_pGreenShade = new ShadeWidget(ShadeWidget::GreenShade,m_pColorsBox);
00151 m_pBlueShade = new ShadeWidget(ShadeWidget::BlueShade,m_pColorsBox);
00152 m_pRGBShade = new ShadeWidget(ShadeWidget::RGBShade,m_pColorsBox);
00153 m_pRGBShade->hoverPoints()->setDisabled(true);
00154
00155 m_pDilatationLabel = new QLabel(m_pColorsBox);
00156 m_pDilatationSpin = new QDoubleSpinBox(m_pColorsBox);
00157 m_pDilatationSpin->setRange(0.0000001,99999999);
00158
00159 m_pColorsLayout->setWidget(0, QFormLayout::SpanningRole, m_pRedShade);
00160 m_pColorsLayout->setWidget(1, QFormLayout::SpanningRole, m_pGreenShade);
00161 m_pColorsLayout->setWidget(2, QFormLayout::SpanningRole, m_pBlueShade);
00162 m_pColorsLayout->setWidget(3, QFormLayout::SpanningRole, m_pRGBShade);
00163 m_pColorsLayout->setWidget(4, QFormLayout::LabelRole, m_pDilatationLabel);
00164 m_pColorsLayout->setWidget(4, QFormLayout::FieldRole, m_pDilatationSpin);
00165
00166 m_pToolBox->addItem(m_pColorsBox, tr("Colors"));
00167
00168 m_pRenderBox = new QWidget(m_pToolBox);
00169 m_pRendersLayout = new QFormLayout(m_pRenderBox);
00170 m_pRendersLayout->setSpacing(6);
00171 m_pRendersLayout->setContentsMargins(11, 11, 11, 11);
00172 m_pRendersLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
00173
00174 m_pThreadCountLabel = new QLabel(m_pRenderBox);
00175 m_pThreadCountSpin = new QSpinBox(m_pRenderBox);
00176 m_pThreadCountSpin->setRange(1,512);
00177
00178 m_pWidthLabel = new QLabel(m_pRenderBox);
00179 m_pWidthSpin = new QSpinBox(m_pRenderBox);
00180 m_pWidthSpin->setRange(1,999999);
00181
00182 m_pHeightLabel = new QLabel(m_pRenderBox);
00183 m_pHeightSpin = new QSpinBox(m_pRenderBox);
00184 m_pHeightSpin->setRange(1,999999);
00185
00186 m_pSmoothLabel = new QLabel(m_pRenderBox);
00187 m_pSmoothCheckBox = new QCheckBox(m_pRenderBox);
00188
00189 m_pAnimatedLabel = new QLabel(m_pRenderBox);
00190 m_pAnimatedCheckBox = new QCheckBox(m_pRenderBox);
00191
00192 m_pRendersLayout->setWidget(0, QFormLayout::LabelRole, m_pThreadCountLabel);
00193 m_pRendersLayout->setWidget(0, QFormLayout::FieldRole, m_pThreadCountSpin);
00194 m_pRendersLayout->setWidget(1, QFormLayout::LabelRole, m_pWidthLabel);
00195 m_pRendersLayout->setWidget(1, QFormLayout::FieldRole, m_pWidthSpin);
00196 m_pRendersLayout->setWidget(2, QFormLayout::LabelRole, m_pHeightLabel);
00197 m_pRendersLayout->setWidget(2, QFormLayout::FieldRole, m_pHeightSpin);
00198 m_pRendersLayout->setWidget(3, QFormLayout::LabelRole, m_pSmoothLabel);
00199 m_pRendersLayout->setWidget(3, QFormLayout::FieldRole, m_pSmoothCheckBox);
00200 m_pRendersLayout->setWidget(4, QFormLayout::LabelRole, m_pAnimatedLabel);
00201 m_pRendersLayout->setWidget(4, QFormLayout::FieldRole, m_pAnimatedCheckBox);
00202 m_pToolBox->addItem(m_pRenderBox, tr("Render"));
00203
00204 m_pDisplay = new BrotDisplay();
00205 m_pDisplay->setObjectName(QString::fromUtf8("BrotDisplay"));
00206
00207 m_pDisplayScroll = new QScrollArea(centralWidget);
00208 m_pDisplayScroll->setAlignment(Qt::AlignCenter);
00209 m_pDisplayScroll->setWidget(m_pDisplay);
00210
00211 m_pMainLayout->addWidget(m_pToolBox,0,Qt::AlignLeft);
00212 m_pMainLayout->addWidget(m_pDisplayScroll,1);
00213 setLayout(m_pMainLayout);
00214
00215 m_pMenuBar = new QMenuBar(this);
00216 m_pMenuBar->setObjectName(QString::fromUtf8("menuBar"));
00217 m_pMenuFile = new QMenu(tr("File"),m_pMenuBar);
00218 m_pActionSave = new QAction(tr("SaveImage"),m_pMenuFile);
00219 m_pActionExit = new QAction(tr("Exit"),m_pMenuFile);
00220 m_pMenuFile->addAction(m_pActionSave);
00221 m_pMenuFile->addSeparator();
00222 m_pMenuFile->addAction(m_pActionExit);
00223 m_pMenuOptions = new QMenu(tr("Options"),m_pMenuBar);
00224 m_pMenuLanguage = new QMenu(tr("Language"),m_pMenuOptions);
00225 m_pActionLanguageFrench = new QAction("Français",m_pMenuLanguage);
00226 m_pActionLanguageFrench->setCheckable(true);
00227 m_pActionLanguageEnglish = new QAction("English",m_pMenuLanguage);
00228 m_pActionLanguageEnglish->setCheckable(true);
00229
00230 m_pMenuLanguage->addAction(m_pActionLanguageFrench);
00231 m_pMenuLanguage->addAction(m_pActionLanguageEnglish);
00232 m_pMenuOptions->addMenu(m_pMenuLanguage);
00233 m_pActionAbout = new QAction(tr("About"),m_pMenuBar);
00234
00235 m_pMenuBar->addMenu(m_pMenuFile);
00236 m_pMenuBar->addMenu(m_pMenuOptions);
00237 setMenuBar(m_pMenuBar);
00238
00239 setStatusBar(new QStatusBar(this));
00240
00241 m_pRenderButton = new QPushButton(statusBar());
00242 m_pRenderButton->resize(75,30);
00243 m_pProgressBar = new QProgressBar(statusBar());
00244 m_pProgressBar->setRange(0,100);
00245 m_pProgressBar->resize(250,30);
00246 m_pProgressBar->setTextVisible(false);
00247 m_pProgressLabel = new QLabel(statusBar());
00248 m_pProgressLabel->resize(75,30);
00249 m_pCancelButton = new QPushButton(statusBar());
00250 m_pCancelButton->resize(75,30);
00251 statusBar()->addWidget(m_pRenderButton,0);
00252 statusBar()->addWidget(m_pProgressBar,0);
00253 statusBar()->addWidget(m_pProgressLabel,0);
00254 statusBar()->addWidget(m_pCancelButton,0);
00255
00256 m_Translator.load("quickbrot_fr");
00257 m_pActionLanguageFrench->setChecked(true);
00258 m_pActionLanguageEnglish->setChecked(false);
00259
00260 TranslateUI();
00261
00262 connect(m_pZoomSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetZoom(double)));
00263 connect(m_pPosXSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetPosX(double)));
00264 connect(m_pPosYSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetPosY(double)));
00265 connect(m_pIterationSpin, SIGNAL(valueChanged(int)), m_pDisplay, SLOT(SetIteration(int)));
00266 connect(m_pFractalComboBox, SIGNAL(activated(int)), this, SLOT(SetFractal(int)));
00267
00268 connect(m_pPrecisionSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetPrecision(double)));
00269 connect(m_pRealSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetReal(double)));
00270 connect(m_pImagSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetImaginary(double)));
00271
00272 connect(m_pRedShade, SIGNAL(colorsChanged()), this, SLOT(colorsChanged()));
00273 connect(m_pGreenShade, SIGNAL(colorsChanged()), this, SLOT(colorsChanged()));
00274 connect(m_pBlueShade, SIGNAL(colorsChanged()), this, SLOT(colorsChanged()));
00275 connect(m_pDilatationSpin, SIGNAL(valueChanged(double)), m_pDisplay, SLOT(SetDilatation(double)));
00276
00277 connect(m_pThreadCountSpin, SIGNAL(valueChanged(int)), m_pDisplay, SLOT(SetThreadCount(int)));
00278 connect(m_pWidthSpin, SIGNAL(valueChanged(int)), this, SLOT(SetRenderWidth(int)));
00279 connect(m_pHeightSpin, SIGNAL(valueChanged(int)), this, SLOT(SetRenderHeight(int)));
00280 connect(m_pSmoothCheckBox, SIGNAL(stateChanged(int)), this, SLOT(SetSmoothColors(int)));
00281 connect(m_pAnimatedCheckBox, SIGNAL(stateChanged(int)), this, SLOT(SetAnimatedRender(int)));
00282
00283 connect(m_pDisplay, SIGNAL(ZoomChanged(double)), m_pZoomSpin, SLOT(setValue(double)));
00284 connect(m_pDisplay, SIGNAL(PosXChanged(double)), m_pPosXSpin, SLOT(setValue(double)));
00285 connect(m_pDisplay, SIGNAL(PosYChanged(double)), m_pPosYSpin, SLOT(setValue(double)));
00286 connect(m_pDisplay, SIGNAL(IterationChanged(int)), m_pIterationSpin, SLOT(setValue(int)));
00287 connect(m_pDisplay, SIGNAL(ThreadCountChanged(int)), m_pThreadCountSpin, SLOT(setValue(int)));
00288
00289 connect(m_pDisplay, SIGNAL(PrecisionChanged(double)), m_pPrecisionSpin, SLOT(setValue(double)));
00290 connect(m_pDisplay, SIGNAL(RealChanged(double)), m_pRealSpin, SLOT(setValue(double)));
00291 connect(m_pDisplay, SIGNAL(ImaginaryChanged(double)), m_pImagSpin, SLOT(setValue(double)));
00292
00293 connect(m_pDisplay, SIGNAL(DilatationChanged(double)), m_pDilatationSpin, SLOT(setValue(double)));
00294
00295 connect(m_pDisplay, SIGNAL(Progress(float)), this, SLOT(OnProgress(float)));
00296
00297 connect(m_pRenderButton, SIGNAL(clicked(bool)), m_pDisplay, SLOT(RedrawFractal()));
00298 connect(m_pCancelButton, SIGNAL(clicked(bool)), this, SLOT(Cancel(bool)));
00299
00300 connect(m_pActionSave, SIGNAL(triggered()), this, SLOT(SaveImage()));
00301 connect(m_pActionExit, SIGNAL(triggered()), this, SLOT(close()));
00302
00303 connect(m_pActionLanguageFrench, SIGNAL(triggered()), this, SLOT(LanguageFrench()));
00304 connect(m_pActionLanguageEnglish, SIGNAL(triggered()), this, SLOT(LanguageEnglish()));
00305
00306 QMetaObject::connectSlotsByName(this);
00307
00308 if (m_pDisplay)
00309 {
00310 m_pDisplay->SetZoom(0.005);
00311 m_pDisplay->SetPosX(0.0);
00312 m_pDisplay->SetPosY(0.0);
00313 m_pDisplay->SetIteration(1000);
00314 m_pDisplay->SetPrecision(0.1);
00315 m_pDisplay->SetReal(-0.4);
00316 m_pDisplay->SetImaginary(0.6);
00317 m_pDisplay->SetThreadCount(QThread::idealThreadCount());
00318 m_pDisplay->SetDilatation(20.0);
00319 SetRenderWidth(640);
00320 SetRenderHeight(480);
00321 }
00322 SetFractal(Fractal_MandelBrot);
00323 SetSmoothColors(2);
00324 SetAnimatedRender(2);
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 m_Gradient << QGradientStop(0.0, QColor(255,255,0));
00355 m_Gradient << QGradientStop(0.25, QColor(0,0,0));
00356 m_Gradient << QGradientStop(0.4, QColor(0,0,0));
00357 m_Gradient << QGradientStop(0.6, QColor(32,32,128));
00358 m_Gradient << QGradientStop(0.8, QColor(192,0,0));
00359 m_Gradient << QGradientStop(1.0, QColor(255,255,0));
00360
00361 m_pRedShade->setPointsFromGradientStops(m_Gradient);
00362 m_pGreenShade->setPointsFromGradientStops(m_Gradient);
00363 m_pBlueShade->setPointsFromGradientStops(m_Gradient);
00364
00365 m_pRGBShade->setGradientStops(m_Gradient);
00366
00367 m_pDisplay->SetGradient(m_Gradient);
00368
00369 m_pProgressBar->setVisible(false);
00370 m_pProgressLabel->setVisible(false);
00371 m_pCancelButton->setVisible(false);
00372 m_pRenderButton->setVisible(true);
00373 }
00374
00379 MainWindow::~MainWindow()
00380 {
00381
00382 }
00383
00387 void MainWindow::TranslateUI()
00388 {
00389 m_pToolBox->setItemText(0,tr("Parameters"));
00390 m_pToolBox->setItemText(1,tr("Colors"));
00391 m_pToolBox->setItemText(2,tr("Render"));
00392
00393 m_pZoomLabel->setText(tr("Zoom"));
00394 m_pPosXLabel->setText(tr("PosX"));
00395 m_pPosYLabel->setText(tr("PosY"));
00396 m_pIterationLabel->setText(tr("Iteration"));
00397 m_pFractalLabel->setText(tr("Fractal"));
00398
00399 m_pPrecisionLabel->setText(tr("Precision"));
00400 m_pMinIterationLabel->setText(tr("MinIteration"));
00401
00402 m_pRealLabel->setText(tr("Real"));
00403 m_pImagLabel->setText(tr("Imaginary"));
00404
00405 m_pDilatationLabel->setText(tr("Dilatation"));
00406
00407 m_pThreadCountLabel->setText(tr("ThreadCount"));
00408 m_pWidthLabel->setText(tr("Width"));
00409 m_pHeightLabel->setText(tr("Height"));
00410 m_pSmoothLabel->setText(tr("SmoothColors"));
00411 m_pAnimatedLabel->setText(tr("AnimatedRender"));
00412
00413 m_pMenuFile->setTitle(tr("File"));
00414 m_pActionSave->setText(tr("SaveImage"));
00415 m_pActionExit->setText(tr("Exit"));
00416 m_pMenuOptions->setTitle(tr("Options"));
00417 m_pMenuLanguage->setTitle(tr("Language"));
00418 m_pActionAbout->setText(tr("About"));
00419
00420 m_pRenderButton->setText(tr("StartRender"));
00421 m_pCancelButton->setText(tr("Cancel"));
00422
00423 m_pParametersBox->update();
00424 }
00425
00430 void MainWindow::changeEvent(QEvent *e)
00431 {
00432 QMainWindow::changeEvent(e);
00433 switch (e->type()) {
00434 case QEvent::LanguageChange:
00435 TranslateUI();
00436 break;
00437 default:
00438
00439 break;
00440 }
00441 }
00442
00447 void MainWindow::OnProgress( float value )
00448 {
00449 if (m_pProgressBar)
00450 {
00451 m_pProgressBar->setValue(value*100);
00452 QString str;
00453 str.sprintf("%.2f %%",value*100);
00454 m_pProgressLabel->setText(str);
00455 if (value>=1.0)
00456 {
00457 if (m_pProgressBar->isVisible()==true)
00458 {
00459 m_pProgressBar->setVisible(false);
00460 m_pProgressLabel->setVisible(false);
00461 m_pCancelButton->setVisible(false);
00462 m_pRenderButton->setVisible(true);
00463 }
00464 }else{
00465 if (m_pProgressBar->isVisible()==false)
00466 {
00467 m_pProgressBar->setVisible(true);
00468 m_pProgressLabel->setVisible(true);
00469 m_pCancelButton->setVisible(true);
00470 m_pRenderButton->setVisible(false);
00471 }
00472 }
00473 }
00474 }
00475
00480 void MainWindow::SetFractal(int fractal)
00481 {
00482 m_pJuliaParameters->setVisible(false);
00483 m_pBuddhaBrotParameters->setVisible(false);
00484
00485 switch (fractal)
00486 {
00487 case Fractal_BuddhaBrot:
00488 m_pBuddhaBrotParameters->setVisible(true);
00489 break;
00490 case Fractal_Julia:
00491 case Fractal_Julia_OpenGL:
00492 m_pJuliaParameters->setVisible(true);
00493 break;
00494 };
00495
00496 if (m_pDisplay)
00497 {
00498 m_pDisplay->SetFractal((Fractal)fractal);
00499 }
00500 }
00501
00506 void MainWindow::SetRenderWidth(int width)
00507 {
00508 if (m_pDisplay && m_pDisplay->width()!=width)
00509 {
00510 m_pWidthSpin->setValue(width);
00511 m_pDisplay->resize(width, m_pDisplay->height());
00512 }
00513 }
00514
00519 void MainWindow::SetRenderHeight(int height)
00520 {
00521 if (m_pDisplay && m_pDisplay->height()!=height)
00522 {
00523 m_pHeightSpin->setValue(height);
00524 m_pDisplay->resize(m_pDisplay->width(), height);
00525 }
00526 }
00527
00532 void MainWindow::SetAnimatedRender(int animated)
00533 {
00534 if (m_pDisplay)
00535 {
00536 m_pDisplay->SetAnimatedRender(animated==0?false:true);
00537 if (m_pAnimatedCheckBox->checkState()!=(Qt::CheckState)animated)
00538 {
00539 m_pAnimatedCheckBox->setCheckState((Qt::CheckState)animated);
00540 }
00541 }
00542 }
00543
00548 void MainWindow::SetSmoothColors(int smooth)
00549 {
00550 if (m_pDisplay)
00551 {
00552 m_pDisplay->SetSmoothColors(smooth==0?false:true);
00553 if (m_pSmoothCheckBox->checkState()!=(Qt::CheckState)smooth)
00554 {
00555 m_pSmoothCheckBox->setCheckState((Qt::CheckState)smooth);
00556 }
00557 }
00558 }
00559
00564 void MainWindow::Cancel(bool)
00565 {
00566 if (m_pDisplay)
00567 {
00568 m_pDisplay->Cancel();
00569 }
00570 }
00571
00576 void MainWindow::SaveImage(void)
00577 {
00578 if (m_pDisplay)
00579 {
00580 QFileDialog dialog(this);
00581 dialog.setFileMode(QFileDialog::AnyFile);
00582 dialog.setAcceptMode(QFileDialog::AcceptSave);
00583 dialog.setNameFilter(tr("Images (*.png)"));
00584
00585 if (dialog.exec())
00586 {
00587 QString filename = dialog.selectedFiles()[0];
00588 if (filename.right(4).toLower()!=".png")
00589 {
00590 filename+=".png";
00591 }
00592 if (m_pDisplay->Save(filename))
00593 {
00594 statusBar()->showMessage(tr("ImageSaved"), 5000);
00595 }else{
00596 statusBar()->showMessage(tr("ImageSavedError"), 5000);
00597 }
00598 }
00599 }
00600 }
00601
00602 inline static bool x_less_than(const QPointF &p1, const QPointF &p2)
00603 {
00604 return p1.x() < p2.x();
00605 }
00606
00607
00612 void MainWindow::colorsChanged(void)
00613 {
00614 qreal w = m_pRGBShade->width();
00615 m_Gradient.clear();
00616 QPolygonF points;
00617
00618 points += m_pRedShade->points();
00619 points += m_pGreenShade->points();
00620 points += m_pBlueShade->points();
00621
00622 qSort(points.begin(), points.end(), x_less_than);
00623
00624 for (int i=0; i<points.size(); ++i) {
00625 qreal x = int(points.at(i).x());
00626 if (i < points.size() - 1 && x == points.at(i+1).x())
00627 continue;
00628 QColor color((0x00ff0000 & m_pRedShade->colorAt(int(x))) >> 16,
00629 (0x0000ff00 & m_pGreenShade->colorAt(int(x))) >> 8,
00630 (0x000000ff & m_pBlueShade->colorAt(int(x))));
00631
00632 if (x / w > 1)
00633 return;
00634
00635 m_Gradient << QGradientStop(x / w, color);
00636 }
00637
00638 m_pRGBShade->setGradientStops(m_Gradient);
00639
00640 m_pDisplay->SetGradient(m_Gradient);
00641 }
00642
00647 void MainWindow::LanguageChanged( int lang )
00648 {
00649 m_pActionLanguageFrench->setChecked(false);
00650 m_pActionLanguageEnglish->setChecked(false);
00651
00652 if (lang==0)
00653 {
00654 m_Translator.load("quickbrot_fr");
00655 m_pActionLanguageFrench->setChecked(true);
00656
00657 }else if (lang==1)
00658 {
00659 m_Translator.load("quickbrot_en");
00660 m_pActionLanguageEnglish->setChecked(true);
00661
00662 }
00663 TranslateUI();
00664 }
00665
00669 void MainWindow::LanguageFrench()
00670 {
00671 LanguageChanged(0);
00672 }
00673
00677 void MainWindow::LanguageEnglish()
00678 {
00679 LanguageChanged(1);
00680 }