1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
#include "GeneratorWindow.hpp"
#include <iostream>
GeneratorWindow::GeneratorWindow (QWidget* parent, QApplication* app):QMainWindow (parent){
_app = app;
setupUi(this);
_gene = NULL;
_ui_name = qFindChild<QLineEdit*>(this, "fileNameEdit") ;
if (_ui_name == NULL)
fprintf (stderr, "Cannot find the name box in the .ui file") ;
_ui_depth = qFindChild<QLineEdit*>(this, "depthEdit") ;
if (_ui_depth == NULL)
fprintf (stderr, "Cannot find the depth box in the .ui file") ;
_ui_procNbr = qFindChild<QLineEdit*>(this, "procNumberEdit") ;
if (_ui_procNbr == NULL)
fprintf (stderr, "Cannot find the proc number box in the .ui file") ;
_ui_numberOfState = qFindChild<QLineEdit*>(this, "stateNumberEdit") ;
if (_ui_numberOfState == NULL)
fprintf (stderr, "Cannot find the number of state box in the .ui file");
_ui_linkNbr = qFindChild<QLineEdit*>(this, "linkEdit") ;
if (_ui_linkNbr == NULL)
fprintf (stderr, "Cannot find the link box in the .ui file") ;
_ui_counterNbr = qFindChild<QLineEdit*>(this, "counterEdit") ;
if (_ui_counterNbr == NULL)
fprintf (stderr, "Cannot find the counter box in the .ui file") ;
_ui_linkTypeNbr = qFindChild<QLineEdit*>(this, "linkType") ;
if (_ui_linkTypeNbr == NULL)
fprintf (stderr, "Cannot find the link type in the .ui file") ;
_ui_eventTypeNbr= qFindChild<QLineEdit*>(this, "eventType") ;
if (_ui_eventTypeNbr == NULL)
fprintf (stderr, "Cannot find the event type in the .ui file") ;
_ui_eventNbr = qFindChild<QLineEdit*>(this, "eventEdit") ;
if (_ui_eventNbr == NULL)
fprintf (stderr, "Cannot find the event box in the .ui file") ;
_ui_event = qFindChild<QCheckBox*>(this, "eventCheck") ;
if (_ui_event == NULL)
fprintf (stderr, "Cannot find the event checkbox in the .ui file") ;
_ui_counter = qFindChild<QCheckBox*>(this, "counterCheck") ;
if (_ui_counter == NULL)
fprintf (stderr, "Cannot find the counter checkbox in the .ui file") ;
_ui_link = qFindChild<QCheckBox*>(this, "linkCheck") ;
if (_ui_link == NULL)
fprintf (stderr, "Cannot find the link checkbox in the .ui file") ;
_ui_eventLabel = qFindChild<QLabel*>(this, "eventLabel") ;
if (_ui_event == NULL)
fprintf (stderr, "Cannot find the event label in the .ui file") ;
_ui_counterLabel = qFindChild<QLabel*>(this, "counterLabel") ;
if (_ui_counter == NULL)
fprintf (stderr, "Cannot find the counter label in the .ui file") ;
_ui_linkLabel = qFindChild<QLabel*>(this, "linkLabel") ;
if (_ui_link == NULL)
fprintf (stderr, "Cannot find the link label in the .ui file") ;
_ui_paje = qFindChild<QCheckBox*>(this, "paje") ;
if (_ui_paje == NULL)
fprintf (stderr, "Cannot find the paje checkbox in the .ui file") ;
_ui_tau = qFindChild<QCheckBox*>(this, "tau") ;
if (_ui_counter == NULL)
fprintf (stderr, "Cannot find the tau checkbox in the .ui file") ;
_ui_otf = qFindChild<QCheckBox*>(this, "otf") ;
if (_ui_link == NULL)
fprintf (stderr, "Cannot find the otf checkbox in the .ui file") ;
generateButton = qFindChild<QPushButton*>(this, "generateButton");
if (generateButton == NULL)
fprintf (stderr, "Cannot find the generate button in the .ui file");
resetButton = qFindChild<QPushButton*>(this, "resetButton");
if (resetButton == NULL)
fprintf (stderr, "Cannot find the reset button in the .ui file");
_ui_numberOfLine = qFindChild<QLineEdit*>(this, "lineNumberEdit") ;
if ( _ui_numberOfLine == NULL)
fprintf (stderr, "Cannot find the number of line in the .ui file");
// QMetaObject::connectSlotsByName (parent);
QObject::connect (generateButton, SIGNAL (clicked ()), this, SLOT (generateButton_clicked ()));
QObject::connect (resetButton, SIGNAL (clicked ()), this, SLOT (resetButton_clicked ()));
this->show ();
}
GeneratorWindow::~GeneratorWindow (){
}
void GeneratorWindow::generate (){
_gene->generate ();
}
void GeneratorWindow::setParam (){
QString nb;
_name = (_ui_name->text () == "")?NAME:_ui_name->text () ;
_depth = (_ui_depth->text () == "")?DEPTH:_ui_depth->text ().toInt () ;
_procNbr = (_ui_procNbr->text () == "")?PROCNBR:_ui_procNbr->text ().toInt () ;
_numberOfState = (_ui_numberOfState->text () == "")?NUMBEROFSTATE:_ui_numberOfState->text ().toInt ();
_numberOfLine = (_ui_numberOfLine->text () == "")?NUMBEROFLINE:_ui_numberOfLine->text ().toInt () ;
_paje = _ui_paje->isChecked ();
_otf = _ui_otf->isChecked ();
_tau = _ui_tau->isChecked ();
nb = _ui_counterNbr->text ();
if (_ui_counter->isChecked () && (nb != ""))
_counterNbr = (nb.toInt ()<_procNbr)?nb.toInt ():_procNbr;
else
_counterNbr = COUNTERNBR;
nb = _ui_linkNbr->text ();
if (_ui_link->isChecked () && (nb != "")){
_linkNbr = (nb.toInt ()<_procNbr)?nb.toInt ():_procNbr;
_linkTypeNbr = _ui_linkTypeNbr->text ().toInt ();
}
else{
_linkNbr = LINKNBR;
_linkTypeNbr = LINKTYPENBR;
}
nb = _ui_linkTypeNbr->text ();
if (_ui_link->isChecked () && (nb != ""))
_linkTypeNbr = nb.toInt ();
else
_linkTypeNbr = LINKTYPENBR;
nb = _ui_eventNbr->text ();
if (_ui_event->isChecked () && (nb != ""))
_eventNbr = (nb.toInt ()<_procNbr)?nb.toInt ():_procNbr;
else
_eventNbr = EVENTNBR;
nb = _ui_eventTypeNbr->text ();
if (_ui_event->isChecked () && (nb != ""))
_eventTypeNbr = nb.toInt ();
else
_eventTypeNbr = EVENTTYPENBR;
std::cout << " Valeurs rentrees : " << std::endl << " nom : " << _name.toStdString () << std::endl << " depth " << _depth << std::endl << " proc nbr " << _procNbr << std::endl << "nb of state " << _numberOfState << std::endl << "nbr line " << _numberOfLine << std::endl << "count nbr " << _counterNbr << std::endl << "event nbr " << _eventNbr << std::endl << "link nbr " << _linkNbr << std::endl << "event type nbr " << _eventTypeNbr << std::endl << "link type nbr " << _linkTypeNbr << std::endl;
if (_gene)
delete (_gene);
_gene = new Generator (_name,
_depth, _procNbr, _numberOfState, _numberOfLine,
_counterNbr, _eventNbr, _linkNbr,
_eventTypeNbr, _linkTypeNbr,
_paje, _otf, _tau);
}
void GeneratorWindow::hideCounter (){
_ui_counterLabel->hide ();
_ui_counterNbr->hide ();
}
void GeneratorWindow::hideLink (){
_ui_linkLabel->hide ();
_ui_linkNbr->hide ();
}
void GeneratorWindow::hideEvent (){
_ui_eventLabel->hide ();
_ui_eventNbr->hide ();
}
void GeneratorWindow::showCounter (){
_ui_counterLabel->show ();
_ui_counterNbr->show ();
}
void GeneratorWindow::showLink (){
_ui_linkLabel->show ();
_ui_linkNbr->show ();
}
void GeneratorWindow::showEvent (){
_ui_eventLabel->show ();
_ui_eventNbr->show ();
}
void GeneratorWindow::finishGeneration (){
cleanParam () ;
if (_gene)
delete _gene;
_gene = NULL;
}
void GeneratorWindow::cleanParam (){
// Class param
_name = NAME ;
_depth = DEPTH ;
_procNbr = PROCNBR ;
_numberOfLine = NUMBEROFLINE ;
_numberOfState = NUMBEROFSTATE;
_linkNbr = LINKNBR ;
_eventNbr = EVENTNBR ;
_counterNbr = COUNTERNBR ;
// UI edit param
_ui_name->setText ("");
_ui_depth->setText ("");
_ui_procNbr->setText ("");
_ui_numberOfLine->setText ("");
_ui_numberOfState->setText ("");
_ui_linkNbr->setText ("");
_ui_eventNbr->setText ("");
_ui_counterNbr->setText ("");
_ui_eventTypeNbr->setText ("");
// UI checkbox
_ui_link->setChecked (true);
_ui_event->setChecked (true);
_ui_counter->setChecked (true);
// Ensure fields are visible
showEvent ();
showLink ();
showCounter ();
}
void GeneratorWindow::resetButton_clicked (){
fprintf (stderr, "Reset ..... \n\n\n");
finishGeneration ();
}
void GeneratorWindow::generateButton_clicked (){
fprintf (stderr, "Generation ..... \n\n\n");
setParam ();
generate ();
cleanParam ();
}
int GeneratorWindow::run (){
return _app->exec ();
}
|