Commit 5e9886ab authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

[yavgui] Add and enable transition properties dialog.

Transition label modification is not implemented yet.

* yavgui/src/Makefile.am: Add new files.
* yavgui/src/dialog_properties_transition.cc,
* yavgui/src/dialog_properties_transition.hh: New.
* yavgui/src/g_scene.cc,
* yavgui/src/g_scene.hh,
* yavgui/src/g_transition.cc,
* yavgui/src/g_transition.hh,
* yavgui/src/g_vcsn_handler.cc,
* yavgui/src/g_vcsn_handler.hh: Add signal/slots/connections.
* yavgui/src/g_vcsn_handler_internal.hh,
* yavgui/src/g_vcsn_handler_internal.hxx: Add temporary implementation.
parent 2536d43c
2009-08-06 d-halluin <d-halluin@lrde.epita.fr>
[yavgui] Add and enable transition properties dialog.
Transition label modification is not implemented yet.
* yavgui/src/Makefile.am: Add new files.
* yavgui/src/dialog_properties_transition.cc,
* yavgui/src/dialog_properties_transition.hh: New.
* yavgui/src/g_scene.cc,
* yavgui/src/g_scene.hh,
* yavgui/src/g_transition.cc,
* yavgui/src/g_transition.hh,
* yavgui/src/g_vcsn_handler.cc,
* yavgui/src/g_vcsn_handler.hh: Add signal/slots/connections.
* yavgui/src/g_vcsn_handler_internal.hh,
* yavgui/src/g_vcsn_handler_internal.hxx: Add temporary implementation.
2009-08-06 d-halluin <d-halluin@lrde.epita.fr>
 
[yavgui] Add a help dialog.
......
......@@ -33,6 +33,8 @@ COMMON_SOURCES = main.cc \
dialog_get_layout.moc.cc \
dialog_properties_state.cc \
dialog_properties_state.moc.cc \
dialog_properties_transition.cc \
dialog_properties_transition.moc.cc \
g_view.cc \
g_view.moc.cc \
g_scene.cc \
......
// dialog_properties_transition.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_properties_transition.cc
* @author Florent D'Halluin <d-halluin@lrde.epita.fr>
*
*
*/
#include "dialog_properties_transition.hh"
namespace gui
{
namespace dialogs
{
DialogPropertiesTransition::DialogPropertiesTransition
(GTransition* transition)
: transition_ (transition),
input_ (new QLineEdit (transition->label ()))
{
QPushButton *closeButton = new QPushButton(tr("Ok"));
connect(closeButton, SIGNAL(clicked()), this, SLOT(done()));
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch(1);
buttonsLayout->addWidget(closeButton);
QLabel* input_label = new QLabel("Label:");
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(input_label);
mainLayout->addWidget(input_);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
setWindowTitle(tr("Transition properties"));
}
void DialogPropertiesTransition::done ()
{
if (transition_)
{
transition_->set_label(input_->text());
transition_->refresh ();
}
emit close ();
}
} // ! namespace dialogs
} // ! namespace gui
// dialog_properties_transition.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_properties_transition.hh
* @author Florent D'Halluin <d-halluin@lrde.epita.fr>
*
*
*/
#ifndef DIALOG_PROPERTIES_TRANSITION_HH_
# define DIALOG_PROPERTIES_TRANSITION_HH_
# include <QtGui>
# include "common.hh"
# include "g_common.hh"
# include "g_transition.hh"
using namespace gui::display;
namespace gui
{
namespace dialogs
{
class DialogPropertiesTransition : public QDialog
{
Q_OBJECT
public:
DialogPropertiesTransition(GTransition* transition);
public slots:
void done ();
private:
GTransition* transition_;
QLineEdit* input_;
};
} // ! namespace dialogs
} // ! namespace gui
#endif /* !DIALOG_PROPERTIES_TRANSITION_HH_ */
......@@ -64,6 +64,8 @@ namespace gui
{
connect(transition, SIGNAL(delTransition()),
this, SLOT(delTransition()));
connect(transition, SIGNAL(setTransitionLabel(QString)),
this, SLOT(setTransitionLabel(QString)));
connect(transition, SIGNAL(selected()),
this, SLOT(itemSelected()));
connect(transition, SIGNAL(deselected()),
......@@ -94,6 +96,12 @@ namespace gui
emit delTransition(dynamic_cast<GTransition*>(sender()));
}
void
GScene::setTransitionLabel(QString label)
{
emit setTransitionLabel(dynamic_cast<GTransition*>(sender()), label);
}
void
GScene::itemSelected()
{
......
......@@ -52,6 +52,7 @@ namespace gui
void delTransition();
void setInitial(QString entry);
void setFinal(QString entry);
void setTransitionLabel(QString label);
// Used to ignore right click events.
void itemSelected();
......@@ -65,6 +66,7 @@ namespace gui
void setInitial(GState* state, QString entry);
void setFinal(GState* state, QString entry);
void delTransition(GTransition* transition);
void setTransitionLabel(GTransition* transition, QString label);
private:
bool item_selected_;
......
......@@ -25,6 +25,8 @@
#include "g_transition.hh"
#include "common.hh"
#include "dialog_properties_transition.hh"
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
......@@ -362,6 +364,13 @@ namespace gui
event->ignore();
return;
}
if (event->button () == Qt::LeftButton)
{
event->accept();
dialogs::DialogPropertiesTransition dlg(this);
dlg.exec();
return;
}
if (event->button () == Qt::RightButton)
{
event->accept();
......@@ -409,6 +418,24 @@ namespace gui
emit deselected ();
}
QString
GTransition::label() const
{
return label_;
}
void
GTransition::set_label(QString label)
{
emit setTransitionLabel(label);
}
void
GTransition::set_label_value(QString label)
{
label_ = label;
}
void
GTransition::refresh_hook_from (QPointF, QPointF)
{
......
......@@ -62,6 +62,13 @@ namespace gui
// Return vcsn_index.
int index() const;
// Return the transition label;
QString label() const;
// Set the transition label in the vcsn_automaton.
void set_label(QString label);
// Set the transition label (called by set_label()).
void set_label_value(QString label);
public slots:
// Refresh both hook points, the label point and the curve quad point.
void refresh ();
......@@ -76,6 +83,7 @@ namespace gui
void deselected ();
void delTransition();
void setTransitionLabel(QString label);
private:
......
......@@ -90,6 +90,18 @@ namespace gui
boost::apply_visitor (op, **(info_.automaton));
}
void
GVcsnHandler::setTransitionLabel(GTransition* transition, QString label)
{
if (! *(info_.automaton))
throw exceptions::NoAutomatonStructure ();
if (!transition)
throw exceptions::NullParameter ();
SetTransitionLabel op(info_, transition, label);
boost::apply_visitor (op, **(info_.automaton));
}
GVcsnHandler::GVcsnHandler (GScene* scene,
GView* view,
automaton_variant** automaton)
......@@ -107,6 +119,8 @@ namespace gui
this, SLOT(setFinal(GState*, QString)));
connect(scene, SIGNAL(delTransition(GTransition*)),
this, SLOT(delTransition(GTransition*)));
connect(scene, SIGNAL(setTransitionLabel(GTransition*, QString)),
this, SLOT(setTransitionLabel(GTransition*, QString)));
}
GVcsnHandler::~GVcsnHandler ()
......
......@@ -66,6 +66,8 @@ namespace gui
void delState(GState* state);
void delTransition(GTransition* transition);
void setTransitionLabel(GTransition* transition, QString label);
void setInitial(GState* state, QString entry);
void setFinal(GState* state, QString entry);
......
......@@ -84,6 +84,20 @@ namespace gui
GTransition* transition;
};
struct SetTransitionLabel: public boost::static_visitor<>
{
SetTransitionLabel(SceneInfo& info,
GTransition* transition,
QString label);
template<typename Automaton>
void operator()(Automaton& automaton);
SceneInfo& info;
GTransition* transition;
QString label;
};
struct SetInitial: public boost::static_visitor<>
{
SetInitial(SceneInfo& info,
......
......@@ -97,6 +97,25 @@ namespace gui
transition = 0;
}
SetTransitionLabel::SetTransitionLabel(SceneInfo& i,
GTransition* t,
QString l)
: info(i),
transition(t),
label(l)
{
}
template<typename Automaton>
void
SetTransitionLabel::operator()(Automaton&)
{
AUTOMATON_TYPES(Automaton)
// FIXME: implement this.
throw exceptions::IncompatibleType();
}
SetInitial::SetInitial(SceneInfo& i, GState* s, QString e)
: info(i),
state(s),
......
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