Skip to content

Commit 2c16d25

Browse files
author
navrkald
committed
To begin/end functionality.
Repaired correct status when show correct colution and then check solution.
1 parent f91566e commit 2c16d25

File tree

10 files changed

+71
-13
lines changed

10 files changed

+71
-13
lines changed

RegularConvertor/algorithms/algorithmwidget.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ AlgorithmWidget::AlgorithmWidget(Algorithm::modes _mode, QWidget *parent) :
1414
connect(this->ui->playButton,SIGNAL(clicked()),this,SLOT(emitPlay()));
1515
connect(this->ui->stopButton,SIGNAL(clicked()),this,SIGNAL(stopPressed()));
1616
connect(this->ui->checkButton,SIGNAL(clicked()),this,SIGNAL(checkSolutionPressed()));
17+
connect(this->ui->beginButton,SIGNAL(clicked()), this, SIGNAl(beginPressed()));
18+
connect(this->ui->endButton,SIGNAL(clicked()),this, SIGNAL(endPressed()));
1719
setWidgets(mode);
1820
}
1921

@@ -48,12 +50,12 @@ void AlgorithmWidget::setWidgets(Algorithm::modes mode)
4850
showWidgets(QList<QWidget*>() << ui->checkButton << ui->showButton);
4951
showSpacer(ui->checkSpacer);
5052
hideWidgets(QList<QWidget*>()
51-
<< ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label
53+
<< ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label << ui->beginButton << ui->endButton
5254
<< ui->prew_stepButton << ui->next_stepButton );
5355
hideSpacer(ui->stepSpacer);
5456
break;
5557
case Algorithm::PLAY_MODE:
56-
showWidgets(QList<QWidget*>() << ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label);
58+
showWidgets(QList<QWidget*>() << ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label << ui->beginButton << ui->endButton);
5759
hideWidgets(QList<QWidget*>()
5860
<< ui->checkButton << ui->showButton
5961
<< ui->prew_stepButton << ui->next_stepButton );
@@ -64,7 +66,7 @@ void AlgorithmWidget::setWidgets(Algorithm::modes mode)
6466
showWidgets(QList<QWidget*>()<< ui->prew_stepButton << ui->next_stepButton);
6567
hideWidgets(QList<QWidget*>()
6668
<< ui->checkButton << ui->showButton
67-
<< ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label);
69+
<< ui->prewButton << ui->nextButton << ui->playButton << ui->stopButton << ui->spinBox << ui->delay_label << ui->beginButton << ui->endButton);
6870
showSpacer(ui->stepSpacer);
6971
hideSpacer(ui->checkSpacer);
7072
break;

RegularConvertor/algorithms/algorithmwidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class AlgorithmWidget : public QWidget
3838
void checkSolutionPressed();
3939
void showCorrectSolutionPressed();
4040
void showUserSolutionPressed();
41-
41+
void beginPressed();
42+
void endPressed();
4243

4344
public slots:
4445
void emitPlay();

RegularConvertor/algorithms/algorithmwidget.ui

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
<layout class="QVBoxLayout" name="verticalLayout">
3131
<item>
3232
<layout class="QHBoxLayout" name="horizontalLayout">
33+
<item>
34+
<widget class="QToolButton" name="beginButton">
35+
<property name="text">
36+
<string>begin</string>
37+
</property>
38+
</widget>
39+
</item>
3340
<item>
3441
<widget class="QToolButton" name="prewButton">
3542
<property name="text">
@@ -58,6 +65,13 @@
5865
</property>
5966
</widget>
6067
</item>
68+
<item>
69+
<widget class="QToolButton" name="endButton">
70+
<property name="text">
71+
<string>end</string>
72+
</property>
73+
</widget>
74+
</item>
6175
<item>
6276
<widget class="QLabel" name="delay_label">
6377
<property name="text">

RegularConvertor/algorithms/fatodfa.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ FaToDFA::FaToDFA(modes _mode, AlgorithmWidget* _algorithm_widget, FA_widget* _no
6262
connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution()));
6363
connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution()));
6464
connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution()));
65-
65+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin()));
66+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toEnd()));
6667

6768
//
6869
// Connect timers.
@@ -397,14 +398,23 @@ void FaToDFA::checkSolution()
397398

398399
void FaToDFA::showCorrectSolution()
399400
{
400-
disconnect(dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setDFA(FiniteAutomata*)));
401+
backup_FA = DFA;
401402
dfa_widget->setFA(new FiniteAutomata(correct_FA));
402403
}
403404

404405
void FaToDFA::showUserSolution()
405406
{
406-
dfa_widget->setFA(new FiniteAutomata(DFA));
407-
connect(dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setDFA(FiniteAutomata*)));
407+
dfa_widget->setFA(new FiniteAutomata(backup_FA));
408+
}
409+
410+
void FaToDFA::toBegin()
411+
{
412+
not_dfa_widget->setFA(FA);
413+
}
414+
415+
void FaToDFA::toEnd()
416+
{
417+
runAlgorithm(0);
408418
}
409419

410420
void FaToDFA::removeFuture()

RegularConvertor/algorithms/fatodfa.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public slots:
3838
void checkSolution();
3939
void showCorrectSolution();
4040
void showUserSolution();
41+
void toBegin();
42+
void toEnd();
4143

4244
private:
4345

@@ -61,7 +63,7 @@ public slots:
6163
} steps;
6264

6365
QList<steps> history;
64-
66+
FiniteAutomata backup_FA;
6567
FiniteAutomata correct_FA;
6668
modes mode;
6769
AlgorithmWidget* algorithm_widget;

RegularConvertor/algorithms/regexptofa.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ RegExpToFA::RegExpToFA(AlgorithmWidget* _algorithm_widget, modes _mode, RegExpWi
8383
connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution()));
8484
connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution()));
8585
connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution()));
86+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin()));
87+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toEnd()));
8688

8789
//
8890
// Connect timers.
@@ -444,6 +446,17 @@ void RegExpToFA::setExample(RegExp *_re)
444446
setMode(CHECK_MODE);
445447
}
446448

449+
void RegExpToFA::toBegin()
450+
{
451+
re_widget->setRegExp(re);
452+
re_widget->modelChanged();
453+
}
454+
455+
void RegExpToFA::toEnd()
456+
{
457+
runAlgorithm(0);
458+
}
459+
447460

448461

449462

RegularConvertor/algorithms/regexptofa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public slots:
4949
void showCorrectSolution();
5050
void showUserSolution();
5151
void setExample(RegExp* _re);
52+
void toBegin();
53+
void toEnd();
5254

5355
private:
5456
AlgorithmWidget* algorithm_widget;

RegularConvertor/algorithms/removeepsilon.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ RemoveEpsilon::RemoveEpsilon(modes _mode, AlgorithmWidget* _algorithm_widget, FA
7070
connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution()));
7171
connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution()));
7272
connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution()));
73-
73+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin()));
74+
connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toEnd()));
7475

7576
//
7677
// Connect timers.
@@ -568,14 +569,23 @@ void RemoveEpsilon::showVariables()
568569

569570
void RemoveEpsilon::showCorrectSolution()
570571
{
571-
disconnect(not_epsilon_fa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(set_not_epsilonFA(FiniteAutomata*)));
572+
backup_FA = non_epsilon_FA;
572573
not_epsilon_fa_widget->setFA(new FiniteAutomata(correct_FA));
573574
}
574575

575576
void RemoveEpsilon::showUserSolution()
576577
{
577-
not_epsilon_fa_widget->setFA(new FiniteAutomata(non_epsilon_FA));
578-
connect(not_epsilon_fa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(set_not_epsilonFA(FiniteAutomata*)));
578+
not_epsilon_fa_widget->setFA(new FiniteAutomata(backup_FA));
579+
}
580+
581+
void RemoveEpsilon::toBegin()
582+
{
583+
epsilon_fa_widget->setFA(new FiniteAutomata(FA));
584+
}
585+
586+
void RemoveEpsilon::toEnd()
587+
{
588+
runAlgorithm(0);
579589
}
580590

581591
void RemoveEpsilon::checkSolution()

RegularConvertor/algorithms/removeepsilon.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ public slots:
5757
void checkSolution();
5858
void showCorrectSolution();
5959
void showUserSolution();
60+
void toBegin();
61+
void toEnd();
62+
6063
private:
6164
FiniteAutomata correct_FA;
65+
FiniteAutomata backup_FA;
6266
AlgorithmWidget* algorithm_widget;
6367
modes mode;
6468
FA_widget* epsilon_fa_widget;
1.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)