00001 /* 00002 # Copyright (c) 2010 Louis du Verdier 00003 # 00004 # Permission is hereby granted, free of charge, to any person obtaining a copy 00005 # of this software and associated documentation files (the "Software"), to deal 00006 # in the Software without restriction, including without limitation the rights 00007 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 # copies of the Software, and to permit persons to whom the Software is 00009 # furnished to do so, subject to the following conditions: 00010 # 00011 # The above copyright notice and this permission notice shall be included in 00012 # all copies or substantial portions of the Software. 00013 # 00014 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 # THE SOFTWARE. 00021 */ 00022 00023 #ifndef MAINWINDOW_H 00024 #define MAINWINDOW_H 00025 00026 #include <QtGui> 00027 #include <complex> 00028 #include "Generator.h" 00029 00037 class ToolsArea; 00038 class GraphicsScene; 00039 class GraphicsView; 00040 class MainWindow; 00041 class Generator; 00042 00047 class ToolsArea : public QDockWidget 00048 { 00049 Q_OBJECT 00050 00051 public: 00056 ToolsArea(MainWindow *p = 0); 00057 00058 public slots: 00062 void setEffect(); 00066 void unsetEffect(); 00067 00068 private: 00069 MainWindow *parent; 00070 QGraphicsColorizeEffect *effect; 00071 QGraphicsColorizeEffect *_effect; 00072 }; 00073 00078 class GraphicsScene : public QGraphicsScene 00079 { 00080 Q_OBJECT 00081 00082 public: 00087 GraphicsScene(MainWindow *p = 0); 00088 MainWindow *parent; 00093 void showMandelbrot(QImage set); 00099 void changeSceneBgColor(QImage set); 00100 QGraphicsPixmapItem *renderItem; 00102 protected: 00107 void mouseMoveEvent(QGraphicsSceneMouseEvent *); 00108 }; 00109 00115 class GraphicsView : public QGraphicsView 00116 { 00117 Q_OBJECT 00118 00119 public: 00124 GraphicsView(MainWindow *p = 0); 00125 00126 signals: 00130 void mouseEnter(); 00134 void mouseLeave(); 00135 00136 protected: 00141 void enterEvent(QEvent *); 00146 void leaveEvent(QEvent *); 00150 void contextMenuEvent(QContextMenuEvent *); 00151 00152 private: 00153 MainWindow *parent; 00154 }; 00155 00160 class MainWindow : public QMainWindow 00161 { 00162 Q_OBJECT 00163 00164 public: 00169 MainWindow(); 00173 ~MainWindow(); 00177 bool resized; 00178 bool generation; 00179 bool closed; 00180 GraphicsScene *scene; 00181 GraphicsView *view; 00182 QLabel *positionArea; 00183 QLabel *messageArea; 00184 QComboBox *setArea; 00185 QCheckBox *intelColo; 00186 QRadioButton *windowSizeArea; 00187 QRadioButton *userSizeArea; 00188 QSpinBox *widthArea; 00189 QSpinBox *heightArea; 00191 signals: 00195 void generationStateChanged(bool); 00196 00197 public slots: 00201 void generate(); 00205 void readyShowMandelbrot(); 00206 00207 private slots: 00208 void assignValue(int); 00209 void displayInfo(QString); 00210 void showMessage(bool); 00211 void sizeChanges(); 00212 void about(); 00213 void saveScene(); 00214 00215 private: 00216 int statsTab; 00217 void initWindow(); 00218 void createMenus(); 00219 void createDialog(); 00220 ToolsArea *toolsArea; 00221 Generator *generator; 00222 QSpinBox *nbIterationsArea; 00223 QDial *redArea; 00224 QDial *greenArea; 00225 QDial *blueArea; 00226 QLabel *redLabel; 00227 QLabel *greenLabel; 00228 QLabel *blueLabel; 00229 QLabel *stats; 00230 QLabel *setInfo; 00231 QProgressDialog *waitDialog; 00232 QPushButton *generateButton; 00233 QTabWidget *tabWidget; 00234 00235 protected: 00240 void closeEvent(QCloseEvent *); 00245 void resizeEvent(QResizeEvent *); 00250 void showEvent(QShowEvent *) 00251 { 00252 int x = QApplication::desktop()->rect().center().x() - width() / 2; 00253 int y = QApplication::desktop()->rect().center().y() - height() / 2; 00254 move(x, y); 00255 } 00256 }; 00257 00258 #endif