@@ -66,6 +66,7 @@ void MainWindow::entry_connected()
6666 ui->portBox ->setEnabled (false );
6767 ui->resetButton ->setEnabled (false );
6868 ui->connectButton ->setText (" Disconnect" );
69+ ui->sendButton ->setEnabled (false );
6970 if (!ui->fileTextEdit ->toPlainText ().isEmpty ()) ui->sendFileButton ->setEnabled (true );
7071 statusBar ()->showMessage (tr (" Successfully connected to bot!" ),4000 );
7172}
@@ -157,11 +158,13 @@ void MainWindow::entry_idle()
157158 qDebug ()<< " entry_idle" << endl;
158159 ui->fileSendProgressBar ->setValue (0 );
159160 ui->sendFileButton ->setText (" Send File" );
161+ ui->saveFileButton ->setText (" Save File" );
160162 ui->loadFileButton ->setText (" Load File" );
161163
162164 ui->controllBox ->setEnabled (true );
163165 ui->restartButton ->setEnabled (false );
164166 ui->loadFileButton ->setEnabled (true );
167+ ui->saveFileButton ->setEnabled (false );
165168 ui->fileSendProgressBar ->setEnabled (false );
166169
167170 bot->send (" M 18" ); // disable motors
@@ -183,14 +186,22 @@ void MainWindow::entry_ask_for_restart()
183186 qDebug ()<< " entry_ask_for_restart" << endl;
184187 statusBar ()->showMessage (tr (" File successfully sent" ));
185188 SetBotToHomePosition ();
186- if (restartLayerMsgBox->exec () == QMessageBox::Ok) // workaround cause the signals don´t fire
187- emit restartLayerMsgBox->accept ();
189+ int result = restartLayerMsgBox->exec ();
190+ if (result == QMessageBox::Ok)
191+ {
192+ emit restart_print ();
193+ qDebug ()<< " emit restart_print" << endl;
194+ }
188195 else
189- emit restartLayerMsgBox->reject ();
196+ {
197+ emit abort_print ();
198+ qDebug ()<< " emit abort_print" << endl;
199+ }
190200}
191201
192202void MainWindow::entry_ask_for_next_layer ()
193203{
204+ qDebug ()<<" entry_ask_for_next_layer" << endl;
194205 qDebug ()<< " entry_ask_for_next_layer" << endl;
195206 if (layerNames.size () > 1 ) layerIndex++;
196207
@@ -201,12 +212,23 @@ void MainWindow::entry_ask_for_next_layer()
201212 {
202213 nextLayerMsgBox->setText (" Please change the tool for layer: " + layerNames[layerIndex]);
203214 SetBotToHomePosition ();
204- nextLayerMsgBox->exec ();
215+ int result = nextLayerMsgBox->exec ();
216+ if (result == QMessageBox::Ok)
217+ {
218+ emit print_next_layer ();
219+ qDebug ()<< " emit print_next_layer" << endl;
220+ }
221+ else
222+ {
223+ emit abort_print ();
224+ qDebug ()<< " emit abort_print" << endl;
225+ }
205226 }
206227}
207228
208229void MainWindow::entry_load_file_dialog ()
209230{
231+ qDebug ()<<" entry_load_file_dialog" << endl;
210232 QString fileName;
211233 if (!curDir.absolutePath ().isEmpty ())
212234 {
@@ -264,11 +286,20 @@ void MainWindow::initSateMachine()
264286 //
265287 start_sending->addTransition (start_sending,SIGNAL (entered ()),sending);
266288
267- ask_for_restart->addTransition (restartLayerMsgBox,SIGNAL (accepted ()),restart);
268- ask_for_restart->addTransition (restartLayerMsgBox,SIGNAL (rejected ()),idle);
269- connect (ask_for_restart,SIGNAL (exited ()),this ,SLOT (hey ()));
289+ idle->addTransition (restartLayerMsgBox,SIGNAL (accepted ()),restart);
290+ idle->addTransition (restartLayerMsgBox,SIGNAL (rejected ()),idle);
291+
292+ idle->addTransition (this ,SIGNAL (restart_print ()),restart);
293+ ask_for_restart->addTransition (this ,SIGNAL (restart_print ()),restart);
294+ ask_for_restart->addTransition (this ,SIGNAL (abort_restart_print ()),abort);
295+ idle->addTransition (this ,SIGNAL (abort_restart_print ()),abort);
270296
271- ask_for_next_layer->addTransition (nextLayerMsgBox,SIGNAL (accepted ()),sending);
297+ idle->addTransition (this ,SIGNAL (print_next_layer ()),sending);
298+ ask_for_next_layer->addTransition (this ,SIGNAL (print_next_layer ()),sending);
299+ idle->addTransition (this ,SIGNAL (abort_print ()),abort);
300+ ask_for_next_layer->addTransition (this ,SIGNAL (abort_print ()),abort);
301+ // idle->addTransition(nextLayerMsgBox,SIGNAL(accepted()),sending);
302+ // idle->addTransition(nextLayerMsgBox,SIGNAL(rejected()),abort);
272303
273304 load_file_dialog->addTransition (load_file_dialog,SIGNAL (entered ()),idle);
274305
@@ -308,14 +339,17 @@ void MainWindow::initUI()
308339 nextLayerMsgBox = new QMessageBox (QMessageBox::Information,
309340 " Next Layer" ,
310341 " The Layer has been finished!\n please insert the tool for the layer: " + QString::number (layerIndex),
311- QMessageBox::Ok|QMessageBox::No);
312- nextLayerMsgBox->setButtonText (QMessageBox::Ok," OK" );
313- nextLayerMsgBox->setButtonText (QMessageBox::No," Abort" );
342+ QMessageBox::Ok|QMessageBox::Abort);
343+
344+ // nextLayerMsgBox->addButton("OK",QMessageBox::AcceptRole);
345+ // nextLayerMsgBox->addButton("Abort",QMessageBox::RejectRole);
314346
315347 restartLayerMsgBox = new QMessageBox (QMessageBox::Information,
316348 " Restart?" ,
317349 " Do you want to restart the print?" ,
318- QMessageBox::Ok|QMessageBox::No);
350+ QMessageBox::Ok|QMessageBox::Abort);
351+ // restartLayerMsgBox->addButton("OK",QMessageBox::RejectRole); //for some reason rejectrole and acceptrole need to be switched
352+ // restartLayerMsgBox->addButton("Abort",QMessageBox::AcceptRole);
319353
320354 connect (ui->undoButton ,SIGNAL (clicked ()),ui->fileTextEdit ,SLOT (undo ()));
321355 connect (ui->redoButton ,SIGNAL (clicked ()),ui->fileTextEdit ,SLOT (redo ()));
@@ -599,7 +633,7 @@ void MainWindow::on_sendString_editingFinished()
599633 }
600634}
601635
602- void MainWindow::on_sendButton_clicked ()
636+ void MainWindow::on_sendButton_released ()
603637{
604638 on_sendString_editingFinished ();
605639 ui->sendString ->setText (" " );
0 commit comments