[Jderobot-admin] jderobot-r1133 - in trunk/src/stable/components/visualHFSM: . gui popups

bmenendez en jderobot.org bmenendez en jderobot.org
Sab Dic 28 19:42:04 CET 2013


Author: bmenendez
Date: 2013-12-28 19:42:04 +0100 (Sat, 28 Dec 2013)
New Revision: 1133

Added:
   trunk/src/stable/components/visualHFSM/gui/edittransitioncode.glade
   trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.cpp
   trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.h
Modified:
   trunk/src/stable/components/visualHFSM/CMakeLists.txt
   trunk/src/stable/components/visualHFSM/generate.cpp
   trunk/src/stable/components/visualHFSM/guisubautomata.cpp
   trunk/src/stable/components/visualHFSM/guisubautomata.h
   trunk/src/stable/components/visualHFSM/guitransition.cpp
   trunk/src/stable/components/visualHFSM/guitransition.h
   trunk/src/stable/components/visualHFSM/savefile.cpp
   trunk/src/stable/components/visualHFSM/transition.cpp
   trunk/src/stable/components/visualHFSM/transition.h
   trunk/src/stable/components/visualHFSM/visualhfsm.cpp
   trunk/src/stable/components/visualHFSM/visualhfsm.h
   trunk/src/stable/components/visualHFSM/xmlparser.cpp
   trunk/src/stable/components/visualHFSM/xmlparser.h
Log:
A?\195?\177adida la posibilidad de poner c?\195?\179digo en las transiciones.


Modified: trunk/src/stable/components/visualHFSM/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/visualHFSM/CMakeLists.txt	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/CMakeLists.txt	2013-12-28 18:42:04 UTC (rev 1133)
@@ -13,6 +13,7 @@
 	popups/configfiledialog.cpp
 	popups/editnodedialog.cpp
 	popups/edittransitiondialog.cpp
+        popups/edittransitioncodedialog.cpp
 	popups/funvardialog.cpp
 	popups/librariesdialog.cpp
 	popups/loadfiledialog.cpp

Modified: trunk/src/stable/components/visualHFSM/generate.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/generate.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/generate.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -217,7 +217,7 @@
 							(nodeListIterator != nodeList.end()) )
 						nodeListIterator++;
 
-					float ms = atof(transListIterator->getCode().c_str());
+					float ms = atof(transListIterator->getCodeTrans().c_str());
 					this->fs << mapTab[T_ONE] << "t_" << nodeListIterator->getName() << "_max = " << (ms/1000.0) << ";" << std::endl;
 
 					mapNameTime[nodeListIterator->getName()] = ms/1000.0;
@@ -281,7 +281,7 @@
 				if (transListIterator->getIdOrigin() == idNode) {
 					int idDestiny = transListIterator->getIdDestiny();
 					if (transListIterator->getType().compare("condition") == 0) {
-						this->fs << "\t\t\t\tif (" << transListIterator->getCode().c_str() << ") {" << std::endl;
+						this->fs << "\t\t\t\tif (" << transListIterator->getCodeTrans().c_str() << ") {" << std::endl;
 						this->fs << "\t\t\t\t\tsub_" << id << " = " << subListIterator->getNodeName(idDestiny) << ";" << std::endl;
 						this->fs << "\t\t\t\t}" << std::endl;
 					} else {
@@ -292,12 +292,16 @@
 						this->fs << "\t\t\t\t\tt_fin = time(NULL);" << std::endl;
 						this->fs << "\t\t\t\t\tsecs = difftime(t_fin, t_ini);" << std::endl;
 						if (id == 1) {
-							float ms = atof(transListIterator->getCode().c_str());
+							float ms = atof(transListIterator->getCodeTrans().c_str());
 							this->fs << "\t\t\t\t\tif (secs > (double) " << (ms / 1000.0) << ") {" << std::endl;
 						} else
 							this->fs << "\t\t\t\t\tif (secs > (double) t_" << subListIterator->getNodeName(idNode) << "_max) {" << std::endl;
 						this->fs << "\t\t\t\t\t\tsub_" << id << " = " << subListIterator->getNodeName(idDestiny) << ";" << std::endl;
 						this->fs << "\t\t\t\t\t\tt_activated = false;" << std::endl;
+						std::istringstream f(transListIterator->getCode());
+						std::string line;
+						while (std::getline(f, line))
+							this->fs << "\t\t\t\t\t\t" << line << std::endl;
 						if (id != 1)
 							this->fs << "\t\t\t\t\t\tt_" << subListIterator->getNodeName(idNode) << "_max = " << mapNameTime[subListIterator->getNodeName(idNode)] << ";" << std::endl;
 						this->fs << "\t\t\t\t\t}" << std::endl;

Added: trunk/src/stable/components/visualHFSM/gui/edittransitioncode.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/edittransitioncode.glade	                        (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/edittransitioncode.glade	2013-12-28 18:42:04 UTC (rev 1133)
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="dialog_code">
+    <property name="width_request">640</property>
+    <property name="height_request">480</property>
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button_cancel">
+                <property name="label" translatable="yes">Cancel</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button_accept">
+                <property name="label" translatable="yes">Accept</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="frame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTextView" id="textview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="frame_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">&lt;b&gt;State code&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">button_cancel</action-widget>
+      <action-widget response="0">button_accept</action-widget>
+    </action-widgets>
+  </object>
+</interface>

Modified: trunk/src/stable/components/visualHFSM/guisubautomata.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -597,6 +597,12 @@
     nodeTransIterator->changeText(name);
 }
 
+void GuiSubautomata::setCodeLastGuiTransition ( std::string code ) {
+    std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+    nodeTransIterator--;
+    nodeTransIterator->setCode(code);
+}
+
 void GuiSubautomata::setTransGuiTransition ( Glib::RefPtr<Goocanvas::Item> item, std::string type, std::string code ) {
     std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
     while ( (!nodeTransIterator->hasThisItem(item)) &&
@@ -694,6 +700,21 @@
     }
 }
 
+void GuiSubautomata::editGuiTransitionCode ( Glib::RefPtr<Goocanvas::Item> item ) {
+    std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+    while ( (!nodeTransIterator->hasThisItem(item)) &&
+            (nodeTransIterator != this->transitionList.end()) )
+        nodeTransIterator++;
+
+    if (nodeTransIterator != this->transitionList.end()) {
+        if (DEBUG)
+            std::cout << BEGIN_GREEN << GUISUB << "Editing transition" << END_COLOR << std::endl;
+
+        EditTransitionCodeDialog* etcdialog = new EditTransitionCodeDialog(&*nodeTransIterator);
+        etcdialog->init();
+    }
+}
+
 // Move the transitions of the item (all its items)
 void GuiSubautomata::moveGuiTransition ( const Glib::RefPtr<Goocanvas::Item>& item ) {
     std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();

Modified: trunk/src/stable/components/visualHFSM/guisubautomata.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.h	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -30,6 +30,7 @@
 #include "guitransition.h"
 #include "popups/editnodedialog.h"
 #include "popups/edittransitiondialog.h"
+#include "popups/edittransitioncodedialog.h"
 #include "popups/renamedialog.h"
 #include "popups/renametransitiondialog.h"
 
@@ -127,6 +128,7 @@
 							  	 Glib::RefPtr<Goocanvas::Item> itemFinal,
 							  	 Glib::RefPtr<Goocanvas::Item> itemText );
 	void setNameLastGuiTransition ( std::string name );
+	void setCodeLastGuiTransition ( std::string code );
 	void setTransGuiTransition ( Glib::RefPtr<Goocanvas::Item> item, std::string type, std::string code );
 	void setTransLastGuiTransition ( std::string type, std::string code );
 
@@ -142,6 +144,7 @@
 	// Another functions for transitions
 	void changeGuiTransitionWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width );
 	void editGuiTransition ( Glib::RefPtr<Goocanvas::Item> item );
+	void editGuiTransitionCode ( Glib::RefPtr<Goocanvas::Item> item );
 	void moveGuiTransition ( const Glib::RefPtr<Goocanvas::Item>& item );
 	void moveJustGuiTransition ( const Glib::RefPtr<Goocanvas::Item>& item, float dx, float dy );
 	void renameGuiTransition ( Glib::RefPtr<Goocanvas::Item> item );

Modified: trunk/src/stable/components/visualHFSM/guitransition.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guitransition.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/guitransition.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -27,7 +27,7 @@
 GuiTransition::GuiTransition ( Transition t, Point p )
 : transition(*(new Transition(t.getId(), t.getIdOrigin(), t.getIdDestiny())))
 , point(*(new Point(p.getX(), p.getY()))) {
-	this->transition.setTrans(t.getType(), t.getCode());
+	this->transition.setTrans(t.getType(), t.getCodeTrans());
 	this->transition.setName(t.getName());
 }
 
@@ -166,6 +166,10 @@
 	this->transition.setIdDestiny(idDestiny);
 }
 
+void GuiTransition::setCode ( std::string code ) {
+	this->transition.setCode(code);
+}
+
 void GuiTransition::setTrans ( std::string type, std::string code ) {
 	this->transition.setTrans(type, code);
 }
@@ -236,10 +240,14 @@
 	return this->transition.getIdDestiny ();
 }
 
-std::string GuiTransition::getCodeTrans () {
+std::string GuiTransition::getCode () {
 	return this->transition.getCode();
 }
 
+std::string GuiTransition::getCodeTrans () {
+	return this->transition.getCodeTrans();
+}
+
 std::string GuiTransition::getName () {
 	return this->transition.getName();
 }

Modified: trunk/src/stable/components/visualHFSM/guitransition.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guitransition.h	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/guitransition.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -50,6 +50,7 @@
 					Glib::RefPtr<Goocanvas::Item> itemFinal,
 					Glib::RefPtr<Goocanvas::Item> itemText );
 	void setIds ( int idOrigin, int idDestiny );
+	void setCode ( std::string code );
 	void setTrans ( std::string type, std::string code );
 
 	// Getters
@@ -72,6 +73,7 @@
 	int getId ();
 	int getIdOrigin ();
 	int getIdDestiny ();
+	std::string getCode ();
 	std::string getCodeTrans ();
 	std::string getName ();
 	std::string getTypeTrans ();

Added: trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.cpp	                        (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -0,0 +1,85 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  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.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez Moreno <b.menendez.moreno en gmail.com>
+ *            José María Cañas Plaza <jmplaza en gsyc.es>
+ *
+ */
+
+#include "edittransitioncodedialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+EditTransitionCodeDialog::EditTransitionCodeDialog ( GuiTransition* gtransition ) {
+    this->gtransition = gtransition;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+EditTransitionCodeDialog::~EditTransitionCodeDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void EditTransitionCodeDialog::init () {
+    bool fine = true;
+	// Load the GtkBuilder file and instantiate its widgets:
+    Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
+    try {
+        refBuilder->add_from_file("gui/edittransitioncode.glade");
+    } catch (const Glib::FileError& ex) {
+        std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl;
+        fine = false;
+    } catch(const Glib::MarkupError& ex) {
+        std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl;
+        fine = false;
+    } catch(const Gtk::BuilderError& ex) {
+        std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl;
+        fine = false;
+    }
+
+    if (fine) {
+        refBuilder->get_widget("dialog_code", this->dialog);
+        refBuilder->get_widget("button_accept", this->button_accept);
+        refBuilder->get_widget("button_cancel", this->button_cancel);
+        refBuilder->get_widget("textview", this->textview);
+
+        Glib::RefPtr<Gtk::TextBuffer> textbuffer = Gtk::TextBuffer::create();
+        textbuffer->set_text(this->gtransition->getCode());
+        this->textview->set_buffer(textbuffer);
+
+        this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+                                        &EditTransitionCodeDialog::on_button_accept));
+        this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+                                        &EditTransitionCodeDialog::on_button_cancel));
+
+        this->dialog->show_now();
+    }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void EditTransitionCodeDialog::on_button_accept () {
+    this->gtransition->setCode(this->textview->get_buffer()->get_text());
+	delete this->dialog;
+}
+
+void EditTransitionCodeDialog::on_button_cancel () {
+    delete this->dialog;
+}
\ No newline at end of file

Added: trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.h	                        (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/edittransitioncodedialog.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  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.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Authors : Borja Menéndez Moreno <b.menendez.moreno en gmail.com>
+ *            José María Cañas Plaza <jmplaza en gsyc.es>
+ *
+ */
+
+#ifndef EDITTRANSITIONCODEDIALOG_H
+#define EDITTRANSITIONCODEDIALOG_H
+
+#include <string>
+#include <iostream>
+
+#include <gtkmm-3.0/gtkmm.h>
+
+#include "../guitransition.h"
+
+// Definition of this class
+class EditTransitionCodeDialog {
+public:
+	// Constructor
+	EditTransitionCodeDialog ( GuiTransition* gtransition );
+
+	// Destructor
+	virtual ~EditTransitionCodeDialog ();
+	
+	// Popup initializer
+	void init ();
+
+private:
+	// Data structure
+	GuiTransition* gtransition;
+	Gtk::Dialog* dialog;
+	Gtk::Button* button_accept;
+	Gtk::Button* button_cancel;
+
+	Gtk::TextView* textview;
+	
+	// Private methods
+	void on_button_accept ();
+	void on_button_cancel ();
+};
+
+#endif // EDITTRANSITIONCODEDIALOG_H
\ No newline at end of file

Modified: trunk/src/stable/components/visualHFSM/savefile.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/savefile.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/savefile.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -128,6 +128,9 @@
 				nodeTransChild = nodeTransition->add_child("destiny");
 				nodeTransChild->set_child_text(ss.str());
 
+				nodeTransChild = nodeTransition->add_child("transcode");
+				nodeTransChild->set_child_text(guiTransIterator->getCode());
+
 				nodeTransChild = nodeTransition->add_child("name");
 				nodeTransChild->set_child_text(guiTransIterator->getName());
 

Modified: trunk/src/stable/components/visualHFSM/transition.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/transition.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/transition.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -56,13 +56,17 @@
 	this->idDestiny = idDestiny;
 }
 
+void Transition::setCode ( std::string code ) {
+	this->code = code;
+}
+
 void Transition::setName ( std::string name ) {
 	this->name = name;
 }
 
-void Transition::setTrans ( std::string type, std::string code ) {
+void Transition::setTrans ( std::string type, std::string codeTrans ) {
 	this->type = type;
-	this->code = code;
+	this->codeTrans = codeTrans;
 }
 
 /*************************************************************
@@ -84,6 +88,10 @@
 	return this->code;
 }
 
+std::string Transition::getCodeTrans () {
+	return this->codeTrans;
+}
+
 std::string Transition::getName () {
 	return this->name;
 }
@@ -100,7 +108,8 @@
 	newtransition.setIdOrigin(this->idOrigin);
 	newtransition.setIdDestiny(this->idDestiny);
 	newtransition.setName(this->name);
-	newtransition.setTrans(this->type, this->code);
+	newtransition.setCode(this->code);
+	newtransition.setTrans(this->type, this->codeTrans);
 
 	return newtransition;
 }
@@ -110,7 +119,8 @@
 	newtransition.setIdOrigin(this->idOrigin);
 	newtransition.setIdDestiny(this->idDestiny);
 	newtransition.setName(this->name);
-	newtransition.setTrans(this->type, this->code);
+	newtransition.setCode(this->code);
+	newtransition.setTrans(this->type, this->codeTrans);
 
 	return newtransition;
 }
\ No newline at end of file

Modified: trunk/src/stable/components/visualHFSM/transition.h
===================================================================
--- trunk/src/stable/components/visualHFSM/transition.h	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/transition.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -40,6 +40,7 @@
 	void setId ( int id );
 	void setIdOrigin ( int idOrigin );
 	void setIdDestiny ( int idDestiny );
+	void setCode ( std::string code );
 	void setName ( std::string name );
 	void setTrans ( std::string type, std::string code );
 
@@ -48,6 +49,7 @@
 	int getIdOrigin ();
 	int getIdDestiny ();
 	std::string getCode ();
+	std::string getCodeTrans ();
 	std::string getName ();
 	std::string getType ();
 
@@ -57,7 +59,7 @@
 private:
 	// Data structure
 	int id, idOrigin, idDestiny;
-	std::string type, code, name;
+	std::string type, code, codeTrans, name;
 }; // Class Transition
 
 #endif
\ No newline at end of file

Modified: trunk/src/stable/components/visualHFSM/visualhfsm.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -231,6 +231,8 @@
                         sigc::mem_fun(this, &VisualHFSM::on_menu_transition_rename));
     this->actionGroupTransition->add(Gtk::Action::create("ContextEdit", "Edit"),
                         sigc::mem_fun(this, &VisualHFSM::on_menu_transition_edit));
+    this->actionGroupTransition->add(Gtk::Action::create("ContextCode", "Code"),
+                        sigc::mem_fun(this, &VisualHFSM::on_menu_transition_code));
     this->actionGroupTransition->add(Gtk::Action::create("ContextRemove", "Remove"),
                         sigc::mem_fun(this, &VisualHFSM::on_menu_transition_remove));
 
@@ -242,6 +244,7 @@
         "   <popup name='PopupMenuTransition'>"
         "       <menuitem action='ContextRename'/>"
         "       <menuitem action='ContextEdit'/>"
+        "       <menuitem action='ContextCode'/>"
         "       <menuitem action='ContextRemove'/>"
         "  </popup>"
         "</ui>";
@@ -452,6 +455,11 @@
     this->currentSubautomata->editGuiTransition(this->selectedItem);
 }
 
+// Edit the code of the selected transition
+void VisualHFSM::on_menu_transition_code () {
+    this->currentSubautomata->editGuiTransitionCode(this->selectedItem);
+}
+
 // Remove the selected transition
 void VisualHFSM::on_menu_transition_remove () {
     if (DEBUG)
@@ -1248,8 +1256,9 @@
             this->theOtherItem = this->currentSubautomata->getGuiNodeItem(idDestiny);
 
             this->create_new_transition(*porigin, *pdestiny, *ptransition, idTransition);
-            this->currentSubautomata->setTransLastGuiTransition(transListIterator->getType(), transListIterator->getCode());
+            this->currentSubautomata->setTransLastGuiTransition(transListIterator->getType(), transListIterator->getCodeTrans());
             this->currentSubautomata->setNameLastGuiTransition(transListIterator->getName());
+            this->currentSubautomata->setCodeLastGuiTransition(transListIterator->getCode());
             this->state = NONE;
             
             transListIterator++;

Modified: trunk/src/stable/components/visualHFSM/visualhfsm.h
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.h	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -185,6 +185,7 @@
     // Of the menus
     void on_menu_transition_rename ();
     void on_menu_transition_edit ();
+    void on_menu_transition_code ();
     void on_menu_transition_remove ();
 
     void on_menu_state_rename ();

Modified: trunk/src/stable/components/visualHFSM/xmlparser.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.cpp	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/xmlparser.cpp	2013-12-28 18:42:04 UTC (rev 1133)
@@ -36,6 +36,7 @@
     this->mapStringValues["transition"] = E_TRANSITION;
     this->mapStringValues["origin"] = E_ORIGIN;
     this->mapStringValues["destiny"] = E_DESTINY;
+    this->mapStringValues["transcode"] = E_TRANSCODE;
     this->mapStringValues["trans"] = E_TRANS;
     this->mapStringValues["libraries"] = E_LIBRARIES;
     this->mapStringValues["lib"] = E_LIB;
@@ -160,6 +161,10 @@
         case E_DESTINY:
             this->option = E_DESTINY;
             break;
+        case E_TRANSCODE:
+            this->option = E_TRANSCODE;
+            this->code.clear();
+            break;
         case E_TRANS: {
             for (xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin();
                                                             iter != attributes.end(); iter++) {
@@ -226,6 +231,9 @@
         case E_TRANSITION:
             this->subautomata->addTransition(this->transition->copy(), this->point->copyAsPointer());
             break;
+        case E_TRANSCODE:
+            this->transition->setCode(this->code);
+            break;
         case E_TRANS:
             this->transition->setTrans(this->type, this->code);
             break;
@@ -280,6 +288,10 @@
             this->code += text;
             break;
         }
+        case E_TRANSCODE: {
+            this->code += text;
+            break;
+        }
         case E_TRANSITION:
             break;
         case E_ORIGIN: {

Modified: trunk/src/stable/components/visualHFSM/xmlparser.h
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.h	2013-12-28 12:46:01 UTC (rev 1132)
+++ trunk/src/stable/components/visualHFSM/xmlparser.h	2013-12-28 18:42:04 UTC (rev 1133)
@@ -46,6 +46,7 @@
     E_TRANSITION,
     E_ORIGIN,
     E_DESTINY,
+    E_TRANSCODE,
     E_TRANS, 
     E_LIBRARIES,
     E_LIB,



More information about the Jderobot-admin mailing list