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

[yavgui] Add temporary setTransition implementation.

Only for boolean_automaton and z_automaton.
To be rewritten.

* yavgui/src/g_vcsn_handler_internal.hh,
* yavgui/src/g_vcsn_handler_internal.hxx: Do that.
parent 5e9886ab
2009-08-06 d-halluin <d-halluin@lrde.epita.fr>
[yavgui] Add temporary setTransition implementation.
Only for boolean_automaton and z_automaton.
To be rewritten.
* yavgui/src/g_vcsn_handler_internal.hh,
* yavgui/src/g_vcsn_handler_internal.hxx: Do that.
2009-08-06 d-halluin <d-halluin@lrde.epita.fr> 2009-08-06 d-halluin <d-halluin@lrde.epita.fr>
   
[yavgui] Add and enable transition properties dialog. [yavgui] Add and enable transition properties dialog.
......
...@@ -90,6 +90,9 @@ namespace gui ...@@ -90,6 +90,9 @@ namespace gui
GTransition* transition, GTransition* transition,
QString label); QString label);
void operator()(vcsn::boolean_automaton::automaton_t& automaton);
void operator()(vcsn::z_automaton::automaton_t& automaton);
template<typename Automaton> template<typename Automaton>
void operator()(Automaton& automaton); void operator()(Automaton& automaton);
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
# include "exceptions.hh" # include "exceptions.hh"
# include "g_vcsn_handler_internal.hh" # include "g_vcsn_handler_internal.hh"
# include <QMessageBox>
# include <cmath> # include <cmath>
# include <sstream> # include <sstream>
...@@ -106,6 +108,86 @@ namespace gui ...@@ -106,6 +108,86 @@ namespace gui
{ {
} }
void
SetTransitionLabel::operator()
(vcsn::boolean_automaton::automaton_t& automaton)
{
// FIXME: This whole implementation is bogus and wrong but seems
// to give basic results. Rewrite.
using namespace vcsn::boolean_automaton;
typedef Element<series_set_t, label_t> label_elt_t;
// FIXME: Unsafe cast?
htransition_t i = (htransition_t) transition->index();
label_elt_t lbl(automaton.series());
// Magic.
std::pair<bool, std::string> r =
algebra::parse(label.toStdString(), lbl);
label_t lbv = lbl.value();
// algebra::parse() gives seemingly wrong result (e.g. 1+a+b
// when parsing "a+b"). This is an ugly workaround.
// Setting an epsilon+letter label (eg. 1+a) is made impossible.
if (lbv.size() > 1)
lbv.erase(lbv.begin());
// Magic ends here.
automaton.update(i, lbv);
if (r.first)
QMessageBox::warning(0, "Set transition label", r.second.c_str());
std::stringstream str;
str << automaton.series_of(i);
transition->set_label_value(str.str().c_str());
transition->update();
}
void
SetTransitionLabel::operator()
(vcsn::z_automaton::automaton_t& automaton)
{
// FIXME: This whole implementation is bogus and wrong but seems
// to give basic results. Rewrite.
using namespace vcsn::z_automaton;
typedef Element<series_set_t, label_t> label_elt_t;
// FIXME: Unsafe cast?
htransition_t i = (htransition_t) transition->index();
label_elt_t lbl(automaton.series());
// Magic.
std::pair<bool, std::string> r =
algebra::parse(label.toStdString(), lbl);
label_t lbv = lbl.value();
// algebra::parse() gives seemingly wrong result (e.g. 1+a+b
// when parsing "a+b"). This is an ugly workaround.
// Setting an epsilon+letter label (eg. 1+a) is made impossible.
if (lbv.size() > 1)
lbv.erase(lbv.begin());
// Magic ends here.
automaton.update(i, lbv);
if (r.first)
QMessageBox::warning(0, "Set transition label", r.second.c_str());
std::stringstream str;
str << automaton.series_of(i);
transition->set_label_value(str.str().c_str());
transition->update();
}
template<typename Automaton> template<typename Automaton>
void void
SetTransitionLabel::operator()(Automaton&) SetTransitionLabel::operator()(Automaton&)
...@@ -113,7 +195,9 @@ namespace gui ...@@ -113,7 +195,9 @@ namespace gui
AUTOMATON_TYPES(Automaton) AUTOMATON_TYPES(Automaton)
// FIXME: implement this. // FIXME: implement this.
throw exceptions::IncompatibleType(); QMessageBox::warning(0, "Set transition label",
"Cannot set the transition label of this kind "
"of automaton.");
} }
SetInitial::SetInitial(SceneInfo& i, GState* s, QString e) SetInitial::SetInitial(SceneInfo& i, GState* s, QString e)
......
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