#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) :{
this -> setStyleSheet("background-color: rgb(35, 5, 5);");
unsigned short pos = 0; //help variable for use vector of QLabels and vector of spin boxes
this -> setWindowTitle("Fractal Generator v. 1.0");
grid->setSpacing(5);
for(int j=0; j<3; j++){ //columns
ptrSpinBox -> setFixedSize(60,20);
ptrSpinBox ->setRange(0, 255); //r,g,b value [0;255]
vctrSpinBoxes.push_back(ptrSpinBox);
ptrSpinBox = NULL; //creating spin box and saving into vector
if(j%3 == 0) //first spin box is R, second one is G third one is B
ptrQLabelRGB
= new QLabel("R");
else if(j%3 == 1)
ptrQLabelRGB
= new QLabel("G");
else if(j%3 == 2)
ptrQLabelRGB
= new QLabel("B");
ptrQLabelRGB ->setFixedSize(10,20);
vctrLabels.push_back(ptrQLabelRGB);
ptrQLabelRGB = NULL; //creating comment R,G,B of spin box and saving into vector
grid -> addWidget(vctrLabels[pos], 5,2*j);
grid -> addWidget(vctrSpinBoxes[pos], 5, 2*j+1);
pos++;
}
grid -> addItem(spacer,5,6);
ptrFractalWindow = new JuliaSet();
grid -> addWidget(ptrFractalWindow, 0, 0,5,20);
for(int j=7; j<10; j++){ //columns
ptrSpinBox -> setFixedSize(60,20);
ptrSpinBox ->setRange(0, 255); //r,g,b value [0;255]
vctrSpinBoxes.push_back(ptrSpinBox);
ptrSpinBox = NULL; //creating spin box and saving into vector
if(j%3 == 1) //first spin box is R, second one is G third one is B
ptrQLabelRGB
= new QLabel("R");
else if(j%3 == 2)
ptrQLabelRGB
= new QLabel("G");
else if(j%3 == 0)
ptrQLabelRGB
= new QLabel("B");
ptrQLabelRGB ->setFixedSize(10,20);
vctrLabels.push_back(ptrQLabelRGB);
ptrQLabelRGB = NULL; //creating comment R,G,B of spin box and saving into vector
grid -> addWidget(vctrLabels[pos], 5,2*j);
grid -> addWidget(vctrSpinBoxes[pos], 5, 2*j+1);
pos++;
}
ptrFractalColor
= new QLabel("Fractal Color");
ptrFractalColor -> setFixedSize(120,20);
ptrBackgroundColor
= new QLabel("Background Color");
ptrBackgroundColor -> setFixedSize(120,20);
grid -> addWidget(ptrFractalColor, 7,2,1,3);
grid -> addWidget(ptrBackgroundColor, 7,16,1,3);
generateButton -> setFixedSize(120,50);
grid -> addWidget(generateButton, 8,6,2,5);
realSlider
= new QSlider(Qt
::Horizontal,
0);
imagSlider
= new QSlider(Qt
::Horizontal,
0);
grid -> addWidget(realSlider, 9,2,1,3);
grid -> addWidget(imagSlider, 9,16,1,3);
ptrRealPartC
= new QLabel("Real(c)");
ptrImagPartC
= new QLabel("Imag(c)");
grid -> addWidget(ptrRealPartC, 10,3,1,3);
grid -> addWidget(ptrImagPartC, 10,17,1,3);
}
//*************************************************************************
MainWindow::~MainWindow()
{
for(unsigned short i=0; i<vctrSpinBoxes.size(); i++){ //deleting pointers
delete vctrSpinBoxes[i];
}
for(unsigned short i=0; i<vctrLabels.size(); i++){ //deleting pointers
delete vctrLabels[i];
}
delete ptrFractalColor;
delete ptrBackgroundColor;
delete grid;
}