Commit ab19754d authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

[yavgui] Ask for alphabet during automaton creation.

* yavgui/src/Makefile.am: Add new files.
* yavgui/src/creators.hh: Do that.
* yavgui/src/dialog_get_alphabet.cc,
* yavgui/src/dialog_get_alphabet.hh: New.  Input dialog box.
parent 4a062d11
2009-08-09 d-halluin <d-halluin@lrde.epita.fr>
[yavgui] Ask for alphabet during automaton creation.
* yavgui/src/Makefile.am: Add new files.
* yavgui/src/creators.hh: Do that.
* yavgui/src/dialog_get_alphabet.cc,
* yavgui/src/dialog_get_alphabet.hh: New. Input dialog box.
2009-08-06 d-halluin <d-halluin@lrde.epita.fr>
 
[yavgui] Add command "product".
......
......@@ -29,6 +29,8 @@ COMMON_SOURCES = main.cc \
dialog_get_instance.moc.cc \
dialog_get_label.cc \
dialog_get_label.moc.cc \
dialog_get_alphabet.cc \
dialog_get_alphabet.moc.cc \
dialog_get_automaton_type.cc \
dialog_get_automaton_type.moc.cc \
dialog_get_layout.cc \
......
......@@ -29,6 +29,7 @@
# include "common.hh"
# include "vcsn_automaton_variant.hh"
# include "dialog_get_alphabet.hh"
# define UPDATE_VARIANT(Automaton) \
if (!(*variant)) \
......@@ -36,6 +37,16 @@
else \
**variant = Automaton
# define GET_ALPHABET(Type, Alphabet, Title) \
Type Alphabet; \
{ \
QString str; \
dialogs::DialogGetAlphabet dlg(Title, &str); \
dlg.exec(); \
for (int i = 0; i < str.size(); ++i) \
Alphabet.insert(str[i].toAscii()); \
}
namespace gui
{
namespace vcsn_internal
......@@ -54,22 +65,36 @@ namespace gui
switch (type)
{
case B:
UPDATE_VARIANT(boolean_automaton::make_automaton
(boolean_automaton::alphabet_t ()));
{
GET_ALPHABET(boolean_automaton::alphabet_t, a,
QObject::tr("Alphabet"));
UPDATE_VARIANT(boolean_automaton::make_automaton(a));
}
break;
case Z:
UPDATE_VARIANT(z_automaton::make_automaton
(z_automaton::alphabet_t ()));
{
GET_ALPHABET(z_automaton::alphabet_t, a,
QObject::tr("Alphabet"));
UPDATE_VARIANT(z_automaton::make_automaton(a));
}
break;
case FMP:
UPDATE_VARIANT(fmp_transducer::make_automaton
(fmp_transducer::first_alphabet_t (),
fmp_transducer::second_alphabet_t ()));
{
GET_ALPHABET(fmp_transducer::first_alphabet_t, a,
QObject::tr("First alphabet"));
GET_ALPHABET(fmp_transducer::second_alphabet_t, b,
QObject::tr("Second alphabet"));
UPDATE_VARIANT(fmp_transducer::make_automaton(a, b));
}
break;
case RW:
UPDATE_VARIANT(boolean_transducer::make_automaton
(boolean_transducer::alphabet_t (),
boolean_transducer::alphabet_t ()));
{
GET_ALPHABET(boolean_transducer::alphabet_t, a,
QObject::tr("First alphabet"));
GET_ALPHABET(boolean_transducer::alphabet_t, b,
QObject::tr("Secont alphabet"));
UPDATE_VARIANT(boolean_transducer::make_automaton(a, b));
}
break;
default:
throw exceptions::CantCreateAutomaton ();
......@@ -77,6 +102,7 @@ namespace gui
}
private:
Creator ()
{}
};
......
// dialog_get_alphabet.cc: this file is part of Vaucanson.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
/**
* @file dialog_get_alphabet.cc
* @author Florent D'Halluin <d-halluin@lrde.epita.fr>
*
*
*/
#include "dialog_get_alphabet.hh"
namespace gui
{
namespace dialogs
{
DialogGetAlphabet::DialogGetAlphabet(QString title, QString* str)
: str_ (str),
input_ (new QLineEdit ())
{
QPushButton *closeButton = new QPushButton(tr("Ok"));
connect(closeButton, SIGNAL(clicked()), this, SLOT(done()));
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch(1);
buttonsLayout->addWidget(closeButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(input_);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
setWindowTitle(title);
}
void DialogGetAlphabet::done ()
{
if (str_)
*str_ = input_->text();
emit close ();
}
} // ! namespace dialogs
} // ! namespace gui
// dialog_get_alphabet.hh: this file is part of Vaucanson.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
/**
* @file dialog_get_alphabet.hh
* @author Florent D'Halluin <d-halluin@lrde.epita.fr>
*
*
*/
#ifndef DIALOG_GET_ALPHABET_HH_
# define DIALOG_GET_ALPHABET_HH_
# include <QtGui>
# include "common.hh"
# include "g_common.hh"
namespace gui
{
namespace dialogs
{
class DialogGetAlphabet : public QDialog
{
Q_OBJECT
public:
DialogGetAlphabet (QString title, QString* str);
public slots:
void done ();
private:
QString* str_;
QLineEdit* input_;
};
} // ! namespace dialogs
} // ! namespace gui
#endif /* !DIALOG_GET_ALPHABET_HH_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment