{
setAutoFillBackground(true);
//buttons settings
settingButton->setText("settings");
settingButton->adjustSize();
oneStepButton->setText("one step");
oneStepButton->adjustSize();
runAllButton->setText("run all");
runAllButton->adjustSize();
//place the buttons in a proper position
settingButton->move(50, 10);
oneStepButton->move(50 + settingButton->width() + 5, 10);
runAllButton->move(60+settingButton->width()+oneStepButton->width(),10);
settingButton->show();
oneStepButton->show();
runAllButton->show();
//plotter settings
minX = 0.0;
maxX = 10.0;
numXTicks = 5;
minY = 0.0;
maxY = 10.0;
numYTicks = 5;
pMutation=0.8;
pXCross=0.15;
popSize=100;
generations=200;
iniPoints();
resize(600,400);
// signals and slots
connect(settingButton,SIGNAL(clicked()),this,SLOT(showSettings()));
connect(oneStepButton,SIGNAL(clicked()),this,SLOT(oneStep()));
connect(runAllButton,SIGNAL(clicked()),this,SLOT(runAll()));
//runAllButton->setEnabled(false); // It works if I post it here.
}
void GenePlotter::runAll()
{
settingButton->setEnabled(false);
oneStepButton->setEnabled(false);
runAllButton->setEnabled(false);
if(couter==0)
++couter;
while(couter<generations)
{
++couter;
execOnce();
}
settingButton->setEnabled(true);
oneStepButton->setEnabled(true);
runAllButton->setEnabled(true);
}
GenePlotter::GenePlotter(QWidget* parent):QDialog(parent)
{
setBackgroundRole(QPalette::Dark);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//buttons settings
settingButton=new QPushButton(this);
settingButton->setText("settings");
settingButton->adjustSize();
oneStepButton=new QPushButton(this);
oneStepButton->setText("one step");
oneStepButton->adjustSize();
runAllButton=new QPushButton(this);
runAllButton->setText("run all");
runAllButton->adjustSize();
//place the buttons in a proper position
settingButton->move(50, 10);
oneStepButton->move(50 + settingButton->width() + 5, 10);
runAllButton->move(60+settingButton->width()+oneStepButton->width(),10);
settingButton->show();
oneStepButton->show();
runAllButton->show();
//plotter settings
minX = 0.0;
maxX = 10.0;
numXTicks = 5;
minY = 0.0;
maxY = 10.0;
numYTicks = 5;
pMutation=0.8;
pXCross=0.15;
popSize=100;
generations=200;
iniPoints();
resize(600,400);
// signals and slots
connect(settingButton,SIGNAL(clicked()),this,SLOT(showSettings()));
connect(oneStepButton,SIGNAL(clicked()),this,SLOT(oneStep()));
connect(runAllButton,SIGNAL(clicked()),this,SLOT(runAll()));
//runAllButton->setEnabled(false); // It works if I post it here.
}
void GenePlotter::runAll()
{
settingButton->setEnabled(false);
oneStepButton->setEnabled(false);
runAllButton->setEnabled(false);
if(couter==0)
++couter;
while(couter<generations)
{
++couter;
execOnce();
}
settingButton->setEnabled(true);
oneStepButton->setEnabled(true);
runAllButton->setEnabled(true);
}
To copy to clipboard, switch view to plain text mode
Bookmarks