From 8b654919f230d71e6ae05f242a1cddd0f2a30af0 Mon Sep 17 00:00:00 2001 From: Vaclav Mares <maresva2@fit.cvut.cz> Date: Thu, 13 Apr 2017 13:58:08 +0200 Subject: [PATCH] Add ALIB functions - Single Initial state - Remove epsilon Incoming - Concatenate epsilon --- agui2/mainwindow.cpp | 28 +++++++++++++++++++++++----- agui2/mainwindow.h | 3 +++ agui2/mainwindow.ui | 6 +++--- agui2/wrapperfactory.cpp | 8 +++++++- agui2/wrapperfactory.h | 4 +++- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/agui2/mainwindow.cpp b/agui2/mainwindow.cpp index c4d18a4db4..4c06904bf1 100644 --- a/agui2/mainwindow.cpp +++ b/agui2/mainwindow.cpp @@ -11,6 +11,7 @@ #include "graphics/outputgraphicsbox.h" #include "graphics/dialogs/inputdialog.h" #include "wrapperfactory.h" +#include "connectionhelper.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -25,13 +26,8 @@ MainWindow::MainWindow(QWidget *parent) : WrapperBox * inputBox = WrapperFactory::create( WrapperFactory::INPUT, 0, 0 ); scene->addItem(inputBox->getGraphics()); - WrapperBox * inputBox2 = WrapperFactory::create( WrapperFactory::INPUT, 0, 50 ); - scene->addItem(inputBox2->getGraphics()); WrapperBox * outputBox = WrapperFactory::create( WrapperFactory::OUTPUT, 400, 0 ); scene->addItem(outputBox->getGraphics()); - WrapperBox * testBox = WrapperFactory::create( WrapperFactory::TEST, 200, 0 ); - scene->addItem(testBox->getGraphics()); - m_output = outputBox; } @@ -62,3 +58,25 @@ void MainWindow::on_CompactBtn_clicked() WrapperBox * box = WrapperFactory::create( WrapperFactory::COMPACT, 200, -50 ); scene->addItem(box->getGraphics()); } + +void MainWindow::on_SingleInitialBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::SINGLE_INITIAL, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_EpsilonRemoveBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::EPSILON_REMOVE_IN, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_ConcatenateBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::CONCATENATE_EPSILON, 200, 100 ); + scene->addItem(box->getGraphics()); + WrapperBox * inBox = WrapperFactory::create( WrapperFactory::INPUT, 0, 100 ); + scene->addItem(inBox->getGraphics()); + ConnectionHelper::getInstance().startConnection(inBox); + ConnectionHelper::getInstance().completeConnection(box); +} diff --git a/agui2/mainwindow.h b/agui2/mainwindow.h index 3bb50d1e10..50b5dcf005 100644 --- a/agui2/mainwindow.h +++ b/agui2/mainwindow.h @@ -27,6 +27,9 @@ private slots: void on_DeterminizeBtn_clicked(); void on_TotalBtn_clicked(); void on_CompactBtn_clicked(); + void on_SingleInitialBtn_clicked(); + void on_EpsilonRemoveBtn_clicked(); + void on_ConcatenateBtn_clicked(); private: Ui::MainWindow *ui; diff --git a/agui2/mainwindow.ui b/agui2/mainwindow.ui index 59c3eb4ed0..443b703e5d 100644 --- a/agui2/mainwindow.ui +++ b/agui2/mainwindow.ui @@ -44,7 +44,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QPushButton" name="pushButton_3"> + <widget class="QPushButton" name="EpsilonRemoveBtn"> <property name="text"> <string>Remove Epsilon</string> </property> @@ -65,7 +65,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_6"> + <widget class="QPushButton" name="SingleInitialBtn"> <property name="text"> <string>Single Initial State</string> </property> @@ -137,7 +137,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_15"> + <widget class="QPushButton" name="ConcatenateBtn"> <property name="text"> <string>Concatenate</string> </property> diff --git a/agui2/wrapperfactory.cpp b/agui2/wrapperfactory.cpp index 1ba31b96b7..a703e43de3 100644 --- a/agui2/wrapperfactory.cpp +++ b/agui2/wrapperfactory.cpp @@ -10,6 +10,8 @@ #include <automaton/determinize/Determinize.h> #include <automaton/simplify/Total.h> +#include <automaton/simplify/SingleInitialState.h> +#include <automaton/simplify/EpsilonRemoverIncoming.h> #include <automaton/transform/Compaction.h> #include <automaton/transform/AutomataConcatenationEpsilonTransition.h> @@ -27,7 +29,11 @@ WrapperBox *WrapperFactory::create(WrapperFactory::BoxActions action, qreal x = return new WrapperBox( new SingleModelBox( &automaton::simplify::Total::total ), new GraphicsBox( "Total", x, y ) ); case COMPACT: return new WrapperBox( new SingleModelBox( &automaton::transform::Compaction::convert ), new GraphicsBox( "Compact", x, y ) ); - case TEST: + case SINGLE_INITIAL: + return new WrapperBox( new SingleModelBox( &automaton::simplify::SingleInitialState::convert ), new GraphicsBox( "Single Initial", x, y ) ); + case EPSILON_REMOVE_IN: + return new WrapperBox( new SingleModelBox( &automaton::simplify::EpsilonRemoverIncoming::remove ), new GraphicsBox( "E-Rremove Incoming", x, y ) ); + case CONCATENATE_EPSILON: return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataConcatenationEpsilonTransition::concatenation ), new DoubleGraphicsBox( "E-Concat", x, y ) ); } } diff --git a/agui2/wrapperfactory.h b/agui2/wrapperfactory.h index 868959de5c..7eb3f5fd26 100644 --- a/agui2/wrapperfactory.h +++ b/agui2/wrapperfactory.h @@ -14,7 +14,9 @@ public: DETERMINIZE, TOTAL, COMPACT, - TEST, + SINGLE_INITIAL, + EPSILON_REMOVE_IN, + CONCATENATE_EPSILON, OUTPUT }; static WrapperBox* create( WrapperFactory::BoxActions action, qreal x, qreal y ); -- GitLab