diff --git a/agui2/mainwindow.cpp b/agui2/mainwindow.cpp index 5a117f03cdc0f2216b28ecc414fca473ddd7a3ca..96ef43d4a2242af1ede46dc4bf6b0ee0192a6704 100644 --- a/agui2/mainwindow.cpp +++ b/agui2/mainwindow.cpp @@ -63,12 +63,118 @@ void MainWindow::on_SingleInitialBtn_clicked() } void MainWindow::on_EpsilonRemoveBtn_clicked() +{ + QMenu menu; + QAction * a; + a = menu.addAction("&Incoming"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_EpsilonRemoveIncoming())); + a = menu.addAction("&Outgoing"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_EpsilonRemoveOutgoing())); + QPoint point = ui->EpsilonRemoveBtn->mapToGlobal( ui->EpsilonRemoveBtn->rect().topRight() ); + menu.exec( point ); +} + +void MainWindow::on_MinimizeBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::MINIMIZE, 200, 100 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_NormilizeBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::NORMALIZE, 200, 100 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_EpsilonRemoveIncoming() { WrapperBox * box = WrapperFactory::create( WrapperFactory::EPSILON_REMOVE_IN, 200, 30 ); scene->addItem(box->getGraphics()); } +void MainWindow::on_EpsilonRemoveOutgoing() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::EPSILON_REMOVE_OUT, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_RenameBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::RENAME, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_TrimBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::TRIM, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_RemoveUselessBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::REMOVE_USELES, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_RemoveUnreachableBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::REMOVE_UNREACHABLE, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_ReverseBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::REVERSE, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_IterateBtn_clicked() +{ + QMenu menu; + QAction * a; + a = menu.addAction("&Without epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_Iterate())); + a = menu.addAction("&Epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_IterateEpsilon())); + QPoint point = ui->IterateBtn->mapToGlobal( ui->IterateBtn->rect().topRight() ); + menu.exec( point ); +} + +void MainWindow::on_Iterate() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::ITERATE, 200, 30 ); + scene->addItem(box->getGraphics()); +} + +void MainWindow::on_IterateEpsilon() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::ITERATE_EPSILON, 200, 30 ); + scene->addItem(box->getGraphics()); +} + void MainWindow::on_ConcatenateBtn_clicked() +{ + QMenu menu; + QAction * a; + a = menu.addAction("&Without epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_Concatenate())); + a = menu.addAction("&Epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_ConcatenateEpsilon())); + QPoint point = ui->ConcatenateBtn->mapToGlobal( ui->ConcatenateBtn->rect().topRight() ); + menu.exec( point ); +} + +void MainWindow::on_Concatenate() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::CONCATENATE, 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); +} + +void MainWindow::on_ConcatenateEpsilon() { WrapperBox * box = WrapperFactory::create( WrapperFactory::CONCATENATE_EPSILON, 200, 100 ); scene->addItem(box->getGraphics()); @@ -78,14 +184,46 @@ void MainWindow::on_ConcatenateBtn_clicked() ConnectionHelper::getInstance().completeConnection(box); } -void MainWindow::on_MinimizeBtn_clicked() +void MainWindow::on_UnionBtn_clicked() { - WrapperBox * box = WrapperFactory::create( WrapperFactory::MINIMIZE, 200, 100 ); + QMenu menu; + QAction * a; + a = menu.addAction("&Without epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_Union())); + a = menu.addAction("&Epsilon transitions"); + QObject::connect(a,SIGNAL(triggered()), this, SLOT(on_UnionEpsilon())); + QPoint point = ui->UnionBtn->mapToGlobal( ui->UnionBtn->rect().topRight() ); + menu.exec( point ); +} + +void MainWindow::on_Union() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::UNION, 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); } -void MainWindow::on_NormilizeBtn_clicked() +void MainWindow::on_UnionEpsilon() { - WrapperBox * box = WrapperFactory::create( WrapperFactory::NORMALIZE, 200, 100 ); + WrapperBox * box = WrapperFactory::create( WrapperFactory::UNION_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); +} + + + +void MainWindow::on_IntersectBtn_clicked() +{ + WrapperBox * box = WrapperFactory::create( WrapperFactory::INTERSCT, 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 c49de022a3c200bbbc34aba181e377ec82db1913..a67032792305a0714d99a599894cb2ab51a46af6 100644 --- a/agui2/mainwindow.h +++ b/agui2/mainwindow.h @@ -32,6 +32,24 @@ private slots: void on_ConcatenateBtn_clicked(); void on_MinimizeBtn_clicked(); void on_NormilizeBtn_clicked(); + void on_RenameBtn_clicked(); + void on_TrimBtn_clicked(); + void on_RemoveUselessBtn_clicked(); + void on_RemoveUnreachableBtn_clicked(); + void on_ReverseBtn_clicked(); + void on_IterateBtn_clicked(); + void on_UnionBtn_clicked(); + + void on_EpsilonRemoveIncoming(); + void on_EpsilonRemoveOutgoing(); + void on_Iterate(); + void on_IterateEpsilon(); + void on_Concatenate(); + void on_ConcatenateEpsilon(); + void on_Union(); + void on_UnionEpsilon(); + + void on_IntersectBtn_clicked(); private: Ui::MainWindow *ui; diff --git a/agui2/mainwindow.ui b/agui2/mainwindow.ui index 3f2b90c40c5f16b473c81b3c99064bc844f63ed7..cf1b5e7639215184bc53a1bae7647c1c833067c3 100644 --- a/agui2/mainwindow.ui +++ b/agui2/mainwindow.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>987</width> - <height>587</height> + <height>615</height> </rect> </property> <property name="sizePolicy"> @@ -58,7 +58,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_5"> + <widget class="QPushButton" name="RenameBtn"> <property name="text"> <string>Rename</string> </property> @@ -86,21 +86,21 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_8"> + <widget class="QPushButton" name="TrimBtn"> <property name="text"> <string>Trim</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_9"> + <widget class="QPushButton" name="RemoveUselessBtn"> <property name="text"> <string>Remove Useless</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_10"> + <widget class="QPushButton" name="RemoveUnreachableBtn"> <property name="text"> <string>Remove Unreachable</string> </property> @@ -116,7 +116,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <widget class="QPushButton" name="pushButton_11"> + <widget class="QPushButton" name="ReverseBtn"> <property name="text"> <string>Reverse</string> </property> @@ -130,14 +130,14 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_13"> + <widget class="QPushButton" name="IterateBtn"> <property name="text"> <string>Iterate</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_14"> + <widget class="QPushButton" name="UnionBtn"> <property name="text"> <string>Union</string> </property> @@ -151,7 +151,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_16"> + <widget class="QPushButton" name="IntersectBtn"> <property name="text"> <string>Intersect</string> </property> diff --git a/agui2/wrapperfactory.cpp b/agui2/wrapperfactory.cpp index 6f0e5fddf8bc49e3519937ae4250b29c8d63bd3e..cc82d6e8022666f353923b7196cdf241016135bf 100644 --- a/agui2/wrapperfactory.cpp +++ b/agui2/wrapperfactory.cpp @@ -8,23 +8,43 @@ #include "models/singlemodelbox.h" #include "models/doublemodelbox.h" +#include <QChar> +#include <QString> + #include <automaton/determinize/Determinize.h> #include <automaton/simplify/Total.h> #include <automaton/simplify/SingleInitialState.h> #include <automaton/simplify/EpsilonRemoverIncoming.h> +#include <automaton/simplify/EpsilonRemoverOutgoing.h> #include <automaton/simplify/Minimize.h> #include <automaton/simplify/Normalize.h> +#include <automaton/simplify/Rename.h> +#include <automaton/simplify/Trim.h> +#include <automaton/simplify/UselessStatesRemover.h> +#include <automaton/simplify/UnreachableStatesRemover.h> #include <automaton/transform/Compaction.h> +#include <automaton/transform/Reverse.h> +#include <automaton/transform/AutomatonIteration.h> +#include <automaton/transform/AutomatonIterationEpsilonTransition.h> +#include <automaton/transform/AutomataConcatenation.h> #include <automaton/transform/AutomataConcatenationEpsilonTransition.h> +#include <automaton/transform/AutomataUnionCartesianProduct.h> +#include <automaton/transform/AutomataUnionEpsilonTransition.h> +#include <automaton/transform/AutomataIntersectionCartesianProduct.h> WrapperBox *WrapperFactory::create(WrapperFactory::BoxActions action, qreal x = 0, qreal y = 0) { + QString str( QChar(0xb5, 0x03) ); + switch( action ) { + // Special case INPUT: return new WrapperBox( new InputModelBox(), new InputGraphicsBox( x, y ) ); case OUTPUT: return new WrapperBox( new OutputModelBox(), new OutputGraphicsBox( x, y ) ); + + // Single simplify case DETERMINIZE: return new WrapperBox( new SingleModelBox( &automaton::determinize::Determinize::determinize ), new DeterminizeGraphicsBox( x, y ) ); case TOTAL: @@ -33,13 +53,43 @@ WrapperBox *WrapperFactory::create(WrapperFactory::BoxActions action, qreal x = return new WrapperBox( new SingleModelBox( &automaton::simplify::Minimize::minimize ), new GraphicsBox( "Minimize", x, y ) ); case NORMALIZE: return new WrapperBox( new SingleModelBox( &automaton::simplify::Normalize::normalize ), new GraphicsBox( "Normalize", x, y ) ); - case COMPACT: - return new WrapperBox( new SingleModelBox( &automaton::transform::Compaction::convert ), new GraphicsBox( "Compact", x, y ) ); 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 ) ); + return new WrapperBox( new SingleModelBox( &automaton::simplify::EpsilonRemoverIncoming::remove ), new GraphicsBox( str.append( "-Remove In" ), x, y ) ); + case EPSILON_REMOVE_OUT: + return new WrapperBox( new SingleModelBox( &automaton::simplify::EpsilonRemoverOutgoing::remove ), new GraphicsBox( str.append( "-Remove Out" ), x, y ) ); + case RENAME: + return new WrapperBox( new SingleModelBox( &automaton::simplify::Rename::rename ), new GraphicsBox( "Rename", x, y ) ); + case TRIM: + return new WrapperBox( new SingleModelBox( &automaton::simplify::Trim::trim ), new GraphicsBox( "Trim", x, y ) ); + case REMOVE_USELES: + return new WrapperBox( new SingleModelBox( &automaton::simplify::UselessStatesRemover::remove ), new GraphicsBox( "Remove Useless", x, y ) ); + case REMOVE_UNREACHABLE: + return new WrapperBox( new SingleModelBox( &automaton::simplify::UnreachableStatesRemover::remove ), new GraphicsBox( "Remove Unreachable", x, y ) ); + + // Single transform + case COMPACT: + return new WrapperBox( new SingleModelBox( &automaton::transform::Compaction::convert ), new GraphicsBox( "Compact", x, y ) ); + case REVERSE: + return new WrapperBox( new SingleModelBox( &automaton::transform::Reverse::convert ), new GraphicsBox( "Reverse", x, y ) ); + case ITERATE: + return new WrapperBox( new SingleModelBox( &automaton::transform::AutomatonIteration::iteration ), new GraphicsBox( "Iterate", x, y ) ); + case ITERATE_EPSILON: + return new WrapperBox( new SingleModelBox( &automaton::transform::AutomatonIterationEpsilonTransition::iteration ), new GraphicsBox( str.append( "-Iterate" ), x, y ) ); + + //Double + case CONCATENATE: + return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataConcatenation::concatenation ), new DoubleGraphicsBox( "Concatenate", x, y ) ); case CONCATENATE_EPSILON: - return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataConcatenationEpsilonTransition::concatenation ), new DoubleGraphicsBox( "E-Concat", x, y ) ); + return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataConcatenationEpsilonTransition::concatenation ), new DoubleGraphicsBox( str.append( "-Concatenate" ), x, y ) ); + case UNION: + return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataUnionCartesianProduct::unification ), new DoubleGraphicsBox( "Union", x, y ) ); + case UNION_EPSILON: + return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataUnionEpsilonTransition::unification ), new DoubleGraphicsBox( str.append( "-Union" ), x, y ) ); + case INTERSCT: + return new WrapperBox( new DoubleModelBox( &automaton::transform::AutomataIntersectionCartesianProduct::intersection ), new DoubleGraphicsBox( "Intersect", x, y ) ); + default: + return NULL; } } diff --git a/agui2/wrapperfactory.h b/agui2/wrapperfactory.h index 320540e6b9e59e1ff42dfbcee6e3245be4b5a0c5..51eb9ad52f7354d7874018b5c3bccd27c47b17b6 100644 --- a/agui2/wrapperfactory.h +++ b/agui2/wrapperfactory.h @@ -16,10 +16,22 @@ public: COMPACT, SINGLE_INITIAL, EPSILON_REMOVE_IN, + EPSILON_REMOVE_OUT, + CONCATENATE, CONCATENATE_EPSILON, MINIMIZE, NORMALIZE, - OUTPUT + OUTPUT, + RENAME, + TRIM, + REMOVE_USELES, + REMOVE_UNREACHABLE, + INTERSCT, + UNION, + UNION_EPSILON, + REVERSE, + ITERATE, + ITERATE_EPSILON }; static WrapperBox* create( WrapperFactory::BoxActions action, qreal x, qreal y ); };