[Jderobot-admin] jderobot-r1036 - in trunk: . Deps Deps/gtk3 src/stable/components src/stable/components/visualHFSM src/stable/components/visualHFSM/gui src/stable/components/visualHFSM/popups
bmenendez en jderobot.org
bmenendez en jderobot.org
Jue Oct 10 18:28:40 CEST 2013
Author: bmenendez
Date: 2013-10-10 18:28:39 +0200 (Thu, 10 Oct 2013)
New Revision: 1036
Added:
trunk/Deps/gtk3/
trunk/Deps/gtk3/CMakeLists.txt
trunk/src/stable/components/visualHFSM/
trunk/src/stable/components/visualHFSM/CMakeLists.txt
trunk/src/stable/components/visualHFSM/common.h
trunk/src/stable/components/visualHFSM/generate.cpp
trunk/src/stable/components/visualHFSM/generate.h
trunk/src/stable/components/visualHFSM/gui/
trunk/src/stable/components/visualHFSM/gui/code.glade
trunk/src/stable/components/visualHFSM/gui/edittransition.glade
trunk/src/stable/components/visualHFSM/gui/funvar.glade
trunk/src/stable/components/visualHFSM/gui/import.glade
trunk/src/stable/components/visualHFSM/gui/main_gui.glade
trunk/src/stable/components/visualHFSM/gui/name.glade
trunk/src/stable/components/visualHFSM/gui/open.glade
trunk/src/stable/components/visualHFSM/gui/save.glade
trunk/src/stable/components/visualHFSM/gui/timing.glade
trunk/src/stable/components/visualHFSM/guinode.cpp
trunk/src/stable/components/visualHFSM/guinode.h
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/main.cpp
trunk/src/stable/components/visualHFSM/node.cpp
trunk/src/stable/components/visualHFSM/node.h
trunk/src/stable/components/visualHFSM/point.cpp
trunk/src/stable/components/visualHFSM/point.h
trunk/src/stable/components/visualHFSM/popups/
trunk/src/stable/components/visualHFSM/popups/editnodedialog.cpp
trunk/src/stable/components/visualHFSM/popups/editnodedialog.h
trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.cpp
trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.h
trunk/src/stable/components/visualHFSM/popups/funvardialog.cpp
trunk/src/stable/components/visualHFSM/popups/funvardialog.h
trunk/src/stable/components/visualHFSM/popups/importdialog.cpp
trunk/src/stable/components/visualHFSM/popups/importdialog.h
trunk/src/stable/components/visualHFSM/popups/loadfiledialog.cpp
trunk/src/stable/components/visualHFSM/popups/loadfiledialog.h
trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp
trunk/src/stable/components/visualHFSM/popups/renamedialog.h
trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.cpp
trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.h
trunk/src/stable/components/visualHFSM/popups/savefiledialog.cpp
trunk/src/stable/components/visualHFSM/popups/savefiledialog.h
trunk/src/stable/components/visualHFSM/popups/timerdialog.cpp
trunk/src/stable/components/visualHFSM/popups/timerdialog.h
trunk/src/stable/components/visualHFSM/savefile.cpp
trunk/src/stable/components/visualHFSM/savefile.h
trunk/src/stable/components/visualHFSM/subautomata.cpp
trunk/src/stable/components/visualHFSM/subautomata.h
trunk/src/stable/components/visualHFSM/tipos.h
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
Modified:
trunk/CMakeLists.txt
Log:
#55 Added VisualHFSM and Gtk3 with Goocanvasmm.
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2013-10-10 16:07:57 UTC (rev 1035)
+++ trunk/CMakeLists.txt 2013-10-10 16:28:39 UTC (rev 1036)
@@ -89,6 +89,7 @@
include(${DEPS_DIR}/tinyxml/CMakeLists.txt)
include(${DEPS_DIR}/gtk2/CMakeLists.txt)
include(${DEPS_DIR}/qt/CMakeLists.txt)
+include(${DEPS_DIR}/gtk3/CMakeLists.txt)
#include(${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/CMakeLists.txt)
Added: trunk/Deps/gtk3/CMakeLists.txt
===================================================================
--- trunk/Deps/gtk3/CMakeLists.txt (rev 0)
+++ trunk/Deps/gtk3/CMakeLists.txt 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,16 @@
+include(FindPkgConfig)
+
+PKG_CHECK_MODULES(gtk3 QUIET gtk+-3.0)
+PKG_CHECK_MODULES(gtkmm3 QUIET gtkmm-3.0)
+PKG_CHECK_MODULES(goocanvasmm QUIET goocanvasmm-2.0)
+IF (goocanvasmm_INCLUDE_DIRS)
+ MESSAGE("*** Goocanvasmm LIBRARIES FOUND")
+ELSE()
+ MESSAGE("*** Goocanvasmm LIBRARIES NOT FOUND")
+ENDIF()
+
+IF (goocanvasmm_INCLUDE_DIRS)
+ SET (VISUALHFSM_COMPILE TRUE)
+ELSE()
+ SET (VISUALHFSM_COMPILE FALSE)
+ENDIF()
Added: trunk/src/stable/components/visualHFSM/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/visualHFSM/CMakeLists.txt (rev 0)
+++ trunk/src/stable/components/visualHFSM/CMakeLists.txt 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,26 @@
+IF (VISUALHFSM_COMPILE)
+
+SET( SOURCE_FILES_VISUALHFSM point.cpp node.cpp transition.cpp guinode.cpp subautomata.cpp guitransition.cpp guisubautomata.cpp generate.cpp popups/editnodedialog.cpp popups/edittransitiondialog.cpp popups/funvardialog.cpp popups/importdialog.cpp popups/loadfiledialog.cpp popups/renamedialog.cpp popups/renametransitiondialog.cpp popups/savefiledialog.cpp popups/timerdialog.cpp savefile.cpp xmlparser.cpp visualhfsm.cpp main.cpp )
+
+#SET( CMAKE_CXX_FLAGS "-g -Wall -fpermissive" ) # Opciones para el compilador
+
+include_directories (
+ ${INTERFACES_CPP_DIR}
+ ${LIBS_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${gtkmm3_INCLUDE_DIRS}
+ ${goocanvasmm_INCLUDE_DIRS}
+ ${gtk3_INCLUDE_DIRS}
+ ${libxmlpp_INCLUDE_DIRS}
+)
+
+add_executable (visualHFSM ${SOURCE_FILES_VISUALHFSM})
+
+TARGET_LINK_LIBRARIES ( visualHFSM
+ ${gtkmm3_LIBRARIES}
+ ${goocanvasmm_LIBRARIES}
+ ${gtk3_LIBRARIES}
+ ${libxmlpp_LIBRARIES}
+)
+
+ENDIF()
Added: trunk/src/stable/components/visualHFSM/common.h
===================================================================
--- trunk/src/stable/components/visualHFSM/common.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/common.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <string>
+#include <iostream>
+
+/*************************************************************
+ * FOR NODES
+ *************************************************************/
+const int RADIUS_NORMAL = 20;
+const int RADIUS_INIT = 15;
+const int Y_NODE_IDEAL = 35;
+
+const std::string ITEM_NAME_NODE = "state";
+
+/*************************************************************
+ * FOR TRANSITIONS
+ *************************************************************/
+const int LINE_WIDTH = 1;
+const int ARROW_LENGTH = 10;
+const int ARROW_TIP_LENGTH = 10;
+const int ARROW_WIDTH = 10;
+const bool END_ARROW = true;
+
+const int SQUARE_SIDE = 10;
+const int SQUARE_SIDE_MID = SQUARE_SIDE / 2;
+const int Y_TRANS_IDEAL = 25;
+
+const std::string ITEM_NAME_TRANSITION = "transition";
+
+/*************************************************************
+ * FOR ITEMS IN GENERAL
+ *************************************************************/
+const std::string ITEM_COLOR_BLACK = "black";
+const std::string ITEM_COLOR_BLUE = "blue";
+const std::string ITEM_COLOR_GREEN = "green";
+const std::string ITEM_COLOR_GREY = "grey";
+const std::string ITEM_COLOR_PURPLE = "purple";
+const std::string ITEM_COLOR_RED = "red";
+const std::string ITEM_COLOR_WHITE = "white";
+const std::string ITEM_COLOR_YELLOW = "yellow";
+
+const int LETTER_WIDTH = 2;
+const float PIXELS_PER_LETTER = 3.5;
+
+/*************************************************************
+ * FOR STD OUTPUT COLOR (DEBUG)
+ *************************************************************/
+const bool DEBUG = true;
+
+const std::string BEGIN_RED = "\033[1;31m";
+const std::string BEGIN_GREEN = "\033[1;32m";
+const std::string BEGIN_YELLOW = "\033[1;33m";
+const std::string BEGIN_BLUE = "\033[1;34m";
+const std::string BEGIN_PURPLE = "\033[1;35m";
+const std::string BEGIN_LBLUE = "\033[1;36m";
+const std::string BEGIN_GREY = "\033[1;37m";
+const std::string END_COLOR = "\033[0m";
+
+const std::string VISUAL = "[[[[ ";
+const std::string GUISUB = "[[[ ";
+const std::string GUIELEM = "[[ ";
+const std::string OTHER = "[ ";
+
+#endif
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/generate.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/generate.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/generate.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,615 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "generate.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+Generate::Generate ( std::list<SubAutomata> subautomataList, std::string cpppath,
+ std::string cfgpath, std::string cmakepath ) {
+ this->subautomataList = subautomataList;
+ this->path = cpppath;
+ this->cfgpath = cfgpath;
+ this->cmakepath = cmakepath;
+
+ this->mapTab[T_ZERO] = std::string();
+ this->mapTab[T_ONE] = std::string("\t");
+ this->mapTab[T_TWO] = std::string("\t\t");
+ this->mapTab[T_THREE] = std::string("\t\t\t");
+ this->mapTab[T_FOUR] = std::string("\t\t\t\t");
+ this->mapTab[T_FIVE] = std::string("\t\t\t\t\t");
+ this->mapTab[T_SIX] = std::string("\t\t\t\t\t\t");
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Generate::~Generate () {}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+int Generate::init () {
+ this->fs.open(this->path.c_str(), std::fstream::out);
+ if (this->fs.is_open()) {
+ this->generateHeaders();
+ this->generateEnums();
+ this->generateVariables();
+ this->generateFunctions();
+ this->generateSubautomatas();
+ this->generateMain();
+ this->fs.close();
+
+ this->fs.open(this->cfgpath.c_str(), std::fstream::out);
+ if (this->fs.is_open()) {
+ this->generateCfg();
+ this->fs.close();
+ }
+
+ this->fs.open(this->cmakepath.c_str(), std::fstream::out);
+ if (this->fs.is_open()) {
+ this->generateCmake();
+ this->fs.close();
+ }
+ return 0;
+ } else
+ return 1;
+}
+
+void Generate::generateHeaders () {
+ this->generateGenericHeaders();
+ this->generateSpecificHeaders();
+}
+
+void Generate::generateGenericHeaders () {
+ this->fs << "#include <iostream>" << std::endl;
+ this->fs << "#include <stdio.h>" << std::endl;
+ this->fs << std::endl;
+ this->fs << "#include <Ice/Ice.h>" << std::endl;
+ this->fs << "#include <IceUtil/IceUtil.h>" << std::endl;
+ this->fs << std::endl;
+ this->fs.flush();
+}
+
+void Generate::generateSpecificHeaders () {
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ std::list<std::string>* interfacesList = subListIterator->getInterfaces();
+ for ( std::list<std::string>::iterator intListIterator = interfacesList->begin();
+ intListIterator != interfacesList->end(); intListIterator++ )
+ this->fs << "#include " << *intListIterator << std::endl;
+ this->fs << std::endl;
+ this->fs.flush();
+ }
+}
+
+void Generate::generateEnums () {
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ int id = subListIterator->getId();
+
+ this->fs << "typedef enum State_Sub_" << id << " {" << std::endl;
+ std::list<Node> nodeList = subListIterator->getNodeList();
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ ) {
+ if (id != 1) {
+ this->fs << "\t" << nodeListIterator->getName() << "," << std::endl;
+ this->fs << "\t" << nodeListIterator->getName() << "_ghost," << std::endl;
+ } else
+ this->fs << "\t" << nodeListIterator->getName() << "," << std::endl;
+ }
+ this->fs << "} State_Sub_" << id << ";" << std::endl;
+
+ this->fs << std::endl;
+
+ this->fs << "const char* Names_Sub_" << id << "[] = {" << std::endl;
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ ) {
+ this->fs << "\t\"" << nodeListIterator->getName() << "\"," << std::endl;
+ if (id != 1) {
+ std::string ghost = std::string(nodeListIterator->getName() + "_ghost");
+ this->fs << "\t\"" << ghost << "\"," << std::endl;
+ }
+ }
+ this->fs << "};" << std::endl;
+
+ this->fs << std::endl;
+ this->fs.flush();
+ }
+}
+
+void Generate::generateVariables () {
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ )
+ this->fs << "pthread_t thr_sub_" << subListIterator->getId() << ";" << std::endl;
+ this->fs << std::endl;
+
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ int id = subListIterator->getId();
+
+ std::list<Node> nodeList = subListIterator->getNodeList();
+ std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ while ( (!nodeListIterator->isInitial()) &&
+ (nodeListIterator != nodeList.end()) )
+ nodeListIterator++;
+
+ std::string nameState;
+ if (id != 1)
+ nameState = std::string(nodeListIterator->getName() + "_ghost");
+ else
+ nameState = std::string(nodeListIterator->getName());
+
+ this->fs << "State_Sub_" << id << " sub_" << id << " = " << nameState.c_str() << ";" << std::endl;
+ }
+ this->fs << std::endl;
+ this->fs.flush();
+
+ this->fs << "jderobot::CameraPrx cameraprx;" << std::endl;
+ this->fs << "jderobot::MotorsPrx motorsprx;" << std::endl;
+ this->fs << "jderobot::NaoMotionsPrx motions;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx head;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx leftshoulder;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx rightshoulder;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx leftelbow;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx rightelbow;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx lefthip;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx righthip;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx leftknee;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx rightknee;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx leftankle;" << std::endl;
+ this->fs << "jderobot::Pose3DMotorsPrx rightankle;" << std::endl;
+ this->fs << std::endl;
+ this->fs.flush();
+}
+
+void Generate::generateFunctions () {
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ this->fs << subListIterator->getFunctions() << std::endl;
+ this->fs << std::endl;
+ this->fs.flush();
+ }
+}
+
+void Generate::generateSubautomatas () {
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ int id = subListIterator->getId();
+ this->fs << "void* subautomata_" << id << " ( void* ) {" << std::endl;
+ this->fs << "\tstruct timeval a, b;" << std::endl;
+ this->fs << "\tint cycle = " << subListIterator->getTime() << ";" << std::endl;
+ this->fs << "\tlong totala, totalb;" << std::endl;
+ this->fs << "\tlong diff;" << std::endl;
+ this->fs << "\ttime_t t_ini;" << std::endl;
+ this->fs << "\ttime_t t_fin;" << std::endl;
+ this->fs << "\tdouble secs;" << std::endl;
+ this->fs << "\tbool t_activated;" << std::endl;
+ this->fs << std::endl;
+
+ int countNodes = 0;
+ std::list<Node> nodeList = subListIterator->getNodeList();
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ )
+ countNodes++;
+
+ std::map<std::string, float> mapNameTime;
+ std::list<Transition> transList = subListIterator->getTransList();
+ if (id != 1) {
+ for ( std::list<Transition>::iterator transListIterator = transList.begin();
+ transListIterator != transList.end(); transListIterator++ ) {
+ int idorigin = transListIterator->getIdOrigin();
+ if (transListIterator->getType().compare("time") == 0) {
+ std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ while ( (nodeListIterator->getId() != idorigin) &&
+ (nodeListIterator != nodeList.end()) )
+ nodeListIterator++;
+
+ float ms = atof(transListIterator->getCode().c_str());
+ this->fs << mapTab[T_ONE] << "t_" << nodeListIterator->getName() << "_max = " << (ms/1000.0) << ";" << std::endl;
+
+ mapNameTime[nodeListIterator->getName()] = ms/1000.0;
+ }
+ }
+ }
+
+ std::istringstream f(subListIterator->getVariables());
+ std::string line;
+ while (std::getline(f, line))
+ this->fs << "\t" << line << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\twhile (true) {" << std::endl;
+ this->fs << "\t\tgettimeofday(&a, NULL);" << std::endl;
+ this->fs << "\t\ttotala = a.tv_sec * 1000000 * a.tv_usec;" << std::endl;
+ this->fs << std::endl;
+
+ if (id != 1) {
+ int idfather = subListIterator->getIdFather();
+
+ std::list<SubAutomata>::iterator subFatherListIterator = this->subautomataList.begin();
+ while ( (subFatherListIterator->getId() != idfather) &&
+ (subFatherListIterator != this->subautomataList.end()) )
+ subFatherListIterator++;
+
+ std::list<Node> nodeFatherList = subFatherListIterator->getNodeList();
+ std::list<Node>::iterator nodeFatherListIterator = nodeFatherList.begin();
+ while ( (nodeFatherListIterator->getIdSubautomataSon() != id) &&
+ (nodeFatherListIterator != nodeFatherList.end()) )
+ nodeFatherListIterator++;
+
+ this->fs << "\t\tif (sub_" << idfather << " == " << nodeFatherListIterator->getName() << ") {" << std::endl;
+ this->fs << "\t\t\tif (";
+
+ int count = 0;
+ for ( std::list<Transition>::iterator nodeListIterator = transList.begin();
+ nodeListIterator != transList.end(); nodeListIterator++ ) {
+ this->fs << " sub_" << id << " == " << nodeListIterator->getName();
+ count++;
+ if (count != countNodes) {
+ this->fs << " ||";
+ }
+ }
+ this->fs << ") {" << std::endl;
+
+ this->fs << "\t\t\t\tsub_" << id << "(State_Sub_" << id << ")(sub_" << id << " - 1);" << std::endl;
+ this->fs << "\t\t\t\tt_ini = time(NULL);" << std::endl;
+ this->fs << "\t\t\t}" << std::endl;
+ }
+
+ this->fs << "\t\t// Evaluation switch" << std::endl;
+ this->fs << "\t\tswitch (sub_" << id << ") {" << std::endl;
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ ) {
+ int idNode = nodeListIterator->getId();
+ this->fs << "\t\t\tcase " << nodeListIterator->getName() << ": {" << std::endl;
+
+ for ( std::list<Transition>::iterator transListIterator = transList.begin();
+ transListIterator != transList.end(); transListIterator++ ) {
+ 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\t\tsub_" << id << " = " << subListIterator->getNodeName(idDestiny) << ";" << std::endl;
+ this->fs << "\t\t\t\t}" << std::endl;
+ } else {
+ this->fs << "\t\t\t\tif (!t_activated) {" << std::endl;
+ this->fs << "\t\t\t\t\tt_ini = time(NULL);" << std::endl;
+ this->fs << "\t\t\t\t\tt_activated = true;" << std::endl;
+ this->fs << "\t\t\t\t} else {" << std::endl;
+ 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());
+ 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;
+ 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;
+ this->fs << "\t\t\t\t}" << std::endl;
+ }
+ this->fs << std::endl;
+ }
+ }
+ this->fs << "\t\t\t\tbreak;" << std::endl;
+ this->fs << "\t\t\t}" << std::endl;
+ this->fs.flush();
+ }
+ this->fs << "\t\t}" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Actuation switch" << std::endl;
+ this->fs << "\t\tswitch (sub_" << id << ") {" << std::endl;
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ ) {
+ this->fs << "\t\t\tcase " << nodeListIterator->getName() << ": {" << std::endl;
+ std::istringstream f(nodeListIterator->getCode());
+ std::string line;
+ while (std::getline(f, line))
+ this->fs << "\t\t\t\t" << line << std::endl;
+ this->fs << "\t\t\t\tbreak;" << std::endl;
+ this->fs << "\t\t\t}" << std::endl;
+ this->fs.flush();
+ }
+ this->fs << "\t\t}" << std::endl;
+ if (id != 1) {
+ this->fs << "\t\t} else {" << std::endl;
+ this->fs << "\t\t\tswitch (sub_" << id << ") {" << std::endl;
+ for ( std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ nodeListIterator != nodeList.end(); nodeListIterator++ ) {
+ if (mapNameTime.find(nodeListIterator->getName()) != mapNameTime.end()) {
+ this->fs << "\t\t\t\tcase " << nodeListIterator->getName() << ":" << std::endl;
+ this->fs << "\t\t\t\t\tt_" << nodeListIterator->getName() << "_max = " << mapNameTime[nodeListIterator->getName()] << " - difftime(t_fin, t_ini);" << std::endl;
+ this->fs << "\t\t\t\t\tbreak;" << std::endl;
+ }
+ }
+ this->fs << "\t\t\t\tdefault:" << std::endl;
+ this->fs << "\t\t\t\t\tbreak;" << std::endl;
+ this->fs << "\t\t\t\tsub_" << id << " = (State_Sub_" << id << ")(sub_" << id << " + 1);" << std::endl;
+ this->fs << "\t\t\t}" << std::endl;
+ this->fs << "\t\t}" << std::endl;
+ }
+ this->fs << std::endl;
+
+ this->fs << "\t\tgettimeofday(&b, NULL);" << std::endl;
+ this->fs << "\t\ttotalb = b.tv_sec * 1000000 + b.tv_usec;" << std::endl;
+ this->fs << "\t\tdiff = (totalb - totala) / 1000;" << std::endl;
+ this->fs << "\t\tif (diff < 0 || diff > cycle)" << std::endl;
+ this->fs << "\t\t\tdiff = cycle;" << std::endl;
+ this->fs << "\t\telse" << std::endl;
+ this->fs << "\t\t\tdiff = cycle - diff;" << std::endl;
+ this->fs << std::endl;
+ this->fs << "\t\tusleep(diff * 1000);" << std::endl;
+ this->fs << "\t\tif (diff < 33 )" << std::endl;
+ this->fs << "\t\t\tusleep (33 * 1000);" << std::endl;
+
+ this->fs << "\t}" << std::endl;
+ this->fs << "}" << std::endl;
+
+ this->fs << std::endl;
+ this->fs.flush();
+ }
+}
+
+void Generate::generateMain () {
+ this->fs << "int main (int argc, char* argv[]) {" << std::endl;
+ this->fs << "\tint status;" << std::endl;
+ this->fs << "\tIce::CommunicatorPtr ic;" << std::endl;
+ this->fs << std::endl;
+ this->fs << "\ttry {" << std::endl;
+ this->fs << "\t\tic = Ice::initialize(argc, argv);" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to camera" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx camera = ic->propertyToProxy(\"comp.Camera.Proxy\");" << std::endl;
+ this->fs << "\t\tif (camera == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with camera\";" << std::endl;
+ this->fs << "\t\tcameraprx = jderobot::CameraPrx::checkedCast(camera);" << std::endl;
+ this->fs << "\t\tif (cameraprx == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Camera.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Camera connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to motors (for walking)" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx motors = ic->propertyToProxy(\"comp.Motors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (motors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with motors\";" << std::endl;
+ this->fs << "\t\tmotorsprx = jderobot::MotorsPrx::checkedCast(motors);" << std::endl;
+ this->fs << "\t\tif (motorsprx == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Motors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Motors connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ this->fs << "\t\t// Contact to motors (for different actions)" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx motionsPrx = ic->propertyToProxy(\"comp.Motions.Proxy\");" << std::endl;
+ this->fs << "\t\tif (motionsPrx == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with motions\";" << std::endl;
+ this->fs << "\t\tmotions = jderobot::NaoMotionsPrx::checkedCast(motionsPrx);" << std::endl;
+ this->fs << "\t\tif (motions == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Motions.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Motions connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to head motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx headmotors = ic->propertyToProxy(\"comp.HeadMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (headmotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with head motors\";" << std::endl;
+ this->fs << "\t\thead = jderobot::Pose3DMotorsPrx::checkedCast(headmotors);" << std::endl;
+ this->fs << "\t\tif (head == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.HeadMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Head motors connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to shoulders motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx leftshouldermotors = ic->propertyToProxy(\"comp.LeftShoulderMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (leftshouldermotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with left shoulder motors\";" << std::endl;
+ this->fs << "\t\tleftshoulder = jderobot::Pose3DMotorsPrx::checkedCast(leftshouldermotors);" << std::endl;
+ this->fs << "\t\tif (leftshoulder == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftShoulderMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Left shoulder connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ this->fs << "\t\tIce::ObjectPrx rightshouldermotors = ic->propertyToProxy(\"comp.RightShoulderMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (rightshouldermotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right shoulder motors\";" << std::endl;
+ this->fs << "\t\trightshoulder = jderobot::Pose3DMotorsPrx::checkedCast(rightshouldermotors);" << std::endl;
+ this->fs << "\t\tif (rightshoulder == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightShoulderMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Right shoulder connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to elbows motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx leftelbowmotors = ic->propertyToProxy(\"comp.LeftElbowMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (leftelbowmotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right elbow motors\";" << std::endl;
+ this->fs << "\t\tleftelbow = jderobot::Pose3DMotorsPrx::checkedCast(leftelbowmotors);" << std::endl;
+ this->fs << "\t\tif (leftelbow == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftElbowMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Left elbow connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\tIce::ObjectPrx rightelbowmotors = ic->propertyToProxy(\"comp.RightElbowMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (rightelbowmotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right elbow motors\";" << std::endl;
+ this->fs << "\t\trightelbow = jderobot::Pose3DMotorsPrx::checkedCast(rightelbowmotors);" << std::endl;
+ this->fs << "\t\tif (rightelbow == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightElbowMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Right elbow connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ this->fs << "\t\t// Contact to hips motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx lefthipmotors = ic->propertyToProxy(\"comp.LeftHipMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (lefthipmotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with left hip motors\";" << std::endl;
+ this->fs << "\t\tlefthip = jderobot::Pose3DMotorsPrx::checkedCast(lefthipmotors);" << std::endl;
+ this->fs << "\t\tif (lefthip == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftHipMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Left hip connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\tIce::ObjectPrx righthipmotors = ic->propertyToProxy(\"comp.RightHipMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (righthipmotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right hip motors\";" << std::endl;
+ this->fs << "\t\trighthip = jderobot::Pose3DMotorsPrx::checkedCast(righthipmotors);" << std::endl;
+ this->fs << "\t\tif (righthip == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightHipMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Right hip connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to knees motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx leftkneemotors = ic->propertyToProxy(\"comp.LeftKneeMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (leftkneemotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with left knee motors\";" << std::endl;
+ this->fs << "\t\tleftknee = jderobot::Pose3DMotorsPrx::checkedCast(leftkneemotors);" << std::endl;
+ this->fs << "\t\tif (leftknee == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftKneeMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Left knee connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ this->fs << "\t\tIce::ObjectPrx rightkneemotors = ic->propertyToProxy(\"comp.RightKneeMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (rightkneemotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right knee motors\";" << std::endl;
+ this->fs << "\t\trightknee = jderobot::Pose3DMotorsPrx::checkedCast(rightkneemotors);" << std::endl;
+ this->fs << "\t\tif (rightknee == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightKneeMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Right knee motors connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\t// Contact to ankles motors" << std::endl;
+ this->fs << "\t\tIce::ObjectPrx leftanklemotors = ic->propertyToProxy(\"comp.LeftAnkleMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (leftanklemotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with left ankle motors\";" << std::endl;
+ this->fs << "\t\tleftankle = jderobot::Pose3DMotorsPrx::checkedCast(leftanklemotors);" << std::endl;
+ this->fs << "\t\tif (leftankle == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftAnkleMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Left ankle motors connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs << "\t\tIce::ObjectPrx rightanklemotors = ic->propertyToProxy(\"comp.RightAnkleMotors.Proxy\");" << std::endl;
+ this->fs << "\t\tif (rightanklemotors == 0)" << std::endl;
+ this->fs << "\t\t\t throw \"Could not create proxy with right ankle motors\";" << std::endl;
+ this->fs << "\t\trightankle = jderobot::Pose3DMotorsPrx::checkedCast(rightanklemotors);" << std::endl;
+ this->fs << "\t\tif (rightankle == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightAnkleMotors.Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"Right ankle motors connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ int id = subListIterator->getId();
+ this->fs << "\t\tpthread_create(&thr_sub_" << id << ", NULL, &subautomata_" << id << ", NULL);" << std::endl;
+ }
+ this->fs << std::endl;
+
+ for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ int id = subListIterator->getId();
+ this->fs << "\t\tpthread_join(thr_sub_" << id << ", NULL);" << std::endl;
+ }
+ this->fs << std::endl;
+
+ this->fs.flush();
+
+ this->fs << this->mapTab[T_ONE] << "} catch ( const Ice::Exception& ex ) {" << std::endl;
+ this->fs << this->mapTab[T_TWO] << "std::cerr << ex << std::endl;" << std::endl;
+ this->fs << this->mapTab[T_TWO] << "status = 1;" << std::endl;
+ this->fs << this->mapTab[T_ONE] << "} catch ( const char* msg ) {" << std::endl;
+ this->fs << this->mapTab[T_TWO] << "std::cerr << msg << std::endl;" << std::endl;
+ this->fs << this->mapTab[T_TWO] << "status = 1;" << std::endl;
+ this->fs << this->mapTab[T_ONE] << "}" << std::endl;
+ this->fs << std::endl;
+ this->fs << this->mapTab[T_ONE] << "if (ic)" << std::endl;
+ this->fs << this->mapTab[T_TWO] << "ic->destroy();" << std::endl;
+ this->fs << std::endl;
+ this->fs << this->mapTab[T_ONE] << "return status;" << std::endl;
+ this->fs << "}" << std::endl;
+
+ this->fs.flush();
+}
+
+void Generate::generateCfg () {
+ this->fs << "comp.HeadMotors.Proxy=NeckMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.HeadSpeed.Proxy=NeckSpeed:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.LeftShoulderMotors.Proxy=LeftShoulderMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.RightShoulderMotors.Proxy=RightShoulderMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.LeftElbowMotors.Proxy=LeftElbowMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.RightElbowMotors.Proxy=RightElbowMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.LeftHipMotors.Proxy=LeftHipMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.RightHipMotors.Proxy=RightHipMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.LeftKneeMotors.Proxy=LeftKneeMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.RightKneeMotors.Proxy=RightKneeMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.LeftAnkleMotors.Proxy=LeftAnkleMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+ this->fs << "comp.RightAnkleMotors.Proxy=RightAnkleMotors:default -h 192.168.14.113 -p 10000" << std::endl;
+
+ this->fs.flush();
+}
+
+void Generate::generateCmake () {
+ this->fs << "project (AUTOMATA)" << std::endl;
+ this->fs << std::endl;
+ this->fs << "cmake_minimum_required(VERSION 2.8)" << std::endl;
+ this->fs << "include(FindPkgConfig)" << std::endl;
+ this->fs << std::endl;
+ this->fs << "SET( SOURCE_FILES_AUTOMATA " << this->getCppName() << " )" << std::endl;
+ this->fs << std::endl;
+ this->fs << "SET( INTERFACES_CPP_DIR /usr/local/lib/jderobot )" << std::endl;
+ this->fs << "SET( LIBS_DIR /usr/local/include/jderobot )" << std::endl;
+ this->fs << std::endl;
+ this->fs << "SET( CMAKE_CXX_FLAGS \"-lpthread -lIce\" ) # Opciones para el compilador" << std::endl;
+ this->fs << std::endl;
+ this->fs << "include_directories (" << std::endl;
+ this->fs << "\t${INTERFACES_CPP_DIR}" << std::endl;
+ this->fs << "\t${LIBS_DIR}" << std::endl;
+ this->fs << "\t${CMAKE_CURRENT_SOURCE_DIR}" << std::endl;
+ this->fs << ")" << std::endl;
+ this->fs << std::endl;
+ this->fs << "add_executable (automata ${SOURCE_FILES_AUTOMATA})" << std::endl;
+ this->fs << std::endl;
+ this->fs << "TARGET_LINK_LIBRARIES ( automata " << std::endl;
+ this->fs << "\t${INTERFACES_CPP_DIR}/libJderobotInterfaces.so" << std::endl;
+ this->fs << "\t${INTERFACES_CPP_DIR}/libjderobotutil.so" << std::endl;
+ this->fs << "\t/usr/lib/libIceUtil.so" << std::endl;
+ this->fs << ")" << std::endl;
+
+ this->fs.flush();
+}
+
+std::string Generate::getCppName () {
+ size_t last_pos = this->path.find_last_of(std::string("/"));
+ if (last_pos == std::string::npos)
+ return NULL;
+
+ return this->path.substr(last_pos + 1, std::string::npos);
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/generate.h
===================================================================
--- trunk/src/stable/components/visualHFSM/generate.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/generate.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,77 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef GENERATE_H
+#define GENERATE_H
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "subautomata.h"
+
+ typedef enum TabEnum {
+ T_ZERO,
+ T_ONE,
+ T_TWO,
+ T_THREE,
+ T_FOUR,
+ T_FIVE,
+ T_SIX
+} TabEnum;
+
+class Generate {
+public:
+ // Constructor
+ Generate ( std::list<SubAutomata> subautomataList, std::string cpppath,
+ std::string cfgpath, std::string cmakepath );
+
+ // Destructor
+ virtual ~Generate ();
+
+ // Another functions
+ int init ();
+
+private:
+ std::list<SubAutomata> subautomataList;
+ std::string path, cfgpath, cmakepath;
+ std::fstream fs;
+ std::map<TabEnum, std::string> mapTab;
+
+ void generateHeaders ();
+ void generateGenericHeaders ();
+ void generateSpecificHeaders ();
+ void generateEnums ();
+ void generateVariables ();
+ void generateFunctions ();
+ void generateSubautomatas ();
+ void generateMain ();
+
+ void generateCfg ();
+
+ void generateCmake ();
+
+ std::string getCppName ();
+
+}; // Class Generate
+
+#endif // GENERATE_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/gui/code.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/code.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/code.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -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"><b>State code</b></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>
Added: trunk/src/stable/components/visualHFSM/gui/edittransition.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/edittransition.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/edittransition.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="dialog_edittransition">
+ <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_area">
+ <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="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkButtonBox" id="buttonbox_radio">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkRadioButton" id="radiobutton_temporal">
+ <property name="label" translatable="yes">Temporal</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">half</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="radiobutton_conditional">
+ <property name="label" translatable="yes">Conditional</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0.0099999997764825821</property>
+ <property name="draw_indicator">True</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="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="alignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkEntry" id="entry_text">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Write here...</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tag</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </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="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>
Added: trunk/src/stable/components/visualHFSM/gui/funvar.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/funvar.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/funvar.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="dialog_funvar">
+ <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="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkTextView" id="textview_variables">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label_variables">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Variables</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="textview_functions">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label_functions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Functions</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </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>
Added: trunk/src/stable/components/visualHFSM/gui/import.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/import.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/import.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment3">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment4">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment5">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkDialog" id="dialog_import">
+ <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="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <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="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_laser">
+ <property name="label" translatable="yes">Laser</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_sonar">
+ <property name="label" translatable="yes">Sonar</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_camera">
+ <property name="label" translatable="yes">Camera</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_pose3dencoders">
+ <property name="label" translatable="yes">Pose3DEncoders</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_sensors">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Sensors</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <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="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_pose3dmotors">
+ <property name="label" translatable="yes">Pose3DMotors</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_actuators">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Actuators</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </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="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>
Added: trunk/src/stable/components/visualHFSM/gui/main_gui.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/main_gui.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/main_gui.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,1135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="VisualHFSM">
+ <property name="width_request">1024</property>
+ <property name="height_request">768</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="title" translatable="yes">VisualHFSM</property>
+ <property name="default_width">1024</property>
+ <property name="default_height">768</property>
+ <property name="destroy_with_parent">True</property>
+ <child>
+ <object class="GtkHBox" id="hbox_visualhfsm">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_total_treeview">
+ <property name="width_request">180</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">15</property>
+ <property name="left_padding">20</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_treeview">
+ <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="alignment_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">treestore</property>
+ <property name="reorderable">True</property>
+ <property name="enable_tree_lines">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview_selection"/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Tree</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_total_schema">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="double_buffered">False</property>
+ <property name="hexpand">True</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">15</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_schema">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="double_buffered">False</property>
+ <property name="hexpand">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport" id="viewport_schema">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="double_buffered">False</property>
+ <property name="hexpand">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_schema">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Schema</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_total_options">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">15</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">20</property>
+ <property name="hexpand">False</property>
+ <child>
+ <object class="GtkFrame" id="frame_options">
+ <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="alignment_options">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox_options">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_navigation">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_navigation">
+ <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="alignment_nav_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table_button_up">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">5</property>
+ <child>
+ <object class="GtkButton" id="button_up">
+ <property name="label" translatable="yes">UP</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="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed17">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed19">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed21">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed22">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed23">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed24">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed25">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed26">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed27">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_navigation">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Navigation</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_figures">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_figures">
+ <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="alignment_figs_buttons">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table_buttons_figures">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">5</property>
+ <child>
+ <object class="GtkButton" id="button_transition">
+ <property name="label" translatable="yes">Transition</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_state">
+ <property name="label" translatable="yes">State</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="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed13">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_figures">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Figures</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_save_open">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_save_open">
+ <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="alignment_save_open_buttons">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table_buttons_save_open">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">3</property>
+ <child>
+ <object class="GtkButton" id="button_save">
+ <property name="label" translatable="yes">Save</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="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_save_as">
+ <property name="label" translatable="yes">Save as</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_open">
+ <property name="label" translatable="yes">Open</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="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed28">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed29">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed30">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed31">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed32">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed33">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_save_open">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Save/Open</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_subautomata_data">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_subautomata_data">
+ <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="alignment_subautomata_dat">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table_buttons_subautomata_data">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">3</property>
+ <child>
+ <object class="GtkButton" id="button_interfaces">
+ <property name="label" translatable="yes">Interfaces</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="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_timer">
+ <property name="label" translatable="yes">Timer</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_variables">
+ <property name="label" translatable="yes">Variables</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="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed34">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed35">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed36">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed37">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed38">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed39">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_subautomata_data">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Subautomata data</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment_code_compile">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">10</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <object class="GtkFrame" id="frame_code_compile">
+ <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="alignment_code_compil">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table_buttons_code_compile">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">5</property>
+ <child>
+ <object class="GtkButton" id="button_generate_code">
+ <property name="label" translatable="yes">Generate code</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_compile">
+ <property name="label" translatable="yes">Compile</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="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed40">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed41">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed42">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed43">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed44">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed45">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed46">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed47">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed48">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed49">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed50">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed51">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFixed" id="fixed52">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_code_compile">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Code and compile</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_options">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Options</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkTreeStore" id="treestore"/>
+</interface>
Added: trunk/src/stable/components/visualHFSM/gui/name.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/name.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/name.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="dialog_name">
+ <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-vbox">
+ <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_area">
+ <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="GtkAlignment" id="alignment_dialog">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkFrame" id="frame_dialog">
+ <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="alignment_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkEntry" id="entry_text">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Write here...</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Name:</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</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="1">button_accept</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Added: trunk/src/stable/components/visualHFSM/gui/open.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/open.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/open.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkFileChooserDialog" id="filechooserdialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="role">GtkFileChooserDialog</property>
+ <property name="default_width">640</property>
+ <property name="default_height">480</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="filechooser">
+ <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="filechooserdialog-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_open">
+ <property name="label" translatable="yes">Open</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>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button_cancel</action-widget>
+ <action-widget response="0">button_open</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Added: trunk/src/stable/components/visualHFSM/gui/save.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/save.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/save.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkFileChooserDialog" id="filechooserdialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="role">GtkFileChooserDialog</property>
+ <property name="type_hint">dialog</property>
+ <property name="action">save</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="filechooserdialog_vbox">
+ <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="filechooserdialog-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_save">
+ <property name="label" translatable="yes">Save</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>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button_cancel</action-widget>
+ <action-widget response="0">button_save</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Added: trunk/src/stable/components/visualHFSM/gui/timing.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/timing.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/timing.glade 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="dialog_timing">
+ <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="GtkEntry" id="entry_time">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Time in ms</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Time</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</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>
Added: trunk/src/stable/components/visualHFSM/guinode.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guinode.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/guinode.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,271 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "guinode.h"
+
+/*************************************************************
+ * CONSTRUCTORS
+ *************************************************************/
+GuiNode::GuiNode ( Node n, Point p )
+: node(*(new Node(n.getId())))
+, point(*(new Point(p.getX(), p.getY()))) {
+ this->node.setIdSubautomataSon(n.getIdSubautomataSon());
+ this->node.setName(n.getName());
+}
+
+GuiNode::GuiNode ( int id, int idSubautomataSon, float x, float y )
+: node(*(new Node(id)))
+, point(*(new Point(x, y))) {
+ this->node.setIdSubautomataSon(idSubautomataSon);
+ this->node.setName(ITEM_NAME_NODE);
+ this->ellipse = Goocanvas::EllipseModel::create(x, y, RADIUS_NORMAL, RADIUS_NORMAL);
+ this->drawIt(1, ITEM_COLOR_BLACK, ITEM_COLOR_BLUE);
+ this->ellipseInitial = Goocanvas::EllipseModel::create(x, y, RADIUS_INIT, RADIUS_INIT);
+ this->text = Goocanvas::TextModel::create( ITEM_NAME_NODE,
+ x - ITEM_NAME_NODE.size() * PIXELS_PER_LETTER,
+ y - Y_NODE_IDEAL, LETTER_WIDTH);
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+GuiNode::~GuiNode () {
+ if (itemInitial)
+ this->itemInitial->remove();
+
+ if (itemText)
+ this->itemText->remove();
+
+ if (item)
+ this->item->remove();
+}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void GuiNode::setAsInitial ( bool initial ) {
+ this->node.setInitial(initial);
+ if (initial)
+ this->drawAsInitial(1, ITEM_COLOR_BLACK, ITEM_COLOR_BLUE);
+ else
+ this->drawAsInitial(0, ITEM_COLOR_BLACK, ITEM_COLOR_BLUE);
+}
+
+void GuiNode::setIdSubautomataSon ( int id ) {
+ this->node.setIdSubautomataSon(id);
+}
+
+void GuiNode::setItems ( const Glib::RefPtr<Goocanvas::Item>& item,
+ Glib::RefPtr<Goocanvas::Item> itemInitial,
+ Glib::RefPtr<Goocanvas::Item> itemText ) {
+ this->item = item;
+ this->itemInitial = itemInitial;
+ this->itemText = itemText;
+}
+
+void GuiNode::setCode ( std::string code ) {
+ this->node.setCode(code);
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+Glib::RefPtr<Goocanvas::Item> GuiNode::getItem () {
+ return this->item;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiNode::getItemInitial () {
+ return this->itemInitial;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiNode::getItemText () {
+ return this->itemText;
+}
+
+Glib::RefPtr<Goocanvas::EllipseModel> GuiNode::getEllipse () {
+ return this->ellipse;
+}
+
+Glib::RefPtr<Goocanvas::EllipseModel> GuiNode::getEllipseInitial () {
+ return this->ellipseInitial;
+}
+
+Glib::RefPtr<Goocanvas::TextModel> GuiNode::getText () {
+ return this->text;
+}
+
+int GuiNode::getId () {
+ return this->node.getId();
+}
+
+int GuiNode::getIdSubautomataSon () {
+ return this->node.getIdSubautomataSon();
+}
+
+std::string GuiNode::getCode () {
+ return this->node.getCode();
+}
+
+std::string GuiNode::getName () {
+ return this->node.getName();
+}
+
+Point GuiNode::getPoint () {
+ return this->point;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+bool GuiNode::itIsInitial () {
+ return this->node.isInitial();
+}
+
+bool GuiNode::hasThisItem ( const Glib::RefPtr<Goocanvas::Item>& item ) {
+ return ((this->item == item) || (this->itemInitial == item) || (this->itemText == item));
+}
+
+void GuiNode::hide () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUIELEM << "Hiding node" << END_COLOR << std::endl;
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipse->property_visibility() = Goocanvas::ITEM_INVISIBLE;
+ this->ellipseInitial->property_visibility() = Goocanvas::ITEM_INVISIBLE;
+ this->text->property_visibility() = Goocanvas::ITEM_INVISIBLE;
+ #else
+ this->ellipse->set_property("visibility", Goocanvas::ITEM_INVISIBLE);
+ this->ellipseInitial->set_property("visibility", Goocanvas::ITEM_INVISIBLE);
+ this->text->set_property("visibility", Goocanvas::ITEM_INVISIBLE);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::show () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUIELEM << "Showing node" << END_COLOR << std::endl;
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipse->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ this->ellipseInitial->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ this->text->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ #else
+ this->ellipse->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ this->ellipseInitial->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ this->text->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::isVisible () {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ if (this->ellipse->property_visibility())
+ std::cout << "ellipse visible" << std::endl;
+ else
+ std::cout << "ellipse invisible" << std::endl;
+ if (this->ellipseInitial->property_visibility())
+ std::cout << "ellipse initial visible" << std::endl;
+ else
+ std::cout << "ellipse initial invisible" << std::endl;
+ if (this->text->property_visibility())
+ std::cout << "text visible" << std::endl;
+ else
+ std::cout << "text invisible" << std::endl;
+ #else
+ if (this->ellipse->get_property("visibility"))
+ std::cout << "ellipse visible" << std::endl;
+ else
+ std::cout << "ellipse invisible" << std::endl;
+ if (this->ellipseInitial->get_property("visibility"))
+ std::cout << "ellipse initial visible" << std::endl;
+ else
+ std::cout << "ellipse initial invisible" << std::endl;
+ if (this->text->get_property("visibility"))
+ std::cout << "text visible" << std::endl;
+ else
+ std::cout << "text invisible" << std::endl;
+ #endif
+}
+
+void GuiNode::changeLineWidth ( float newLineWidth ) {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipse->property_line_width() = double(newLineWidth);
+ #else
+ this->ellipse->set_property("line_width", double(newLineWidth));
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::changeLineWidthInitial ( float newLineWidthInitial ) {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipseInitial->property_line_width() = newLineWidthInitial;
+ #else
+ this->ellipseInitial->set_property("line_width", newLineWidthInitial);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::changeText ( std::string newText ) {
+ this->node.setName(newText);
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->text->property_text() = newText;
+ this->text->property_x() = this->point.getX() - newText.size() * PIXELS_PER_LETTER;
+ this->text->property_y() = this->point.getY() - Y_NODE_IDEAL;
+ #else
+ this->text->set_property("text", newText);
+ this->text->set_property("x", this->point.getX() - newText.size() * PIXELS_PER_LETTER);
+ this->text->set_property("y", this->point.getY() - Y_NODE_IDEAL);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::moveItems ( double dx, double dy ) {
+ this->item->translate(dx, dy);
+ this->itemInitial->translate(dx, dy);
+ this->text->translate(dx, dy);
+ this->point.move(dx, dy);
+}
+
+GuiNode GuiNode::copy () {
+ GuiNode gnode(this->node.copy(), this->point.copy());
+ gnode.setItems(this->item, this->itemInitial, this->itemText);
+
+ return gnode;
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void GuiNode::drawAsInitial ( float line_width, std::string stroke_color, std::string fill_color ) {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipseInitial->property_line_width() = line_width;
+ this->ellipseInitial->property_stroke_color() = stroke_color;
+ #else
+ this->ellipseInitial->set_property("line_width", line_width);
+ this->ellipseInitial->set_property("stroke_color", Glib::ustring(stroke_color));
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiNode::drawIt ( float line_width, std::string stroke_color, std::string fill_color ) {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->ellipse->property_line_width() = line_width;
+ this->ellipse->property_stroke_color() = stroke_color;
+ this->ellipse->property_fill_color() = fill_color;
+ #else
+ this->ellipse->set_property("line_width", line_width);
+ this->ellipse->set_property("stroke_color", Glib::ustring(stroke_color));
+ this->ellipse->set_property("fill_color", Glib::ustring(fill_color));
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/guinode.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guinode.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/guinode.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,98 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef GUINODE_H
+#define GUINODE_H
+
+#include <list>
+#include <string>
+#include <iostream>
+
+#include <gtkmm-3.0/gtkmm.h>
+#include <goocanvasmm-2.0/goocanvasmm.h>
+#include <boost/shared_ptr.hpp>
+
+#include "common.h"
+#include "point.h"
+#include "node.h"
+
+// Definition of this class
+class GuiNode {
+public:
+ // Constructors
+ GuiNode ( Node node, Point p );
+ GuiNode ( int id, int idSubautomataSon, float x, float y );
+
+ // Destructor
+ virtual ~GuiNode ();
+
+ // Setters
+ void setAsInitial ( bool initial );
+ void setIdSubautomataSon ( int id );
+ void setItems ( const Glib::RefPtr<Goocanvas::Item>& item,
+ Glib::RefPtr<Goocanvas::Item> itemInitial,
+ Glib::RefPtr<Goocanvas::Item> itemText );
+ void setCode ( std::string code );
+
+ // Getters
+ Glib::RefPtr<Goocanvas::Item> getItem ();
+ Glib::RefPtr<Goocanvas::Item> getItemInitial ();
+ Glib::RefPtr<Goocanvas::Item> getItemText ();
+
+ Glib::RefPtr<Goocanvas::EllipseModel> getEllipse ();
+ Glib::RefPtr<Goocanvas::EllipseModel> getEllipseInitial ();
+
+ Glib::RefPtr<Goocanvas::TextModel> getText ();
+
+ int getId ();
+ int getIdSubautomataSon ();
+ std::string getCode ();
+ std::string getName ();
+ Point getPoint ();
+
+ // Another functions
+ bool hasThisItem ( const Glib::RefPtr<Goocanvas::Item>& item );
+ bool itIsInitial ();
+
+ void hide ();
+ void show ();
+ void isVisible ();
+
+ void changeLineWidth ( float newLineWidth );
+ void changeLineWidthInitial ( float newLineWidthInitial );
+ void changeText ( std::string newText );
+ void moveItems ( double dx, double dy );
+
+ GuiNode copy ();
+
+private:
+ // Data structure
+ Node node;
+ Point point;
+ Glib::RefPtr<Goocanvas::EllipseModel> ellipse, ellipseInitial;
+ Glib::RefPtr<Goocanvas::TextModel> text;
+ Glib::RefPtr<Goocanvas::Item> item, itemInitial, itemText;
+
+ // Private methods
+ void drawAsInitial ( float line_width, std::string stroke_color, std::string fill_color );
+ void drawIt (float line_width, std::string stroke_color, std::string fill_color);
+};
+
+#endif
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/guisubautomata.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,691 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "guisubautomata.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+GuiSubautomata::GuiSubautomata ( int id, int idFather ) {
+ this->id = id;
+ this->idFather = idFather;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+GuiSubautomata::~GuiSubautomata () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void GuiSubautomata::setFunctions ( std::string functions ) {
+ this->functions = functions;
+}
+
+void GuiSubautomata::setTime ( std::string timing ) {
+ this->timing = timing;
+}
+
+void GuiSubautomata::setVariables ( std::string variables ) {
+ this->variables = variables;
+}
+
+void GuiSubautomata::setInterfaces ( std::list<std::string>& interfaces ) {
+ this->interfaces = interfaces;
+}
+
+void GuiSubautomata::setNodeList ( std::list<GuiNode>* list ) {
+ this->nodeList.clear();
+ for ( std::list<GuiNode>::iterator nodeListIterator = list->begin();
+ nodeListIterator != list->end(); nodeListIterator++ )
+ this->nodeList.push_back(*nodeListIterator);
+}
+
+void GuiSubautomata::setTransList ( std::list<GuiTransition>* list ) {
+ this->transitionList.clear();
+ for ( std::list<GuiTransition>::iterator transListIterator = list->begin();
+ transListIterator != list->end(); transListIterator++ )
+ this->transitionList.push_back(*transListIterator);
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+int GuiSubautomata::getId () {
+ return this->id;
+}
+
+int GuiSubautomata::getIdFather () {
+ return this->idFather;
+}
+
+std::string GuiSubautomata::getFunctions () {
+ return this->functions;
+}
+
+std::string GuiSubautomata::getTime () {
+ return this->timing;
+}
+
+std::string GuiSubautomata::getVariables () {
+ return this->variables;
+}
+
+std::list<std::string>* GuiSubautomata::getInterfaces () {
+ return &this->interfaces;
+}
+
+std::list<GuiNode>* GuiSubautomata::getListGuiNodes () {
+ return &this->nodeList;
+}
+
+std::list<GuiTransition>* GuiSubautomata::getListGuiTransitions () {
+ return &this->transitionList;
+}
+
+std::list<GuiTransition> GuiSubautomata::getAllGuiTransitionsWith (
+ Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiTransition> guiTransitionList;
+
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while (nodeTransIterator != this->transitionList.end()) {
+ if (nodeTransIterator->hasThisItem(item))
+ guiTransitionList.push_back(*nodeTransIterator);
+ nodeTransIterator++;
+ }
+
+ return guiTransitionList;
+}
+
+std::list<GuiTransition> GuiSubautomata::getAllGuiTransitionsWith ( int id ) {
+ std::list<GuiTransition> guiTransitionList;
+
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while (nodeTransIterator != this->transitionList.end()) {
+ if ( (nodeTransIterator->getIdOrigin() == id) ||
+ (nodeTransIterator->getIdDestiny() == id))
+ guiTransitionList.push_back(*nodeTransIterator);
+ nodeTransIterator++;
+ }
+
+ return guiTransitionList;
+}
+
+GuiNode* GuiSubautomata::getGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ return &*nodeListIterator;
+
+ return NULL;
+}
+
+GuiTransition* GuiSubautomata::getGuiTransition ( 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())
+ return &*nodeTransIterator;
+
+ return NULL;
+}
+
+Point GuiSubautomata::getPoint ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ return nodeListIterator->getPoint();
+
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while ( (!nodeTransIterator->hasThisItem(item)) &&
+ (nodeTransIterator != this->transitionList.end()) )
+ nodeTransIterator++;
+
+ return nodeTransIterator->getPoint();
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void GuiSubautomata::hideAll () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Hiding (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
+
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( nodeListIterator != this->nodeList.end() ) {
+ nodeListIterator->hide();
+ nodeListIterator++;
+ }
+
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while ( nodeTransIterator != this->transitionList.end() ) {
+ nodeTransIterator->hide();
+ nodeTransIterator++;
+ }
+}
+
+void GuiSubautomata::showAll () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Showing (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
+
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( nodeListIterator != this->nodeList.end() ) {
+ nodeListIterator->show();
+// nodeListIterator->isVisible();
+ nodeListIterator++;
+ }
+
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while ( nodeTransIterator != this->transitionList.end() ) {
+ nodeTransIterator->show();
+ nodeTransIterator++;
+ }
+}
+
+void GuiSubautomata::removeAll () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Removing (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
+
+ this->nodeList.clear();
+ this->transitionList.clear();
+}
+
+// Is node list empty?
+bool GuiSubautomata::isNodeListEmpty () {
+ return this->nodeList.empty();
+}
+
+bool GuiSubautomata::findInterface ( std::string interface ) {
+ bool found = false;
+
+ std::list<std::string>::iterator interfacesIterator = this->interfaces.begin();
+ while ( (!found) && (interfacesIterator != this->interfaces.end()) ) {
+ std::size_t pos = interfacesIterator->find(interface);
+ found = (pos != std::string::npos);
+ interfacesIterator++;
+ }
+
+ return found;
+}
+
+void GuiSubautomata::newGuiNode ( int id, int idSubautomataSon, float x, float y ) {
+ GuiNode gnode(id, idSubautomataSon, x, y);
+ this->nodeList.push_back(gnode);
+// delete gnode;
+}
+
+// Removes the node with the Goocanvas::Item 'item'
+void GuiSubautomata::removeGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
+ this->removeGuiTransitionsWith(item);
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ bool isInit = nodeListIterator->itIsInitial();
+
+ if (nodeListIterator != this->nodeList.end()) {
+ nodeListIterator = this->nodeList.erase(nodeListIterator);
+
+ if ((!this->nodeList.empty()) && (isInit)) {
+ if (nodeListIterator == this->nodeList.end())
+ this->nodeList.begin()->setAsInitial(true);
+ else
+ nodeListIterator->setAsInitial(true);
+ }
+ }
+}
+
+// Removes the node with the id 'id'
+void GuiSubautomata::removeGuiNode ( int id ) {
+ this->removeGuiTransitionsWith(id);
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->getId() != id) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ bool isInit = nodeListIterator->itIsInitial();
+
+ if (nodeListIterator != this->nodeList.end()) {
+ nodeListIterator = this->nodeList.erase(nodeListIterator);
+
+ if ((!this->nodeList.empty()) && (isInit)) {
+ if (nodeListIterator == this->nodeList.end())
+ this->nodeList.begin()->setAsInitial(true);
+ else
+ nodeListIterator->setAsInitial(true);
+ }
+ }
+}
+
+// Creates a new GuiTransition
+void GuiSubautomata::newGuiTransition ( Point origin, Point final, int id ) {
+ GuiTransition gtransition(origin, final, id);
+ this->transitionList.push_back(gtransition);
+}
+
+void GuiSubautomata::newGuiTransition ( Point origin, Point final, Point midpoint, int id ) {
+ GuiTransition gtransition(origin, final, midpoint, id);
+ this->transitionList.push_back(gtransition);
+}
+
+void GuiSubautomata::removeGuiTransitionsWith ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while (nodeTransIterator != this->transitionList.end()) {
+ if (nodeTransIterator->hasThisItem(item)) {
+ nodeTransIterator = this->transitionList.erase(nodeTransIterator);
+ } else if (nodeTransIterator != this->transitionList.end()) {
+ nodeTransIterator++;
+ }
+ }
+}
+
+void GuiSubautomata::removeGuiTransitionsWith ( int id ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while (nodeTransIterator != this->transitionList.end()) {
+ if ( (nodeTransIterator->getIdOrigin() != id) &&
+ (nodeTransIterator->getIdDestiny() != id) ) {
+ nodeTransIterator = this->transitionList.erase(nodeTransIterator);
+ } else if (nodeTransIterator != this->transitionList.end()) {
+ nodeTransIterator++;
+ }
+ }
+}
+
+GuiSubautomata GuiSubautomata::copy () {
+ std::list<GuiNode> gnodelist;
+ for ( std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ nodeListIterator != this->nodeList.end(); nodeListIterator++ )
+ gnodelist.push_back(nodeListIterator->copy());
+
+ std::list<GuiTransition> gtranslist;
+ for ( std::list<GuiTransition>::iterator transListIterator = this->transitionList.begin();
+ transListIterator != this->transitionList.end(); transListIterator++ )
+ gtranslist.push_back(transListIterator->copy());
+
+ GuiSubautomata gsubautomata(this->id, this->idFather);
+ gsubautomata.setFunctions(std::string(this->functions));
+ gsubautomata.setTime(std::string(this->timing));
+ gsubautomata.setVariables(std::string(this->variables));
+ gsubautomata.setInterfaces(this->interfaces);
+ gsubautomata.setNodeList(&gnodelist);
+ gsubautomata.setTransList(>ranslist);
+
+ std::cout << "hasta aquiiiiiiii???" << std::endl;
+
+ return gsubautomata;
+}
+
+/*************************************************************
+ * METHODS FOR ACCESSING NODES
+ *************************************************************/
+
+ /*************************************************************
+ * SETTERS FOR NODES
+ *************************************************************/
+// Sets the items for a node with the Goocanvas::Item 'item'
+void GuiSubautomata::setGuiNodeItems ( const Glib::RefPtr<Goocanvas::Item>& item,
+ Glib::RefPtr<Goocanvas::Item> selectedItem,
+ Glib::RefPtr<Goocanvas::Item> textItem ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ nodeListIterator->setItems(item, selectedItem, textItem);
+}
+
+void GuiSubautomata::setIdSubautomataSon ( int id, const Glib::RefPtr<Goocanvas::Item>& item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ nodeListIterator->setIdSubautomataSon(id);
+}
+
+void GuiSubautomata::setCodeLastGuiNode ( std::string code ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ nodeListIterator->setCode(code);
+}
+
+void GuiSubautomata::setIsInitialLastGuiNode ( bool isInitial ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ nodeListIterator->setAsInitial(isInitial);
+}
+
+void GuiSubautomata::setNameLastGuiNode ( std::string name ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ nodeListIterator->changeText(name);
+}
+
+/*************************************************************
+ * GETTERS FOR NODES
+ *************************************************************/
+Glib::RefPtr<Goocanvas::EllipseModel> GuiSubautomata::getLastEllipse () {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ return nodeListIterator->getEllipse();
+}
+
+Glib::RefPtr<Goocanvas::EllipseModel> GuiSubautomata::getLastEllipseInit () {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ return nodeListIterator->getEllipseInitial();
+}
+
+Glib::RefPtr<Goocanvas::TextModel> GuiSubautomata::getLastTextNode () {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ return nodeListIterator->getText();
+}
+
+std::string GuiSubautomata::getLastGuiNodeName () {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ return nodeListIterator->getName();
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiSubautomata::getGuiNodeItem ( int id ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (nodeListIterator->getId() != id) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ return nodeListIterator->getItem();
+}
+
+int GuiSubautomata::getGuinodeId ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ return nodeListIterator->getId();
+}
+
+int GuiSubautomata::getFirstIdNode () {
+ return this->nodeList.begin()->getId();
+}
+
+int GuiSubautomata::getIdSubautomataSon ( const Glib::RefPtr<Goocanvas::Item>& item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ return nodeListIterator->getIdSubautomataSon();
+
+ return 0;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS FOR NODES
+ *************************************************************/
+// Changes the node width with the Goocanvas::Item 'item'
+void GuiSubautomata::changeGuiNodeWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ nodeListIterator->changeLineWidth(width);
+}
+
+void GuiSubautomata::checkLastGuiNodeForInitial () {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
+ nodeListIterator--;
+ if (this->nodeList.size() == 1)
+ nodeListIterator->setAsInitial(true);
+ else
+ nodeListIterator->setAsInitial(false);
+}
+
+// Edits the node with the Goocanvas::Item 'item'
+void GuiSubautomata::editGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) && (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end()) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Editing transition" << END_COLOR << std::endl;
+
+ EditNodeDialog* endialog = new EditNodeDialog(&*nodeListIterator);
+ endialog->init();
+ }
+}
+
+// Marks the node with the Goocanvas::Item 'item' as initial
+// If there is another node marked as initial, it first removes that mark
+void GuiSubautomata::markGuiNodeAsInitial ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->itIsInitial()) && (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+ if (nodeListIterator != this->nodeList.end())
+ nodeListIterator->setAsInitial(false);
+
+ nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+ if (nodeListIterator != this->nodeList.end()) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Marked node as initial" << END_COLOR << std::endl;
+
+ nodeListIterator->setAsInitial(true);
+ }
+}
+
+// Moves the node (all its items)
+void GuiSubautomata::moveGuiNode ( const Glib::RefPtr<Goocanvas::Item>& item,
+ double dx, double dy ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ nodeListIterator->moveItems(dx, dy);
+}
+
+// Renames the node with the Goocanvas::Item 'item'
+void GuiSubautomata::renameGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) && (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end()) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Renaming node" << END_COLOR << std::endl;
+
+ RenameDialog* rdialog = new RenameDialog(&*nodeListIterator);
+ rdialog->init();
+ }
+}
+
+/*************************************************************
+ * METHODS FOR ACCESSING TRANSITIONS
+ *************************************************************/
+
+/*************************************************************
+ * SETTERS FOR TRANSITIONS
+ *************************************************************/
+void GuiSubautomata::setGuiTransitionItems ( Glib::RefPtr<Goocanvas::Item> itemTransLeft,
+ Glib::RefPtr<Goocanvas::Item> itemTransRight,
+ const Glib::RefPtr<Goocanvas::Item>& itemMidpoint,
+ Glib::RefPtr<Goocanvas::Item> itemOrigin,
+ Glib::RefPtr<Goocanvas::Item> itemFinal,
+ Glib::RefPtr<Goocanvas::Item> itemText ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ nodeTransIterator->setItems(itemTransLeft, itemTransRight, itemMidpoint,
+ itemOrigin, itemFinal, itemText);
+ nodeTransIterator->setIds(this->getGuinodeId(itemOrigin), this->getGuinodeId(itemFinal));
+}
+
+void GuiSubautomata::setNameLastGuiTransition ( std::string name ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ nodeTransIterator->changeText(name);
+}
+
+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)) &&
+ (nodeTransIterator != this->transitionList.end()) )
+ nodeTransIterator++;
+
+ if (nodeTransIterator != this->transitionList.end())
+ nodeTransIterator->setTrans(type, code);
+}
+
+void GuiSubautomata::setTransLastGuiTransition ( std::string type, std::string code ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ nodeTransIterator->setTrans(type, code);
+}
+
+/*************************************************************
+ * GETTERS FOR TRANSITIONS
+ *************************************************************/
+Glib::RefPtr<Goocanvas::PolylineModel> GuiSubautomata::getLastLeftLine () {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ return nodeTransIterator->getLeftLine();
+}
+
+Glib::RefPtr<Goocanvas::PolylineModel> GuiSubautomata::getLastRightLine () {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ return nodeTransIterator->getRightLine();
+}
+
+Glib::RefPtr<Goocanvas::RectModel> GuiSubautomata::getLastMidpoint () {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ return nodeTransIterator->getMidpoint();
+}
+
+Glib::RefPtr<Goocanvas::TextModel> GuiSubautomata::getLastTextTransition () {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.end();
+ nodeTransIterator--;
+ return nodeTransIterator->getTextModel();
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS FOR TRANSITIONS
+ *************************************************************/
+void GuiSubautomata::changeGuiTransitionWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while ( (!nodeTransIterator->hasThisItem(item)) &&
+ (nodeTransIterator != this->transitionList.end()) )
+ nodeTransIterator++;
+
+ if (nodeTransIterator != this->transitionList.end())
+ nodeTransIterator->changeLineWidth(width);
+}
+
+void GuiSubautomata::editGuiTransition ( 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;
+
+ EditTransitionDialog* etdialog = new EditTransitionDialog(&*nodeTransIterator);
+ etdialog->init();
+ }
+}
+
+// Moves 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();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end()) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while (nodeTransIterator != this->transitionList.end()) {
+ while ( (!nodeTransIterator->hasThisItem(item)) &&
+ (nodeTransIterator != this->transitionList.end())) {
+ nodeTransIterator++;
+ }
+
+ if (nodeTransIterator != this->transitionList.end()) {
+ Point ppoint = this->getPoint(item);
+
+ Point point = ppoint.calculateGoodArrowPosition(this->getPoint(nodeTransIterator->getItemMidpoint()));
+
+ if (nodeTransIterator->isOrigin(item))
+ nodeTransIterator->moveLeftItem(0, point.getX(), point.getY());
+ else
+ nodeTransIterator->moveRightItem(1, point.getX(), point.getY());
+
+ nodeTransIterator++;
+ }
+ }
+ }
+}
+
+void GuiSubautomata::moveJustGuiTransition ( const Glib::RefPtr<Goocanvas::Item>& item,
+ float dx, float dy ) {
+ std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
+ while ( (!nodeTransIterator->hasThisItem(item)) &&
+ (nodeTransIterator != this->transitionList.end()) )
+ nodeTransIterator++;
+
+ if (nodeTransIterator != this->transitionList.end()) {
+ nodeTransIterator->moveMidpoint(dx, dy,
+ this->getPoint(nodeTransIterator->getItemOrigin()),
+ this->getPoint(nodeTransIterator->getItemFinal()));
+ }
+}
+
+void GuiSubautomata::renameGuiTransition ( 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 << "Renaming transition" << END_COLOR << std::endl;
+
+ RenameDialogTransition* rdialog = new RenameDialogTransition(&*nodeTransIterator);
+ rdialog->init();
+ }
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/guisubautomata.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,153 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef GUISUBAUTOMATA_H
+#define GUISUBAUTOMATA_H
+
+#include <list>
+#include <string>
+
+#include "point.h"
+#include "guinode.h"
+#include "guitransition.h"
+#include "popups/editnodedialog.h"
+#include "popups/edittransitiondialog.h"
+#include "popups/renamedialog.h"
+#include "popups/renametransitiondialog.h"
+
+// Definition of this class
+class GuiSubautomata {
+public:
+ // Constructor
+ GuiSubautomata ( int id, int idFather );
+
+ // Destructor
+ virtual ~GuiSubautomata ();
+
+ // Setters
+ void setFunctions ( std::string functions );
+ void setTime ( std::string timing );
+ void setVariables ( std::string variables );
+ void setInterfaces ( std::list<std::string>& interfaces );
+
+ void setNodeList ( std::list<GuiNode>* list );
+ void setTransList ( std::list<GuiTransition>* list );
+
+ // Getters
+ int getId ();
+ int getIdFather ();
+ std::string getFunctions ();
+ std::string getTime ();
+ std::string getVariables ();
+ std::list<std::string>* getInterfaces ();
+ std::list<GuiNode>* getListGuiNodes ();
+ std::list<GuiTransition>* getListGuiTransitions ();
+ std::list<GuiTransition> getAllGuiTransitionsWith ( Glib::RefPtr<Goocanvas::Item> item );
+ std::list<GuiTransition> getAllGuiTransitionsWith ( int id );
+
+ GuiNode* getGuiNode ( Glib::RefPtr<Goocanvas::Item> item );
+ GuiTransition* getGuiTransition ( Glib::RefPtr<Goocanvas::Item> item );
+ Point getPoint ( Glib::RefPtr<Goocanvas::Item> item );
+
+ // Another functions
+ void hideAll ();
+ void showAll ();
+ void removeAll ();
+ bool isNodeListEmpty ();
+ bool findInterface ( std::string interface );
+ void newGuiNode ( int id, int idSubautomataSon, float x, float y );
+ void removeGuiNode ( Glib::RefPtr<Goocanvas::Item> item );
+ void removeGuiNode ( int id );
+ void newGuiTransition ( Point origin, Point final, int id );
+ void newGuiTransition ( Point origin, Point final, Point midpoint, int id );
+ void removeGuiTransitionsWith ( Glib::RefPtr<Goocanvas::Item> item );
+ void removeGuiTransitionsWith ( int id );
+ GuiSubautomata copy ();
+
+ // Methods for accessing nodes
+ // Setters for nodes
+ void setGuiNodeItems ( const Glib::RefPtr<Goocanvas::Item>& item,
+ Glib::RefPtr<Goocanvas::Item> selectedItem,
+ Glib::RefPtr<Goocanvas::Item> textItem );
+ void setIdSubautomataSon ( int id, const Glib::RefPtr<Goocanvas::Item>& item );
+
+ void setCodeLastGuiNode ( std::string code );
+ void setIsInitialLastGuiNode ( bool isInitial );
+ void setNameLastGuiNode ( std::string name );
+
+ // Getters for nodes
+ Glib::RefPtr<Goocanvas::EllipseModel> getLastEllipse ();
+ Glib::RefPtr<Goocanvas::EllipseModel> getLastEllipseInit ();
+ Glib::RefPtr<Goocanvas::TextModel> getLastTextNode ();
+
+ std::string getLastGuiNodeName ();
+ int getLastGuiNodeIdFatherState ();
+
+ Glib::RefPtr<Goocanvas::Item> getGuiNodeItem ( int id );
+ int getGuinodeId ( Glib::RefPtr<Goocanvas::Item> item );
+
+ int getFirstIdNode ();
+
+ int getIdSubautomataSon ( const Glib::RefPtr<Goocanvas::Item>& item );
+
+ // Another functions for nodes
+ void changeGuiNodeWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width );
+ void checkLastGuiNodeForInitial ();
+ void editGuiNode ( Glib::RefPtr<Goocanvas::Item> item );
+ void markGuiNodeAsInitial ( Glib::RefPtr<Goocanvas::Item> item );
+ void moveGuiNode ( const Glib::RefPtr<Goocanvas::Item>& item,
+ double dx, double dy );
+ void renameGuiNode ( Glib::RefPtr<Goocanvas::Item> item );
+
+ // Methods for accessing transitions
+ // Setters for transitions
+ void setGuiTransitionItems ( Glib::RefPtr<Goocanvas::Item> itemTransLeft,
+ Glib::RefPtr<Goocanvas::Item> itemTransRight,
+ const Glib::RefPtr<Goocanvas::Item>& itemMidpoint,
+ Glib::RefPtr<Goocanvas::Item> itemOrigin,
+ Glib::RefPtr<Goocanvas::Item> itemFinal,
+ Glib::RefPtr<Goocanvas::Item> itemText );
+ void setNameLastGuiTransition ( std::string name );
+ void setTransGuiTransition ( Glib::RefPtr<Goocanvas::Item> item, std::string type, std::string code );
+ void setTransLastGuiTransition ( std::string type, std::string code );
+
+ // Getters for transitions
+ Glib::RefPtr<Goocanvas::PolylineModel> getLastLeftLine ();
+ Glib::RefPtr<Goocanvas::PolylineModel> getLastRightLine ();
+ Glib::RefPtr<Goocanvas::RectModel> getLastMidpoint ();
+ Glib::RefPtr<Goocanvas::TextModel> getLastTextTransition ();
+
+ // Another functions for transitions
+ void changeGuiTransitionWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width );
+ void editGuiTransition ( 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 );
+
+private:
+ // Data structure
+ int id, idFather;
+ std::string timing, variables, functions;
+ std::list<std::string> interfaces;
+ std::list<GuiNode> nodeList;
+ std::list<GuiTransition> transitionList;
+}; // Class GuiSubautomata
+
+#endif // GUISUBAUTOMATA_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/guitransition.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guitransition.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/guitransition.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,380 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "guitransition.h"
+
+/*************************************************************
+ * CONSTRUCTORS
+ *************************************************************/
+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.setName(t.getName());
+}
+
+GuiTransition::GuiTransition ( Point porigin, Point pfinal, int id )
+: transition(*(new Transition(id)))
+, point(porigin.midpoint(pfinal)) {
+ Point origin = porigin.calculateGoodArrowPosition(pfinal);
+ Point final = pfinal.calculateGoodArrowPosition(porigin);
+
+ this->leftline = Goocanvas::PolylineModel::create(origin.getX(), origin.getY(),
+ this->point.getX(), this->point.getY());
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->leftline->property_line_width() = LINE_WIDTH;
+ #else
+ this->leftline->set_property("line_width", LINE_WIDTH);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->rightline = Goocanvas::PolylineModel::create(this->point.getX(), this->point.getY(),
+ final.getX(), final.getY());
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->rightline->property_line_width() = LINE_WIDTH;
+ this->rightline->property_arrow_length() = ARROW_LENGTH;
+ this->rightline->property_arrow_tip_length() = ARROW_TIP_LENGTH;
+ this->rightline->property_arrow_width() = ARROW_WIDTH;
+ this->rightline->property_end_arrow() = END_ARROW;
+ #else
+ this->rightline->set_property("line_width", LINE_WIDTH);
+ this->rightline->set_property("arrow_length", ARROW_LENGTH);
+ this->rightline->set_property("arrow_tip_length", ARROW_TIP_LENGTH);
+ this->rightline->set_property("arrow_width", ARROW_WIDTH);
+ this->rightline->set_property("end_arrow", END_ARROW);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->midpoint = Goocanvas::RectModel::create(this->point.getX() - SQUARE_SIDE_MID,
+ this->point.getY() - SQUARE_SIDE_MID,
+ SQUARE_SIDE, SQUARE_SIDE);
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->midpoint->property_line_width() = LINE_WIDTH;
+ this->midpoint->property_fill_color() = ITEM_COLOR_RED;
+ #else
+ this->midpoint->set_property("line_width", LINE_WIDTH);
+ this->midpoint->set_property("fill_color", Glib::ustring(ITEM_COLOR_RED));
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->text = Goocanvas::TextModel::create(
+ ITEM_NAME_TRANSITION,
+ this->point.getX() - ITEM_NAME_TRANSITION.size() * PIXELS_PER_LETTER,
+ this->point.getY() - Y_TRANS_IDEAL, LETTER_WIDTH);
+
+ this->transition.setName(ITEM_NAME_TRANSITION);
+}
+
+GuiTransition::GuiTransition ( Point porigin, Point pfinal, Point pmidpoint, int id )
+: transition(*(new Transition(id)))
+, point(pmidpoint) {
+ Point origin = porigin.calculateGoodArrowPosition(pmidpoint);
+ Point final = pfinal.calculateGoodArrowPosition(pmidpoint);
+
+ this->leftline = Goocanvas::PolylineModel::create(origin.getX(), origin.getY(),
+ pmidpoint.getX(), pmidpoint.getY());
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->leftline->property_line_width() = LINE_WIDTH;
+ #else
+ this->leftline->set_property("line_width", LINE_WIDTH);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->rightline = Goocanvas::PolylineModel::create(pmidpoint.getX(), pmidpoint.getY(),
+ final.getX(), final.getY());
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->rightline->property_line_width() = LINE_WIDTH;
+ this->rightline->property_arrow_length() = ARROW_LENGTH;
+ this->rightline->property_arrow_tip_length() = ARROW_TIP_LENGTH;
+ this->rightline->property_arrow_width() = ARROW_WIDTH;
+ this->rightline->property_end_arrow() = END_ARROW;
+ #else
+ this->rightline->set_property("line_width", LINE_WIDTH);
+ this->rightline->set_property("arrow_length", ARROW_LENGTH);
+ this->rightline->set_property("arrow_tip_length", ARROW_TIP_LENGTH);
+ this->rightline->set_property("arrow_width", ARROW_WIDTH);
+ this->rightline->set_property("end_arrow", END_ARROW);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->midpoint = Goocanvas::RectModel::create(pmidpoint.getX() - SQUARE_SIDE_MID,
+ pmidpoint.getY() - SQUARE_SIDE_MID,
+ SQUARE_SIDE, SQUARE_SIDE);
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->midpoint->property_line_width() = LINE_WIDTH;
+ this->midpoint->property_fill_color() = ITEM_COLOR_RED;
+ #else
+ this->midpoint->set_property("line_width", LINE_WIDTH);
+ this->midpoint->set_property("fill_color", Glib::ustring(ITEM_COLOR_RED));
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->text = Goocanvas::TextModel::create(
+ ITEM_NAME_TRANSITION,
+ pmidpoint.getX() - ITEM_NAME_TRANSITION.size() * PIXELS_PER_LETTER,
+ pmidpoint.getY() - Y_TRANS_IDEAL, LETTER_WIDTH);
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+GuiTransition::~GuiTransition () {
+ if (this->itemTransLeft)
+ this->itemTransLeft->remove();
+
+ if (this->itemTransRight)
+ this->itemTransRight->remove();
+
+ if (this->itemMidpoint)
+ this->itemMidpoint->remove();
+
+ if (this->itemText)
+ this->itemText->remove();
+}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void GuiTransition::setItems ( Glib::RefPtr<Goocanvas::Item> itemTransLeft,
+ Glib::RefPtr<Goocanvas::Item> itemTransRight,
+ Glib::RefPtr<Goocanvas::Item> itemMidpoint,
+ Glib::RefPtr<Goocanvas::Item> itemOrigin,
+ Glib::RefPtr<Goocanvas::Item> itemFinal,
+ Glib::RefPtr<Goocanvas::Item> itemText ) {
+ this->itemTransLeft = itemTransLeft;
+ this->itemTransRight = itemTransRight;
+ this->itemMidpoint = itemMidpoint;
+ this->itemOrigin = itemOrigin;
+ this->itemFinal = itemFinal;
+ this->itemText = itemText;
+}
+
+void GuiTransition::setIds ( int idOrigin, int idDestiny ) {
+ this->transition.setIdOrigin(idOrigin);
+ this->transition.setIdDestiny(idDestiny);
+}
+
+void GuiTransition::setTrans ( std::string type, std::string code ) {
+ this->transition.setTrans(type, code);
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemMidpoint () {
+ return this->itemMidpoint;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemOrigin () {
+ return this->itemOrigin;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemFinal () {
+ return this->itemFinal;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemText () {
+ return this->itemText;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemTransLeft () {
+ return this->itemTransLeft;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getItemTransRight () {
+ return this->itemTransRight;
+}
+
+Glib::RefPtr<Goocanvas::Item> GuiTransition::getTheOther ( Glib::RefPtr<Goocanvas::Item> item ) {
+ if (item == this->itemOrigin)
+ return this->itemFinal;
+ else
+ return this->itemOrigin;
+}
+
+Glib::RefPtr<Goocanvas::PolylineModel> GuiTransition::getLeftLine () {
+ return this->leftline;
+}
+
+Glib::RefPtr<Goocanvas::PolylineModel> GuiTransition::getRightLine () {
+ return this->rightline;
+}
+
+Glib::RefPtr<Goocanvas::RectModel> GuiTransition::getMidpoint () {
+ return this->midpoint;
+}
+
+Glib::RefPtr<Goocanvas::TextModel> GuiTransition::getTextModel () {
+ return this->text;
+}
+
+Point GuiTransition::getPoint () {
+ return this->point;
+}
+
+int GuiTransition::getId () {
+ return this->transition.getId();
+}
+
+int GuiTransition::getIdOrigin () {
+ return this->transition.getIdOrigin();
+}
+
+int GuiTransition::getIdDestiny () {
+ return this->transition.getIdDestiny ();
+}
+
+std::string GuiTransition::getCodeTrans () {
+ return this->transition.getCode();
+}
+
+std::string GuiTransition::getName () {
+ return this->transition.getName();
+}
+
+std::string GuiTransition::getTypeTrans () {
+ return this->transition.getType();
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+bool GuiTransition::hasThisItem ( Glib::RefPtr<Goocanvas::Item> item ) {
+ return ((this->itemMidpoint == item) ||
+ (this->itemOrigin == item) || (this->itemFinal == item));
+}
+
+bool GuiTransition::isOrigin ( Glib::RefPtr<Goocanvas::Item> item ) {
+ return (this->itemOrigin == item);
+}
+
+void GuiTransition::hide () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUIELEM << "Hiding transition" << END_COLOR << std::endl;
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->leftline->property_visibility() = Goocanvas::ITEM_HIDDEN;
+ this->rightline->property_visibility() = Goocanvas::ITEM_HIDDEN;
+ this->midpoint->property_visibility() = Goocanvas::ITEM_HIDDEN;
+ this->text->property_visibility() = Goocanvas::ITEM_HIDDEN;
+ #else
+ this->leftline->set_property("visibility", Goocanvas::ITEM_HIDDEN);
+ this->rightline->set_property("visibility", Goocanvas::ITEM_HIDDEN);
+ this->midpoint->set_property("visibility", Goocanvas::ITEM_HIDDEN);
+ this->text->set_property("visibility", Goocanvas::ITEM_HIDDEN);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiTransition::show () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUIELEM << "Showing transition" << END_COLOR << std::endl;
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->leftline->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ this->rightline->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ this->midpoint->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ this->text->property_visibility() = Goocanvas::ITEM_VISIBLE;
+ #else
+ this->leftline->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ this->rightline->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ this->midpoint->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ this->text->set_property("visibility", Goocanvas::ITEM_VISIBLE);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiTransition::changeLineWidth ( float newLineWidth ) {
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->midpoint->property_line_width() = newLineWidth;
+ #else
+ this->midpoint->set_property("line_width", newLineWidth);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiTransition::changeText ( std::string newText ) {
+ double x;
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ x = this->midpoint->property_x();
+ #else
+ x = this->midpoint->get_property("x");
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ this->transition.setName(newText);
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->text->property_text() = newText;
+ this->text->property_x() = x - newText.size() * PIXELS_PER_LETTER;
+ #else
+ this->text->set_property("text", newText);
+ this->text->set_property("x", x - newText.size() * PIXELS_PER_LETTER);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiTransition::moveLeftItem ( int index, double posx, double posy ) {
+ Goocanvas::Points points;
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ points = this->leftline->property_points();
+ #else
+ points = this->leftline->get_property("points");
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ points.set_coordinate(index, posx, posy);
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->leftline->property_points() = points;
+ #else
+ this->leftline->set_property("points", points);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+void GuiTransition::moveMidpoint ( float dx, float dy, Point leftpoint, Point rightpoint ) {
+ this->midpoint->translate(dx, dy);
+ this->text->translate(dx, dy);
+ this->point.move(dx, dy);
+
+ Point origin = leftpoint.calculateGoodArrowPosition(this->point);
+ Point final = rightpoint.calculateGoodArrowPosition(this->point);
+
+// std::cout << "point.x: " << this->point.getX() << std::endl;
+// std::cout << "point.y: " << this->point.getY() << std::endl;
+
+ this->moveLeftItem(0, origin.getX(), origin.getY());
+ this->moveLeftItem(1, this->point.getX(), this->point.getY());
+
+ this->moveRightItem(0, this->point.getX(), this->point.getY());
+ this->moveRightItem(1, final.getX(), final.getY());
+}
+
+void GuiTransition::moveRightItem ( int index, double posx, double posy ) {
+ Goocanvas::Points points;
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ points = this->rightline->property_points();
+ #else
+ points = this->rightline->get_property("points");
+ #endif //GLIBMM_PROPERTIES_ENABLED
+
+ points.set_coordinate(index, posx, posy);
+
+ #ifdef GLIBMM_PROPERTIES_ENABLED
+ this->rightline->property_points() = points;
+ #else
+ this->rightline->set_property("points", points);
+ #endif //GLIBMM_PROPERTIES_ENABLED
+}
+
+GuiTransition GuiTransition::copy () {
+ GuiTransition gtransition(this->transition.copy(), this->point.copy());
+ gtransition.setItems(this->itemTransLeft, this->itemTransRight, this->itemMidpoint,
+ this->itemOrigin, this->itemFinal, this->itemText);
+
+ return gtransition;
+}
Added: trunk/src/stable/components/visualHFSM/guitransition.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guitransition.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/guitransition.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,104 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef GUITRANSITION_H
+#define GUITRANSITION_H
+
+#include <list>
+
+#include <gtkmm-3.0/gtkmm.h>
+#include <goocanvasmm-2.0/goocanvasmm.h>
+
+#include "common.h"
+#include "point.h"
+#include "transition.h"
+
+// Definition of this class
+class GuiTransition {
+public:
+ // Constructors
+ GuiTransition ( Transition transition, Point p );
+ GuiTransition ( Point porigin, Point pfinal, int id );
+ GuiTransition ( Point porigin, Point pfinal, Point pmidpoint, int id );
+
+ // Destructor
+ virtual ~GuiTransition ();
+
+ // Setters
+ void setItems ( Glib::RefPtr<Goocanvas::Item> itemTransLeft,
+ Glib::RefPtr<Goocanvas::Item> itemTransRight,
+ Glib::RefPtr<Goocanvas::Item> itemMidpoint,
+ Glib::RefPtr<Goocanvas::Item> itemOrigin,
+ Glib::RefPtr<Goocanvas::Item> itemFinal,
+ Glib::RefPtr<Goocanvas::Item> itemText );
+ void setIds ( int idOrigin, int idDestiny );
+ void setTrans ( std::string type, std::string code );
+
+ // Getters
+ Glib::RefPtr<Goocanvas::Item> getItemMidpoint ();
+ Glib::RefPtr<Goocanvas::Item> getItemOrigin ();
+ Glib::RefPtr<Goocanvas::Item> getItemFinal ();
+ Glib::RefPtr<Goocanvas::Item> getItemText ();
+ Glib::RefPtr<Goocanvas::Item> getItemTransLeft ();
+ Glib::RefPtr<Goocanvas::Item> getItemTransRight ();
+ Glib::RefPtr<Goocanvas::Item> getTheOther ( Glib::RefPtr<Goocanvas::Item> item );
+
+ Glib::RefPtr<Goocanvas::PolylineModel> getLeftLine ();
+ Glib::RefPtr<Goocanvas::PolylineModel> getRightLine ();
+
+ Glib::RefPtr<Goocanvas::RectModel> getMidpoint ();
+ Glib::RefPtr<Goocanvas::TextModel> getTextModel ();
+
+ Point getPoint ();
+
+ int getId ();
+ int getIdOrigin ();
+ int getIdDestiny ();
+ std::string getCodeTrans ();
+ std::string getName ();
+ std::string getTypeTrans ();
+
+ // Another functions
+ bool hasThisItem ( Glib::RefPtr<Goocanvas::Item> item );
+ bool isOrigin ( Glib::RefPtr<Goocanvas::Item> item );
+
+ void hide ();
+ void show ();
+
+ void changeLineWidth ( float newLineWidth );
+ void changeText ( std::string newText );
+ void moveLeftItem ( int index, double posx, double posy );
+ void moveMidpoint ( float dx, float dy, Point leftpoint, Point rightpoint );
+ void moveRightItem ( int index, double posx, double posy );
+
+ GuiTransition copy ();
+
+private:
+ // Data structure
+ Glib::RefPtr<Goocanvas::PolylineModel> leftline, rightline;
+ Glib::RefPtr<Goocanvas::RectModel> midpoint;
+ Glib::RefPtr<Goocanvas::TextModel> text;
+ Glib::RefPtr<Goocanvas::Item> itemTransLeft, itemTransRight, itemMidpoint;
+ Glib::RefPtr<Goocanvas::Item> itemOrigin, itemFinal, itemText;
+ Transition transition;
+ Point point;
+}; // Class GuiTransition
+
+#endif // GUITRANSITION_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/main.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/main.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/main.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,30 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "visualhfsm.h"
+#include <gtkmm/application.h>
+
+int main(int argc, char *argv[]) {
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "jderobot.visualhfsm");
+
+ VisualHFSM visualhfsm;
+
+ return app->run(visualhfsm);
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/node.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/node.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/node.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,111 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "node.h"
+
+/*************************************************************
+ * CONSTRUCTORS
+ *************************************************************/
+Node::Node ( bool initial ) {
+ this->initial = initial;
+}
+
+Node::Node ( int id ) {
+ this->id = id;
+}
+
+Node::Node ( int id, bool initial ) {
+ this->id = id;
+ this->initial = initial;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Node::~Node () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void Node::setId ( int id ) {
+ this->id = id;
+}
+
+void Node::setIdSubautomataSon ( int idIdSubautomataSon ) {
+ this->idSubautomataSon = idIdSubautomataSon;
+}
+
+void Node::setInitial ( bool initial ) {
+ this->initial = initial;
+}
+
+void Node::setCode ( std::string code ) {
+ this->code = code;
+}
+
+void Node::setName ( std::string name ) {
+ this->name = name;
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+int Node::getId () {
+ return this->id;
+}
+
+int Node::getIdSubautomataSon () {
+ return this->idSubautomataSon;
+}
+
+bool Node::isInitial () {
+ return this->initial;
+}
+
+std::string Node::getCode () {
+ return this->code;
+}
+
+std::string Node::getName () {
+ return this->name;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+Node Node::copy () {
+ Node newnode(this->id);
+ newnode.setIdSubautomataSon(this->idSubautomataSon);
+ newnode.setInitial(this->initial);
+ newnode.setCode(this->code);
+ newnode.setName(this->name);
+
+ return newnode;
+}
+
+Node Node::copy ( int newid ) {
+ Node newnode(newid);
+ newnode.setIdSubautomataSon(this->idSubautomataSon);
+ newnode.setInitial(this->initial);
+ newnode.setCode(this->code);
+ newnode.setName(this->name);
+
+ return newnode;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/node.h
===================================================================
--- trunk/src/stable/components/visualHFSM/node.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/node.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,64 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef NODE_H
+#define NODE_H
+
+#include <iostream>
+#include <string>
+
+// Definition of this class
+class Node {
+public:
+ // Constructors
+ Node ( bool initial );
+ Node ( int id );
+ Node ( int id, bool initial );
+
+ // Destructor
+ virtual ~Node ();
+
+ // Setters
+ void setId ( int id );
+ void setIdSubautomataSon ( int idSubautomataSon );
+ void setInitial ( bool initial );
+ void setCode ( std::string code );
+ void setName ( std::string name );
+
+ // Getters
+ int getId ();
+ int getIdSubautomataSon ();
+
+ bool isInitial ();
+
+ std::string getCode ();
+ std::string getName ();
+
+ // Another functions
+ Node copy ();
+ Node copy ( int newid );
+private:
+ // Data structure
+ int id, idSubautomataSon;
+ bool initial;
+ std::string name, code;
+}; // Class Node
+
+#endif
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/point.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/point.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/point.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,105 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "point.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+Point::Point ( float x, float y ) {
+ this->x = x;
+ this->y = y;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Point::~Point () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void Point::setX ( float x ) {
+ this->x = x;
+}
+
+void Point::setY ( float y ) {
+ this->y = y;
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+float Point::getX () {
+ return this->x;
+}
+
+float Point::getY () {
+ return this->y;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void Point::move ( float dx, float dy ) {
+ this->x += dx;
+ this->y += dy;
+}
+
+Point Point::calculateGoodArrowPosition ( Point p ) {
+ float distance_op = this->y - p.getY();
+ float distance_ad = this->x - p.getX();
+
+ float alpha = atan(distance_op / distance_ad);
+
+ float possible1_final_x = this->x + RADIUS_NORMAL * cos(alpha);
+ float possible1_final_y = this->y + RADIUS_NORMAL * sin(alpha);
+
+ float distance1 = sqrt(pow(possible1_final_x - p.getX(), 2.0) +
+ pow(possible1_final_y - p.getY(), 2.0));
+
+ float possible2_final_x = this->x - RADIUS_NORMAL * cos(alpha);
+ float possible2_final_y = this->y - RADIUS_NORMAL * sin(alpha);
+
+ float distance2 = sqrt(pow(possible2_final_x - p.getX(), 2.0) +
+ pow(possible2_final_y - p.getY(), 2.0));
+
+ if (distance1 < distance2) {
+ Point p(possible1_final_x, possible1_final_y);
+ return p;
+ } else {
+ Point p(possible2_final_x, possible2_final_y);
+ return p;
+ }
+}
+
+Point Point::midpoint ( Point p ) {
+ Point point((this->x + p.getX()) / 2.0, (this->y + p.getY()) / 2.0);
+ return point;
+}
+
+Point Point::copy () {
+ Point p(this->x, this->y);
+ return p;
+}
+
+Point* Point::copyAsPointer () {
+ return (new Point(this->x, this->y));
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/point.h
===================================================================
--- trunk/src/stable/components/visualHFSM/point.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/point.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,60 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef POINT_H
+#define POINT_H
+
+#include <string>
+#include <iostream>
+#include <math.h>
+
+#include "common.h"
+
+// Definition of this class
+class Point {
+public:
+ // Constructor
+ Point ( float x, float y );
+
+ // Destructor
+ ~Point ();
+
+ // Setters
+ void setX ( float x );
+ void setY ( float y );
+
+ // Getters
+ float getX ();
+ float getY ();
+
+ // Another functions
+ void move ( float dx, float dy );
+
+ Point calculateGoodArrowPosition ( Point p );
+ Point midpoint ( Point p );
+
+ Point copy ();
+ Point* copyAsPointer ();
+
+private:
+ float x, y;
+};
+
+#endif // POINT_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/editnodedialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/editnodedialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/editnodedialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,84 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "editnodedialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+EditNodeDialog::EditNodeDialog ( GuiNode* gnode ) {
+ this->gnode = gnode;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+EditNodeDialog::~EditNodeDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void EditNodeDialog::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/code.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->gnode->getCode());
+ this->textview->set_buffer(textbuffer);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &EditNodeDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &EditNodeDialog::on_button_cancel));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void EditNodeDialog::on_button_accept () {
+ this->gnode->setCode(this->textview->get_buffer()->get_text());
+ delete this->dialog;
+}
+
+void EditNodeDialog::on_button_cancel () {
+ delete this->dialog;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/editnodedialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/editnodedialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/editnodedialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,57 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef EDITNODEDIALOG_H
+#define EDITNODEDIALOG_H
+
+#include <string>
+#include <iostream>
+
+#include <gtkmm-3.0/gtkmm.h>
+
+#include "../guinode.h"
+
+// Definition of this class
+class EditNodeDialog {
+public:
+ // Constructor
+ EditNodeDialog ( GuiNode* gnode );
+
+ // Destructor
+ virtual ~EditNodeDialog ();
+
+ // Popup initializer
+ void init ();
+
+private:
+ // Data structure
+ GuiNode* gnode;
+ 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 // EDITNODEDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,139 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "edittransitiondialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+EditTransitionDialog::EditTransitionDialog ( GuiTransition* gtransition ) {
+ this->gtransition = gtransition;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+EditTransitionDialog::~EditTransitionDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void EditTransitionDialog::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/edittransition.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_edittransition", this->dialog);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+ refBuilder->get_widget("entry_text", this->entry_text);
+ refBuilder->get_widget("label_frame", this->label_frame);
+ refBuilder->get_widget("radiobutton_temporal", this->radiobutton_temporal);
+ refBuilder->get_widget("radiobutton_conditional", this->radiobutton_conditional);
+
+ Gtk::RadioButton::Group group = this->radiobutton_temporal->get_group();
+ this->radiobutton_conditional->set_group(group);
+
+ this->radiobutton_temporal->signal_clicked().connect(sigc::mem_fun(this,
+ &EditTransitionDialog::on_radio_temporal_clicked));
+ this->radiobutton_conditional->signal_clicked().connect(sigc::mem_fun(this,
+ &EditTransitionDialog::on_radio_conditional_clicked));
+
+ if (this->gtransition->getTypeTrans().compare("condition") == 0) {
+ this->on_radio_conditional_clicked();
+ this->radiobutton_conditional->set_active();
+ } else {
+ this->on_radio_temporal_clicked();
+ this->radiobutton_temporal->set_active();
+ }
+
+ this->entry_text->set_text(this->gtransition->getCodeTrans());
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &EditTransitionDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &EditTransitionDialog::on_button_cancel));
+
+ this->dialog->add_events(Gdk::KEY_PRESS_MASK);
+ this->dialog->signal_key_release_event().connect(sigc::mem_fun(this,
+ &EditTransitionDialog::on_key_released));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void EditTransitionDialog::on_radio_temporal_clicked () {
+ Glib::ustring str ("Time (ms):");
+ this->putTextOnLabel(str);
+ if (this->gtransition->getTypeTrans().compare("time") == 0)
+ this->entry_text->set_text(this->gtransition->getCodeTrans());
+ else
+ this->entry_text->set_text("");
+}
+
+void EditTransitionDialog::on_radio_conditional_clicked () {
+ Glib::ustring str ("Condition:");
+ this->putTextOnLabel(str);
+ if (this->gtransition->getTypeTrans().compare("condition") == 0)
+ this->entry_text->set_text(this->gtransition->getCodeTrans());
+ else
+ this->entry_text->set_text("");
+}
+
+void EditTransitionDialog::on_button_accept () {
+ if (this->radiobutton_conditional->get_active())
+ this->gtransition->setTrans("condition", this->entry_text->get_text());
+ else
+ this->gtransition->setTrans("time", this->entry_text->get_text());
+
+ delete this->dialog;
+}
+
+void EditTransitionDialog::on_button_cancel () {
+ delete this->dialog;
+}
+
+bool EditTransitionDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
+
+void EditTransitionDialog::putTextOnLabel ( const Glib::ustring& text ) {
+ this->label_frame->set_text(text);
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/edittransitiondialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,64 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef EDITTRANSITIONDIALOG_H
+#define EDITTRANSITIONDIALOG_H
+
+#include <string>
+#include <iostream>
+
+#include <gtkmm-3.0/gtkmm.h>
+
+#include "../guitransition.h"
+
+// Definition of this class
+class EditTransitionDialog {
+public:
+ // Constructor
+ EditTransitionDialog ( GuiTransition* gtransition );
+
+ // Destructor
+ virtual ~EditTransitionDialog ();
+
+ // Popup initializer
+ void init ();
+
+private:
+ // Data structure
+ GuiTransition* gtransition;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+
+ Gtk::Entry* entry_text;
+ Gtk::Label* label_frame;
+ Gtk::RadioButton *radiobutton_temporal, *radiobutton_conditional;
+
+ // Private methods
+ void on_radio_temporal_clicked ();
+ void on_radio_conditional_clicked ();
+ void on_button_accept ();
+ void on_button_cancel ();
+ bool on_key_released ( GdkEventKey* event );
+
+ void putTextOnLabel ( const Glib::ustring& text );
+};
+
+#endif // EDITTRANSITIONDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/funvardialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/funvardialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/funvardialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,92 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "funvardialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+FunVarDialog::FunVarDialog ( GuiSubautomata* gsubautomata ) {
+ this->gsubautomata = gsubautomata;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+FunVarDialog::~FunVarDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void FunVarDialog::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/funvar.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_funvar", this->dialog);
+
+ refBuilder->get_widget("textview_functions", this->textview_functions);
+ refBuilder->get_widget("textview_variables", this->textview_variables);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+
+ Glib::RefPtr<Gtk::TextBuffer> textbufferFunctions = Gtk::TextBuffer::create();
+ textbufferFunctions->set_text(this->gsubautomata->getFunctions());
+ this->textview_functions->set_buffer(textbufferFunctions);
+
+ Glib::RefPtr<Gtk::TextBuffer> textbufferVariables = Gtk::TextBuffer::create();
+ textbufferVariables->set_text(this->gsubautomata->getVariables());
+ this->textview_variables->set_buffer(textbufferVariables);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &FunVarDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &FunVarDialog::on_button_cancel));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void FunVarDialog::on_button_accept () {
+ this->gsubautomata->setVariables(this->textview_variables->get_buffer()->get_text());
+ this->gsubautomata->setFunctions(this->textview_functions->get_buffer()->get_text());
+ delete this->dialog;
+}
+
+void FunVarDialog::on_button_cancel () {
+ delete this->dialog;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/funvardialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/funvardialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/funvardialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,51 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef FUNVARDIALOG_H
+#define FUNVARDIALOG_H
+
+#include "../guisubautomata.h"
+
+// Definition of this class
+class FunVarDialog {
+public:
+ // Constructor
+ FunVarDialog ( GuiSubautomata* gsubautomata );
+
+ // Destructor
+ virtual ~FunVarDialog ();
+
+ // Popup initializer
+ void init ();
+
+private:
+ // Data structure
+ GuiSubautomata* gsubautomata;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+ Gtk::TextView *textview_variables, *textview_functions;
+
+ // Private methods
+ void on_button_accept ();
+ void on_button_cancel ();
+};
+
+#endif // FUNVARDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/importdialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/importdialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/importdialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,130 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "importdialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+ImportDialog::ImportDialog ( GuiSubautomata* gsubautomata ) {
+ this->gsubautomata = gsubautomata;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+ImportDialog::~ImportDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void ImportDialog::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/import.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_import", this->dialog);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+
+ refBuilder->get_widget("checkbutton_laser", this->checkbutton_laser);
+ refBuilder->get_widget("checkbutton_sonar", this->checkbutton_sonar);
+ refBuilder->get_widget("checkbutton_camera", this->checkbutton_camera);
+ refBuilder->get_widget("checkbutton_pose3dencoders", this->checkbutton_pose3dencoders);
+ refBuilder->get_widget("checkbutton_pose3dmotors", this->checkbutton_pose3dmotors);
+
+ if (gsubautomata->findInterface(std::string("laser")))
+ this->checkbutton_laser->set_active(true);
+
+ if (gsubautomata->findInterface(std::string("sonar")))
+ this->checkbutton_sonar->set_active(true);
+
+ if (gsubautomata->findInterface(std::string("camera")))
+ this->checkbutton_camera->set_active(true);
+
+ if (gsubautomata->findInterface(std::string("pose3dencoders")))
+ this->checkbutton_pose3dencoders->set_active(true);
+
+ if (gsubautomata->findInterface(std::string("pose3dmotors")))
+ this->checkbutton_pose3dmotors->set_active(true);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &ImportDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &ImportDialog::on_button_cancel));
+
+ this->dialog->add_events(Gdk::KEY_PRESS_MASK);
+ this->dialog->signal_key_release_event().connect(sigc::mem_fun(this,
+ &ImportDialog::on_key_released));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void ImportDialog::on_button_accept () {
+ std::list<std::string> listInterfaces;
+
+ if (this->checkbutton_laser->get_active())
+ listInterfaces.push_back(std::string("<jderobot/laser.h>"));
+
+ if (this->checkbutton_sonar->get_active())
+ listInterfaces.push_back(std::string("<jderobot/sonar.h>"));
+
+ if (this->checkbutton_camera->get_active())
+ listInterfaces.push_back(std::string("<jderobot/camera.h>"));
+
+ if (this->checkbutton_pose3dencoders->get_active())
+ listInterfaces.push_back(std::string("<jderobot/pose3dencoders.h>"));
+
+ if (this->checkbutton_pose3dmotors->get_active())
+ listInterfaces.push_back(std::string("<jderobot/pose3dmotors.h>"));
+
+ this->gsubautomata->setInterfaces(listInterfaces);
+
+ delete this->dialog;
+}
+
+void ImportDialog::on_button_cancel () {
+ delete this->dialog;
+}
+
+bool ImportDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/importdialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/importdialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/importdialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,53 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef IMPORTDIALOG_H
+#define IMPORTDIALOG_H
+
+#include "../guisubautomata.h"
+
+// Definition of this class
+class ImportDialog {
+public:
+ // Constructor
+ ImportDialog ( GuiSubautomata* gsubautomata );
+
+ // Destructor
+ virtual ~ImportDialog ();
+
+ // Popup initializer
+ void init ();
+
+protected:
+ // Data structure
+ GuiSubautomata* gsubautomata;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+ Gtk::CheckButton *checkbutton_laser, *checkbutton_sonar, *checkbutton_camera;
+ Gtk::CheckButton *checkbutton_pose3dencoders, *checkbutton_pose3dmotors;
+
+ // Private methods
+ void on_button_accept ();
+ void on_button_cancel ();
+ bool on_key_released ( GdkEventKey* event );
+};
+
+#endif // IMPORTDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/loadfiledialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/loadfiledialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/loadfiledialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,103 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "loadfiledialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+LoadFileDialog::LoadFileDialog () {}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+LoadFileDialog::~LoadFileDialog () {
+
+}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void LoadFileDialog::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/open.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("filechooserdialog", this->filechooserdialog);
+
+ refBuilder->get_widget("button_open", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &LoadFileDialog::on_button_accept));
+
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &LoadFileDialog::on_button_cancel));
+
+ Glib::RefPtr<Gtk::FileFilter> filter_xml = Gtk::FileFilter::create();
+ filter_xml->set_name("VisualHFSM files");
+ filter_xml->add_mime_type("text/xml");
+ this->filechooserdialog->add_filter(filter_xml);
+
+ Glib::RefPtr<Gtk::FileFilter> filter_any = Gtk::FileFilter::create();
+ filter_any->set_name("Any files");
+ filter_any->add_pattern("*");
+ this->filechooserdialog->add_filter(filter_any);
+
+ this->filechooserdialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void LoadFileDialog::on_button_accept () {
+ this->filepath = this->filechooserdialog->get_filename();
+ delete this->filechooserdialog;
+ this->m_signal.emit(this->filepath);
+}
+
+void LoadFileDialog::on_button_cancel () {
+ delete this->filechooserdialog;
+}
+
+bool LoadFileDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
+
+LoadFileDialog::type_signal LoadFileDialog::signal_path() {
+ return m_signal;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/loadfiledialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/loadfiledialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/loadfiledialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,62 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef LOADFILEDIALOG_H
+#define LOADFILEDIALOG_H
+
+#include <iostream>
+#include <stdio.h>
+#include <gtkmm-3.0/gtkmm.h>
+#include <sigc++/sigc++.h>
+
+#include "../common.h"
+
+// Definition of this class
+class LoadFileDialog {
+public:
+ // Constructor
+ LoadFileDialog ();
+
+ // Destructor
+ virtual ~LoadFileDialog ();
+
+ // Popup initializer
+ void init ();
+
+ //signal accessor:
+ typedef sigc::signal<void, std::string> type_signal;
+ type_signal signal_path ();
+
+protected:
+ // Data structure
+ Gtk::FileChooserDialog* filechooserdialog;
+ Gtk::Button *button_accept, *button_cancel;
+ Gtk::Entry* entry_text;
+ std::string filepath;
+
+ // Private methods
+ void on_button_accept ();
+ bool on_key_released ( GdkEventKey* event );
+ void on_button_cancel ();
+
+ type_signal m_signal;
+};
+
+#endif // LOADFILEDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,92 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "renamedialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+RenameDialog::RenameDialog ( GuiNode* gnode ) {
+ this->gnode = gnode;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+RenameDialog::~RenameDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void RenameDialog::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/name.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_name", this->dialog);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+ refBuilder->get_widget("entry_text", this->entry_text);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &RenameDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &RenameDialog::on_button_cancel));
+
+ this->dialog->add_events(Gdk::KEY_PRESS_MASK);
+ this->dialog->signal_key_release_event().connect(sigc::mem_fun(this,
+ &RenameDialog::on_key_released));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void RenameDialog::on_button_accept () {
+ this->gnode->changeText(this->entry_text->get_text());
+ delete this->dialog;
+}
+
+void RenameDialog::on_button_cancel () {
+ delete this->dialog;
+}
+
+bool RenameDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/renamedialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renamedialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/renamedialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,52 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef RENAMEDIALOG_H
+#define RENAMEDIALOG_H
+
+#include "../guinode.h"
+
+// Definition of this class
+class RenameDialog {
+public:
+ // Constructor
+ RenameDialog ( GuiNode* gnode );
+
+ // Destructor
+ virtual ~RenameDialog ();
+
+ // Popup initializer
+ void init ();
+
+protected:
+ // Data structure
+ GuiNode* gnode;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+ Gtk::Entry* entry_text;
+
+ // Private methods
+ void on_button_accept ();
+ void on_button_cancel ();
+ bool on_key_released ( GdkEventKey* event );
+};
+
+#endif // RENAMEDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,92 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "renametransitiondialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+RenameDialogTransition::RenameDialogTransition ( GuiTransition* gtransition ) {
+ this->gtransition = gtransition;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+RenameDialogTransition::~RenameDialogTransition () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void RenameDialogTransition::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/name.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_name", this->dialog);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+ refBuilder->get_widget("entry_text", this->entry_text);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &RenameDialogTransition::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &RenameDialogTransition::on_button_cancel));
+
+ this->dialog->add_events(Gdk::KEY_PRESS_MASK);
+ this->dialog->signal_key_release_event().connect(sigc::mem_fun(this,
+ &RenameDialogTransition::on_key_released));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void RenameDialogTransition::on_button_accept () {
+ this->gtransition->changeText(this->entry_text->get_text());
+ delete this->dialog;
+}
+
+void RenameDialogTransition::on_button_cancel () {
+ delete this->dialog;
+}
+
+bool RenameDialogTransition::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/renametransitiondialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,52 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef RENAMEDIALOGTRANSITION_H
+#define RENAMEDIALOGTRANSITION_H
+
+#include "../guitransition.h"
+
+// Definition of this class
+class RenameDialogTransition {
+public:
+ // Constructor
+ RenameDialogTransition ( GuiTransition* gtransition );
+
+ // Destructor
+ virtual ~RenameDialogTransition ();
+
+ // Popup initializer
+ void init ();
+
+protected:
+ // Data structure
+ GuiTransition* gtransition;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+ Gtk::Entry* entry_text;
+
+ // Private methods
+ void on_button_accept ();
+ void on_button_cancel ();
+ bool on_key_released ( GdkEventKey* event );
+};
+
+#endif // RENAMEDIALOGTRANSITION_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/savefiledialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/savefiledialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/savefiledialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,106 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "savefiledialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+SaveFileDialog::SaveFileDialog () {}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+SaveFileDialog::~SaveFileDialog () {
+
+}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void SaveFileDialog::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/save.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("filechooserdialog", this->filechooserdialog);
+
+ refBuilder->get_widget("button_save", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &SaveFileDialog::on_button_accept));
+
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &SaveFileDialog::on_button_cancel));
+
+ Glib::RefPtr<Gtk::FileFilter> filter_xml = Gtk::FileFilter::create();
+ filter_xml->set_name("VisualHFSM files");
+ filter_xml->add_mime_type("text/xml");
+ this->filechooserdialog->add_filter(filter_xml);
+
+ Glib::RefPtr<Gtk::FileFilter> filter_any = Gtk::FileFilter::create();
+ filter_any->set_name("Any files");
+ filter_any->add_pattern("*");
+ this->filechooserdialog->add_filter(filter_any);
+
+ this->filechooserdialog->show_now();
+ }
+}
+
+/*************************************************************
+ * SIGNAL ACCESSOR
+ *************************************************************/
+SaveFileDialog::type_signal SaveFileDialog::signal_path () {
+ return m_signal;
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void SaveFileDialog::on_button_accept () {
+ this->filepath = this->filechooserdialog->get_filename();
+ delete this->filechooserdialog;
+ this->m_signal.emit(this->filepath);
+}
+
+void SaveFileDialog::on_button_cancel () {
+ delete this->filechooserdialog;
+}
+
+bool SaveFileDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/savefiledialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/savefiledialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/savefiledialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,62 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef SAVEFILEDIALOG_H
+#define SAVEFILEDIALOG_H
+
+#include <iostream>
+#include <stdio.h>
+#include <gtkmm-3.0/gtkmm.h>
+#include <sigc++/sigc++.h>
+
+#include "../common.h"
+
+// Definition of this class
+class SaveFileDialog {
+public:
+ // Constructor
+ SaveFileDialog ();
+
+ // Destructor
+ virtual ~SaveFileDialog ();
+
+ // Popup initializer
+ void init ();
+
+ // Signal accessor
+ typedef sigc::signal<void, std::string> type_signal;
+ type_signal signal_path ();
+
+protected:
+ // Data structure
+ Gtk::FileChooserDialog* filechooserdialog;
+ Gtk::Button *button_accept, *button_cancel;
+ Gtk::Entry* entry_text;
+ std::string filepath;
+
+ // Private methods
+ void on_button_accept ();
+ bool on_key_released ( GdkEventKey* event );
+ void on_button_cancel ();
+
+ type_signal m_signal;
+};
+
+#endif // SAVEFILEDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/timerdialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/timerdialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/timerdialog.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,94 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "timerdialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+TimerDialog::TimerDialog ( GuiSubautomata* gsubautomata ) {
+ this->gsubautomata = gsubautomata;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+TimerDialog::~TimerDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void TimerDialog::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/timing.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_timing", this->dialog);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+ refBuilder->get_widget("entry_time", this->entry_text);
+
+ this->entry_text->set_text(Glib::ustring(this->gsubautomata->getTime()));
+
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &TimerDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &TimerDialog::on_button_cancel));
+
+ this->dialog->add_events(Gdk::KEY_PRESS_MASK);
+ this->dialog->signal_key_release_event().connect(sigc::mem_fun(this,
+ &TimerDialog::on_key_released));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void TimerDialog::on_button_accept () {
+ this->gsubautomata->setTime(this->entry_text->get_text());
+ delete this->dialog;
+}
+
+void TimerDialog::on_button_cancel () {
+ delete this->dialog;
+}
+
+bool TimerDialog::on_key_released ( GdkEventKey* event ) {
+ if (event->keyval == GDK_KEY_Return)
+ this->on_button_accept();
+
+ return true;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/timerdialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/timerdialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/timerdialog.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,52 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef TIMERDIALOG_H
+#define TIMERDIALOG_H
+
+#include "../guisubautomata.h"
+
+// Definition of this class
+class TimerDialog {
+public:
+ // Constructor
+ TimerDialog ( GuiSubautomata* gsubautomata );
+
+ // Destructor
+ virtual ~TimerDialog ();
+
+ // Popup initializer
+ void init ();
+
+protected:
+ // Data structure
+ GuiSubautomata* gsubautomata;
+ Gtk::Dialog* dialog;
+ Gtk::Button* button_accept;
+ Gtk::Button* button_cancel;
+ Gtk::Entry* entry_text;
+
+ // Private methods
+ void on_button_accept ();
+ bool on_key_released ( GdkEventKey* event );
+ void on_button_cancel ();
+};
+
+#endif // TIMERDIALOG_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/savefile.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/savefile.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/savefile.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,159 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "savefile.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+SaveFile::SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList ) {
+ this->filepath = std::string(filepath);
+ this->subautomataList = subautomataList;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+SaveFile::~SaveFile () {}
+
+/*************************************************************
+ * INITIALIZER
+ *************************************************************/
+void SaveFile::init () {
+// std::locale::global(std::locale(""));
+
+ #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ try {
+ #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
+
+ xmlpp::Document document;
+ xmlpp::Element* nodeRoot = document.create_root_node("VisualHFSM", "", "");
+
+ for ( std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList->begin();
+ subListIterator != this->subautomataList->end(); subListIterator++ ) { // for every subautomata
+ xmlpp::Element* nodeSubautomata = nodeRoot->add_child("SubAutomata");
+
+ std::stringstream ss;
+ ss << subListIterator->getId();
+ nodeSubautomata->set_attribute("id", ss.str());
+
+ ss.str(std::string());
+ ss << subListIterator->getIdFather();
+ nodeSubautomata->set_attribute("idFather", ss.str());
+
+ std::list<GuiNode>* listGuiNodes = subListIterator->getListGuiNodes();
+ for ( std::list<GuiNode>::iterator guiNodesIterator = listGuiNodes->begin();
+ guiNodesIterator != listGuiNodes->end(); guiNodesIterator++ ) {
+ xmlpp::Element* nodeState = nodeSubautomata->add_child("state");
+
+ if (guiNodesIterator->itIsInitial())
+ nodeState->set_attribute("initial", "true");
+ else
+ nodeState->set_attribute("initial", "false");
+
+ ss.str(std::string());
+ ss << guiNodesIterator->getId();
+ nodeState->set_attribute("id", ss.str());
+
+ Point point = guiNodesIterator->getPoint();
+ ss.str(std::string());
+ ss << point.getX();
+ xmlpp::Element* nodeStateChild = nodeState->add_child("posx");
+ nodeStateChild->set_child_text(ss.str());
+ ss.str(std::string());
+ ss << point.getY();
+ nodeStateChild = nodeState->add_child("posy");
+ nodeStateChild->set_child_text(ss.str());
+
+ nodeStateChild = nodeState->add_child("name");
+ nodeStateChild->set_child_text(guiNodesIterator->getName());
+
+ ss.str(std::string());
+ ss << guiNodesIterator->getIdSubautomataSon();
+ nodeStateChild = nodeState->add_child("idSubautomataSon");
+ nodeStateChild->set_child_text(ss.str());
+
+ nodeStateChild = nodeState->add_child("code");
+ nodeStateChild->set_child_text(guiNodesIterator->getCode());
+ }
+
+ std::list<GuiTransition>* listGuiTransition = subListIterator->getListGuiTransitions();
+ for ( std::list<GuiTransition>::iterator guiTransIterator = listGuiTransition->begin();
+ guiTransIterator != listGuiTransition->end(); guiTransIterator++ ) {
+ xmlpp::Element* nodeTransition = nodeSubautomata->add_child("transition");
+
+ ss.str(std::string());
+ ss << guiTransIterator->getId();
+ nodeTransition->set_attribute("id", ss.str());
+
+ Point point = guiTransIterator->getPoint();
+ ss.str(std::string());
+ ss << point.getX();
+ xmlpp::Element* nodeTransChild = nodeTransition->add_child("posx");
+ nodeTransChild->set_child_text(ss.str());
+ ss.str(std::string());
+ ss << point.getY();
+ nodeTransChild = nodeTransition->add_child("posy");
+ nodeTransChild->set_child_text(ss.str());
+
+ ss.str(std::string());
+ ss << guiTransIterator->getIdOrigin();
+ nodeTransChild = nodeTransition->add_child("origin");
+ nodeTransChild->set_child_text(ss.str());
+
+ ss.str(std::string());
+ ss << guiTransIterator->getIdDestiny();
+ nodeTransChild = nodeTransition->add_child("destiny");
+ nodeTransChild->set_child_text(ss.str());
+
+ nodeTransChild = nodeTransition->add_child("name");
+ nodeTransChild->set_child_text(guiTransIterator->getName());
+
+ nodeTransChild = nodeTransition->add_child("trans");
+ nodeTransChild->set_attribute("type", guiTransIterator->getTypeTrans());
+ nodeTransChild->set_child_text(guiTransIterator->getCodeTrans());
+ }
+
+ xmlpp::Element* nodeLibs = nodeSubautomata->add_child("libraries");
+ std::list<std::string>* listLibs = subListIterator->getInterfaces();
+ for ( std::list<std::string>::iterator listLibsIterator = listLibs->begin();
+ listLibsIterator != listLibs->end(); listLibsIterator++ ) {
+ xmlpp::Element* nodelib = nodeLibs->add_child("lib");
+ nodelib->set_child_text(*listLibsIterator);
+ }
+
+ xmlpp::Element* nodeTiming = nodeSubautomata->add_child("iteration_time");
+ nodeTiming->set_child_text(subListIterator->getTime());
+
+ xmlpp::Element* nodeVariables = nodeSubautomata->add_child("variables");
+ nodeVariables->set_child_text(subListIterator->getVariables());
+
+ xmlpp::Element* nodeFunctions = nodeSubautomata->add_child("functions");
+ nodeFunctions->set_child_text(subListIterator->getFunctions());
+ }
+
+ document.write_to_file(this->filepath, "UTF-8");
+
+ #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ } catch ( const std::exception& ex ) {
+ std::cout << "Exception caught: " << ex.what() << std::endl;
+ }
+ #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/savefile.h
===================================================================
--- trunk/src/stable/components/visualHFSM/savefile.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/savefile.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,46 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef SAVEFILE_H
+#define SAVEFILE_H
+
+#include <libxml++/libxml++.h>
+
+#include "guisubautomata.h"
+
+// Definition of this class
+class SaveFile {
+public:
+ // Constructor
+ SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList );
+
+ // Destructor
+ virtual ~SaveFile ();
+
+ // Initializer
+ void init ();
+
+private:
+ // Data structure
+ std::string filepath;
+ std::list<GuiSubautomata>* subautomataList;
+};
+
+#endif // SAVEFILE_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/subautomata.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/subautomata.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/subautomata.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,144 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "subautomata.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+SubAutomata::SubAutomata ( int id, int idFather ) {
+ this->id = id;
+ this->idFather = idFather;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+SubAutomata::~SubAutomata () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void SubAutomata::setNodePoint ( int id, Point* p ) {
+ this->mapNodePoint[id] = p;
+}
+
+void SubAutomata::setTransPoint ( int id, Point* p ) {
+ this->mapTransPoint[id] = p;
+}
+
+void SubAutomata::setFunctions ( std::string functions ) {
+ this->functions = functions;
+}
+
+void SubAutomata::setTime ( std::string timing ) {
+ this->timing = timing;
+}
+
+void SubAutomata::setVariables ( std::string variables ) {
+ this->variables = variables;
+}
+
+void SubAutomata::setInterfaces ( std::list<std::string>& interfaces ) {
+ this->interfaces = interfaces;
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+int SubAutomata::getId () {
+ return this->id;
+}
+
+int SubAutomata::getIdFather () {
+ return this->idFather;
+}
+
+std::string SubAutomata::getFunctions () {
+ return this->functions;
+}
+
+std::string SubAutomata::getNodeName ( int id ) {
+ std::string name = std::string();
+ std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ while ( (nodeListIterator->getId() != id) &&
+ (nodeListIterator != nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != nodeList.end())
+ name = nodeListIterator->getName();
+
+ return name;
+}
+
+std::string SubAutomata::getTime () {
+ return this->timing;
+}
+
+std::string SubAutomata::getVariables () {
+ return this->variables;
+}
+
+std::list<std::string>* SubAutomata::getInterfaces () {
+ return &this->interfaces;
+}
+
+std::list<Node> SubAutomata::getNodeList () {
+ return this->nodeList;
+}
+
+std::list<Transition> SubAutomata::getTransList () {
+ return this->transitionList;
+}
+
+Point* SubAutomata::getNodePoint ( int id ) {
+ std::map<int, Point*>::iterator itmap = this->mapNodePoint.begin();
+ while (itmap != this->mapNodePoint.end()) {
+ if (itmap->first == id)
+ return itmap->second;
+ itmap++;
+ }
+
+ return NULL;
+}
+
+Point* SubAutomata::getTransPoint ( int id ) {
+ std::map<int, Point*>::iterator itmap = this->mapTransPoint.begin();
+ while (itmap != this->mapNodePoint.end()) {
+ if (itmap->first == id)
+ return itmap->second;
+ itmap++;
+ }
+
+ return NULL;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+void SubAutomata::addNode ( Node n, Point* p ) {
+ this->nodeList.push_back(n);
+ this->mapNodePoint[n.getId()] = p;
+}
+
+void SubAutomata::addTransition ( Transition trans, Point* p ) {
+ this->transitionList.push_back(trans);
+ this->mapTransPoint[trans.getId()] = p;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/subautomata.h
===================================================================
--- trunk/src/stable/components/visualHFSM/subautomata.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/subautomata.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,80 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef SUBAUTOMATA_H
+#define SUBAUTOMATA_H
+
+#include <list>
+#include <map>
+#include <iostream>
+#include <string>
+
+#include "node.h"
+#include "transition.h"
+#include "point.h"
+
+// Definition of this class
+class SubAutomata {
+public:
+ // Constructor
+ SubAutomata ( int id, int idFather );
+
+ // Destructor
+ virtual ~SubAutomata ();
+
+ // Setters
+ void setNodePoint ( int id, Point* p );
+ void setTransPoint ( int id, Point* p );
+
+ void setFunctions ( std::string functions );
+ void setTime ( std::string timing );
+ void setVariables ( std::string variables );
+ void setInterfaces ( std::list<std::string>& interfaces );
+
+ // Getters
+ int getId ();
+ int getIdFather ();
+
+ std::string getFunctions ();
+ std::string getNodeName ( int id );
+ std::string getTime ();
+ std::string getVariables ();
+ std::list<std::string>* getInterfaces ();
+
+ std::list<Node> getNodeList ();
+ std::list<Transition> getTransList ();
+
+ Point* getNodePoint ( int id );
+ Point* getTransPoint ( int id );
+
+ // Another functions
+ void addNode ( Node n, Point* p );
+ void addTransition ( Transition trans, Point* p );
+private:
+ // Data structure
+ int id, idFather;
+ std::map<int, Point*> mapNodePoint, mapTransPoint;
+ std::list<Node> nodeList;
+ std::list<Transition> transitionList;
+ std::string timing, variables, functions;
+ std::list<std::string> interfaces;
+}; // Class SubAutomata
+
+#endif // SUBAUTOMATA_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/tipos.h
===================================================================
--- trunk/src/stable/components/visualHFSM/tipos.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/tipos.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,100 @@
+#ifndef TIPOS_H
+#define TIPOS_H
+
+#include <libgnomecanvas/libgnomecanvas.h>
+#include <list>
+#include <string>
+using namespace std;
+
+typedef struct punto {
+ double x;
+ double y;
+} punto;
+
+typedef struct recta {
+ double A;
+ double B;
+ double C;
+} recta;
+
+
+typedef struct tipoNodo {
+
+ GnomeCanvasItem * item;
+ GnomeCanvasItem * estado_inicial;
+// int origenX, origenY; // Punto (x,y) donde se dibujara en el canvas
+// int destinoX, destinoY; // Punto (x,y) donde se dibujara en el canvas
+ string nombre; // Nombre del nodo. "" por defecto
+ string codigo; // Codigo del estado
+ GnomeCanvasItem * item_nombre; // item que muestra el nombre del estado
+ list <GnomeCanvasItem *> listaAdyacentes; // Para estados -- Lista de lineas adyacentes
+ int idHijo; //Id. que indica el subautomata dentro de la lista de subautomatas que se corresponde con el hijo de este estado
+} tNodo;
+
+typedef struct tipoTransicion {
+ //int id;
+ GnomeCanvasItem * item; // Item que representa la transición. Está formado a su vez por 3 item: 2 líneas y un punto de acción en la unión de ambas (box).
+ // Posicion 0 inicio recta, posicion 1 final recta, posicion 2 box.
+ //int origenX, origenY;
+ //int destinoX, destinoY;
+ //double pMedioX, pMedioY; // Posición del punto de acción de la transición.
+ GnomeCanvasItem * origen; // Nodo origen
+ GnomeCanvasItem * destino; // Nodo destino
+ string nombre; // Nombre de la transicion. "" por defecto
+ GnomeCanvasItem * item_nombre; // Item del nombre de la transición.
+ //GnomeCanvasItem * orientacion; // Triangulo flecha
+ string codigo;
+ int tiempo;
+} tTransicion;
+
+extern list <tNodo> ListaElementos;
+extern list <tTransicion> ListaTransiciones;
+
+typedef struct transicion_aux { // Transiciones temporales. Usadas para pintar las transiciones despues de cargar un fichero.
+ GnomeCanvasItem *origen;
+ GnomeCanvasItem *destino;
+ int origen_xml;
+ int destino_id;
+ int tiempo;
+ string codigo;
+ string nombre;
+ GnomeCanvasItem *item;
+} transicion_aux;
+
+typedef struct importar {
+ bool laser;
+ bool motor;
+ bool radar;
+ bool encoders;
+ bool lat_lon;
+ bool camara;
+ bool ptencoders;
+} importar;
+
+
+typedef enum TYPE_VENTANA {
+ NOMBRAR,
+ EDITAR,
+ CODIGO,
+ LIBRERIAS,
+ TIMER
+}tVentana;
+
+typedef struct nodoVentana {
+ GnomeCanvasItem * item; // item correspondiente a la ventana
+ tVentana tipo; // Nombre del nodo. "" por defecto
+ GtkWidget *ventana; // Ventana
+} nVentana;
+
+typedef struct tSubAut {
+ list <tNodo> ListaElementosSub;
+ list <tTransicion> ListaTransicionesSub;
+ int tiempoIteracionSub;
+ string variablesSub;
+ string funcionesSub;
+ importar impSub;
+ int idSub;
+ int idPadre;
+} tSubAut;
+
+#endif
Added: trunk/src/stable/components/visualHFSM/transition.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/transition.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/transition.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,95 @@
+#include "transition.h"
+
+/*************************************************************
+ * CONSTRUCTORS
+ *************************************************************/
+Transition::Transition () {}
+
+Transition::Transition ( int id ) {
+ this->id = id;
+}
+
+Transition::Transition ( int id, int idOrigin, int idDestiny ) {
+ this->id = id;
+ this->idOrigin = idOrigin;
+ this->idDestiny = idDestiny;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+Transition::~Transition () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void Transition::setId ( int id ) {
+ this->id = id;
+}
+
+void Transition::setIdOrigin ( int idOrigin ) {
+ this->idOrigin = idOrigin;
+}
+
+void Transition::setIdDestiny ( int idDestiny ) {
+ this->idDestiny = idDestiny;
+}
+
+void Transition::setName ( std::string name ) {
+ this->name = name;
+}
+
+void Transition::setTrans ( std::string type, std::string code ) {
+ this->type = type;
+ this->code = code;
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+int Transition::getId () {
+ return this->id;
+}
+
+int Transition::getIdOrigin () {
+ return this->idOrigin;
+}
+
+int Transition::getIdDestiny () {
+ return this->idDestiny;
+}
+
+std::string Transition::getCode () {
+ return this->code;
+}
+
+std::string Transition::getName () {
+ return this->name;
+}
+
+std::string Transition::getType () {
+ return this->type;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+Transition Transition::copy () {
+ Transition newtransition(this->id);
+ newtransition.setIdOrigin(this->idOrigin);
+ newtransition.setIdDestiny(this->idDestiny);
+ newtransition.setName(this->name);
+ newtransition.setTrans(this->type, this->code);
+
+ return newtransition;
+}
+
+Transition Transition::copy ( int newid ) {
+ Transition newtransition(newid);
+ newtransition.setIdOrigin(this->idOrigin);
+ newtransition.setIdDestiny(this->idDestiny);
+ newtransition.setName(this->name);
+ newtransition.setTrans(this->type, this->code);
+
+ return newtransition;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/transition.h
===================================================================
--- trunk/src/stable/components/visualHFSM/transition.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/transition.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,62 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef TRANSITION_H
+#define TRANSITION_H
+
+#include <iostream>
+#include <string>
+
+// Definition of this class
+class Transition {
+public:
+ // Constructors
+ Transition ();
+ Transition ( int id );
+ Transition ( int id, int idOrigin, int idDestiny );
+
+ // Destructor
+ virtual ~Transition ();
+
+ // Setters
+ void setId ( int id );
+ void setIdOrigin ( int idOrigin );
+ void setIdDestiny ( int idDestiny );
+ void setName ( std::string name );
+ void setTrans ( std::string type, std::string code );
+
+ // Getters
+ int getId ();
+ int getIdOrigin ();
+ int getIdDestiny ();
+ std::string getCode ();
+ std::string getName ();
+ std::string getType ();
+
+ // Another functions
+ Transition copy ();
+ Transition copy ( int newid );
+private:
+ // Data structure
+ int id, idOrigin, idDestiny;
+ std::string type, code, name;
+}; // Class Transition
+
+#endif
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/visualhfsm.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,1166 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "visualhfsm.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+VisualHFSM::VisualHFSM () {
+ if (this->get_all_widgets() != -1) {
+ this->assign_signals();
+
+ this->refTreeModel = Gtk::TreeStore::create(this->m_Columns);
+ this->treeview->set_model(this->refTreeModel);
+
+ //Add the TreeView's view columns:
+ this->treeview->append_column("ID", this->m_Columns.m_col_id);
+ this->treeview->append_column("Name", this->m_Columns.m_col_name);
+
+ this->root = Goocanvas::GroupModel::create();
+ this->canvas->set_root_item_model(root);
+ this->canvas->set_visible(true);
+ this->viewport_schema->add(*(this->canvas));
+ show_all_children();
+
+ this->create_menu_transition();
+ this->create_menu_item();
+ this->create_menu_paste();
+
+ this->copyPressed = false;
+
+ this->id = 1;
+ GuiSubautomata guisub(id, 0);
+ this->subautomataList.push_back(guisub);
+ this->currentSubautomata = this->getSubautomata(id);
+ this->id++;
+
+ this->idguinode = 1;
+ this->idguitransition = 1;
+ }
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+VisualHFSM::~VisualHFSM () {}
+
+/*************************************************************
+ * INTERNAL METHODS
+ *************************************************************/
+int VisualHFSM::get_all_widgets () {
+ int returned = 0;
+ // Load the GtkBuilder file and instantiate its widgets:
+ Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
+ try {
+ refBuilder->add_from_file("gui/main_gui.glade");
+ } catch (const Glib::FileError& ex) {
+ std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl;
+ returned = -1;
+ } catch(const Glib::MarkupError& ex) {
+ std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl;
+ returned = -1;
+ } catch(const Gtk::BuilderError& ex) {
+ std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl;
+ returned = -1;
+ }
+
+ if (returned == 0) {
+ // Get the windows
+ refBuilder->get_widget("viewport_schema", this->viewport_schema);
+
+ // Get the treeview
+ refBuilder->get_widget("treeview", this->treeview);
+
+ // Get the buttons
+ refBuilder->get_widget("button_up", this->button_up);
+ refBuilder->get_widget("button_transition", this->button_transition);
+ refBuilder->get_widget("button_state", this->button_state);
+ refBuilder->get_widget("button_save", this->button_save);
+ refBuilder->get_widget("button_save_as", this->button_save_as);
+ refBuilder->get_widget("button_open", this->button_open);
+ refBuilder->get_widget("button_interfaces", this->button_interfaces);
+ refBuilder->get_widget("button_timer", this->button_timer);
+ refBuilder->get_widget("button_variables", this->button_variables);
+ refBuilder->get_widget("button_generate_code", this->button_generate_code);
+ refBuilder->get_widget("button_compile", this->button_compile);
+ }
+
+ return returned;
+}
+
+void VisualHFSM::assign_signals () {
+ // Events
+ this->button_up->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_up));
+ this->button_transition->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_transition));
+ this->button_state->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_state));
+ this->button_save->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_save));
+ this->button_save_as->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_save_as));
+ this->button_open->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_open));
+ this->button_interfaces->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_interfaces));
+ this->button_timer->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_timer));
+ this->button_variables->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_variables));
+ this->button_generate_code->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_generate_code));
+ this->button_compile->signal_clicked().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_options_clicked_compile));
+
+ this->viewport_schema->signal_event().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_schema_event));
+
+ this->canvas = Gtk::manage(new Goocanvas::Canvas());
+ this->canvas->signal_item_created().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_item_created));
+}
+
+void VisualHFSM::create_menu_transition () {
+ this->actionGroupTransition = Gtk::ActionGroup::create();
+ this->actionGroupTransition->add(Gtk::Action::create("ContextMenu", "Context Menu"));
+ this->actionGroupTransition->add(Gtk::Action::create("ContextRename", "Rename"),
+ 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("ContextRemove", "Remove"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_transition_remove));
+
+ this->UIManagerTransition = Gtk::UIManager::create();
+ this->UIManagerTransition->insert_action_group(this->actionGroupTransition);
+ add_accel_group(this->UIManagerTransition->get_accel_group());
+ Glib::ustring ui_info =
+ "<ui>"
+ " <popup name='PopupMenuTransition'>"
+ " <menuitem action='ContextRename'/>"
+ " <menuitem action='ContextEdit'/>"
+ " <menuitem action='ContextRemove'/>"
+ " </popup>"
+ "</ui>";
+ try {
+ this->UIManagerTransition->add_ui_from_string(ui_info);
+ } catch(const Glib::Error& ex) {
+ std::cerr << "building menus failed: " << ex.what();
+ }
+
+ //Get the menu:
+ this->menuPopupTransition = dynamic_cast<Gtk::Menu*>(this->UIManagerTransition->get_widget("/PopupMenuTransition"));
+ if (!this->menuPopupTransition)
+ g_warning("menu not found");
+}
+
+void VisualHFSM::create_menu_item () {
+ this->actionGroupItem = Gtk::ActionGroup::create();
+ this->actionGroupItem->add(Gtk::Action::create("ContextMenu", "Context Menu"));
+ this->actionGroupItem->add(Gtk::Action::create("ContextRename", "Rename"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_state_rename));
+ this->actionGroupItem->add(Gtk::Action::create("ContextEdit", "Edit"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_state_edit));
+ this->actionGroupItem->add(Gtk::Action::create("ContextMarkAsInitial", "Mark as initial"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_state_markasinitial));
+ this->actionGroupItem->add(Gtk::Action::create("ContextCopy", "Copy"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_state_copy));
+ this->actionGroupItem->add(Gtk::Action::create("ContextRemove", "Remove"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_state_remove));
+
+ this->UIManagerItem = Gtk::UIManager::create();
+ this->UIManagerItem->insert_action_group(this->actionGroupItem);
+ add_accel_group(this->UIManagerItem->get_accel_group());
+ Glib::ustring ui_info =
+ "<ui>"
+ " <popup name='PopupMenu'>"
+ " <menuitem action='ContextRename'/>"
+ " <menuitem action='ContextEdit'/>"
+ " <menuitem action='ContextMarkAsInitial'/>"
+ " <menuitem action='ContextCopy'/>"
+ " <menuitem action='ContextRemove'/>"
+ " </popup>"
+ "</ui>";
+ try {
+ this->UIManagerItem->add_ui_from_string(ui_info);
+ } catch(const Glib::Error& ex) {
+ std::cerr << "building menus failed: " << ex.what();
+ }
+
+ //Get the menu:
+ this->menuPopupItem = dynamic_cast<Gtk::Menu*>(this->UIManagerItem->get_widget("/PopupMenu"));
+ if(!this->menuPopupItem)
+ g_warning("menu not found");
+}
+
+void VisualHFSM::create_menu_paste () {
+ this->actionGroupPaste = Gtk::ActionGroup::create();
+ this->actionGroupPaste->add(Gtk::Action::create("ContextMenu", "Context Menu"));
+ this->actionGroupPaste->add(Gtk::Action::create("ContextPaste", "Paste"),
+ sigc::mem_fun(this, &VisualHFSM::on_menu_canvas_paste));
+
+ this->UIManagerPaste = Gtk::UIManager::create();
+ this->UIManagerPaste->insert_action_group(this->actionGroupPaste);
+ add_accel_group(this->UIManagerPaste->get_accel_group());
+ Glib::ustring ui_infoPaste =
+ "<ui>"
+ " <popup name='PopupMenuPaste'>"
+ " <menuitem action='ContextPaste'/>"
+ " </popup>"
+ "</ui>";
+ try {
+ this->UIManagerPaste->add_ui_from_string(ui_infoPaste);
+ } catch(const Glib::Error& ex) {
+ std::cerr << "building menu paste failed: " << ex.what();
+ }
+
+ //Get the menu:
+ this->menuPopupPaste = dynamic_cast<Gtk::Menu*>(this->UIManagerPaste->get_widget("/PopupMenuPaste"));
+ if(!this->menuPopupPaste)
+ g_warning("menu paste not found");
+}
+
+void VisualHFSM::create_new_state ( int idSubautomataSon ) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Creating state with ID: " << this->idguinode << END_COLOR << std::endl;
+
+
+ this->currentSubautomata->newGuiNode(this->idguinode, idSubautomataSon, this->event_x, this->event_y);
+ std::string nameNode = this->currentSubautomata->getLastGuiNodeName();
+
+ if (this->currentSubautomata->getId() == 1) {
+ Gtk::TreeModel::Row row = *(refTreeModel->append());
+ row[m_Columns.m_col_id] = this->idguinode;
+ row[m_Columns.m_col_name] = nameNode;
+ } else {
+ this->fillTreeView(nameNode, refTreeModel->children(), this->getIdNodeInSubautomata(this->currentSubautomata->getIdFather()));
+ }
+
+
+ this->state = NORMAL;
+ this->root->add_child(this->currentSubautomata->getLastEllipse());
+
+ this->state = TEXT;
+ this->root->add_child(this->currentSubautomata->getLastTextNode());
+
+ this->state = INIT;
+ this->root->add_child(this->currentSubautomata->getLastEllipseInit());
+
+ this->currentSubautomata->checkLastGuiNodeForInitial();
+
+ this->state = ALL;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
+}
+
+void VisualHFSM::create_new_transition ( const Glib::RefPtr<Goocanvas::Item>& item ) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Creating transition" << END_COLOR << std::endl;
+
+ this->theOtherItem = item;
+
+ Point porigin = this->currentSubautomata->getPoint(this->lastItem);
+ Point pfinal = this->currentSubautomata->getPoint(this->theOtherItem);
+
+ this->currentSubautomata->newGuiTransition(porigin, pfinal, this->idguitransition);
+ this->idguitransition++;
+
+ this->state = TRANS_LEFT;
+ this->root->add_child(this->currentSubautomata->getLastLeftLine());
+
+ this->state = TRANS_RIGHT;
+ this->root->add_child(this->currentSubautomata->getLastRightLine());
+
+ this->state = TEXT;
+ this->root->add_child(this->currentSubautomata->getLastTextTransition());
+
+ this->state = TRANS_MIDPOINT;
+ this->root->add_child(this->currentSubautomata->getLastMidpoint());
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
+}
+
+void VisualHFSM::create_new_transition ( Point origin, Point final, Point midpoint, int idTransition ) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Creating transition" << END_COLOR << std::endl;
+
+ this->currentSubautomata->newGuiTransition(origin, final, midpoint, idTransition);
+
+ this->state = TRANS_LEFT;
+ this->root->add_child(this->currentSubautomata->getLastLeftLine());
+
+ this->state = TRANS_RIGHT;
+ this->root->add_child(this->currentSubautomata->getLastRightLine());
+
+ this->state = TEXT;
+ this->root->add_child(this->currentSubautomata->getLastTextTransition());
+
+ this->state = TRANS_MIDPOINT;
+ this->root->add_child(this->currentSubautomata->getLastMidpoint());
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
+}
+
+/*************************************************************
+ * METHODS FOR SIGNALS
+ *************************************************************/
+
+/*************************************************************
+ * OF THE MENUS (TRANSITIONS)
+ *************************************************************/
+void VisualHFSM::on_menu_transition_rename () {
+ this->currentSubautomata->renameGuiTransition(this->selectedItem);
+}
+
+void VisualHFSM::on_menu_transition_edit () {
+ this->currentSubautomata->editGuiTransition(this->selectedItem);
+}
+
+void VisualHFSM::on_menu_transition_remove () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Removing transition..." << END_COLOR << std::endl;
+
+ GuiTransition* gtransition = this->currentSubautomata->getGuiTransition(this->selectedItem);
+ if (gtransition != NULL) {
+ root->remove_child(root->find_child(gtransition->getLeftLine()));
+ root->remove_child(root->find_child(gtransition->getRightLine()));
+ root->remove_child(root->find_child(gtransition->getMidpoint()));
+ root->remove_child(root->find_child(gtransition->getTextModel()));
+
+ this->currentSubautomata->removeGuiTransitionsWith(this->selectedItem);
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
+ } else if (DEBUG) {
+ std::cout << BEGIN_YELLOW << VISUAL << "Impossible to remove!" << END_COLOR << std::endl;
+ }
+}
+
+/*************************************************************
+ * OF THE MENUS (STATES)
+ *************************************************************/
+void VisualHFSM::on_menu_state_rename () {
+ this->copyPressed = false;
+
+ this->currentSubautomata->renameGuiNode(this->selectedItem);
+}
+
+void VisualHFSM::on_menu_state_edit () {
+ this->copyPressed = false;
+
+ this->currentSubautomata->editGuiNode(this->selectedItem);
+}
+
+void VisualHFSM::on_menu_state_markasinitial () {
+ this->copyPressed = false;
+
+ this->currentSubautomata->markGuiNodeAsInitial(this->selectedItem);
+}
+
+void VisualHFSM::on_menu_state_copy () {
+ this->copyPressed = true;
+}
+
+void VisualHFSM::on_menu_state_remove () {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Removing state..." << END_COLOR << std::endl;
+
+ this->copyPressed = false;
+
+ GuiNode* gnode = this->currentSubautomata->getGuiNode(this->selectedItem);
+ if (gnode != NULL) {
+ this->removeFromTreeView(gnode->getId(), this->refTreeModel->children());
+// this->removeRecursively(this->getSubautomata(this->getIdSubautomataWithNode(gnode->getIdSubautomataSon())), gnode);
+ this->removeRecursively(this->currentSubautomata, gnode);
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
+ } else if (DEBUG) {
+ std::cout << BEGIN_YELLOW << VISUAL << "Impossible to remove!" << END_COLOR << std::endl;
+ }
+}
+
+void VisualHFSM::on_menu_canvas_paste () {
+ this->copyPressed = true;
+
+ this->create_new_state(0);
+ this->idguinode++;
+}
+
+/*************************************************************
+ * OF THE TREEVIEW
+ *************************************************************/
+
+/*************************************************************
+ * OF THE SCHEMA
+ *************************************************************/
+bool VisualHFSM::on_schema_event ( GdkEvent* event ) {
+ if ((event->button.x != 0) && (event->button.y != 0)) {
+ this->event_x = event->button.x;
+ this->event_y = event->button.y;
+ }
+
+ if ((lastButton == STATE) && (event->type == GDK_BUTTON_RELEASE)
+ && (event->button.button == 1)) { // create an state
+ this->create_new_state(0);
+ this->idguinode++;
+ } else if ((event->button.button == 3) && this->copyPressed && !this->showingMenuPopup) {
+ if(menuPopupPaste) {
+ std::cout << BEGIN_GREEN << VISUAL << "Showing popup paste" << END_COLOR << std::endl;
+ menuPopupPaste->popup(((GdkEventButton*)event)->button, ((GdkEventButton*)event)->time);
+ }
+ } else if ((event->button.button == 3) && this->showingMenuPopup) {
+ this->showingMenuPopup = false;
+ }
+
+ return false;
+}
+
+void VisualHFSM::on_item_created ( const Glib::RefPtr<Goocanvas::Item>& item,
+ const Glib::RefPtr<Goocanvas::ItemModel>& /* model */) {
+ if (this->state == NORMAL) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ item->signal_button_press_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_button_press_event));
+ item->signal_button_release_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_button_release_event));
+ item->signal_motion_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_motion_notify_event));
+ item->signal_enter_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_enter_notify_event));
+ item->signal_leave_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_leave_notify_event));
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item NORMAL created" << END_COLOR << std::endl;
+
+ this->selectedItem = item;
+ } else if (this->state == INIT) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ item->signal_enter_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_item_enter_notify_event));
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item INIT created" << END_COLOR << std::endl;
+
+ this->currentSubautomata->setGuiNodeItems(this->selectedItem, item, this->textItem);
+ } else if (this->state == TEXT) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item TEXT created" << END_COLOR << std::endl;
+
+ this->textItem = item;
+ } else if (this->state == TRANS_LEFT) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item TRANS_LEFT created" << END_COLOR << std::endl;
+
+ this->leftItemTrans = item;
+ } else if (this->state == TRANS_RIGHT) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item TRANS_RIGHT created" << END_COLOR << std::endl;
+
+ this->rightItemTrans = item;
+ } else if (this->state == TRANS_MIDPOINT) {
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
+ if (group)
+ return;
+
+ item->signal_button_press_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_transition_button_press_event));
+ item->signal_button_release_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_transition_button_release_event));
+ item->signal_motion_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_transition_motion_notify_event));
+ item->signal_enter_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_transition_enter_notify_event));
+ item->signal_leave_notify_event().connect(
+ sigc::mem_fun(this, &VisualHFSM::on_transition_leave_notify_event));
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Item TRANS_MIDPOINT created" << END_COLOR << std::endl;
+
+ this->currentSubautomata->setGuiTransitionItems(this->leftItemTrans,
+ this->rightItemTrans, item, this->lastItem,
+ this->theOtherItem, this->textItem);
+ }
+}
+
+bool VisualHFSM::on_item_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event ) {
+ if ((event->button == 1) && item) {
+ if (event->type == GDK_2BUTTON_PRESS) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Going deep" << END_COLOR << std::endl;
+
+ this->currentSubautomata->hideAll();
+ int idSubautomataSon = this->currentSubautomata->getIdSubautomataSon(item);
+ if (idSubautomataSon != 0) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "To the automata with id: " << idSubautomataSon << END_COLOR << std::endl;
+
+ this->currentSubautomata = this->getSubautomata(idSubautomataSon);
+ this->currentSubautomata->showAll();
+ } else {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Creating a new subautomata with id: " << id << END_COLOR << std::endl;
+
+ this->currentSubautomata->setIdSubautomataSon(id, item);
+ GuiSubautomata newSubautomata(id, this->currentSubautomata->getId());
+ subautomataList.push_back(newSubautomata);
+ this->currentSubautomata = this->getSubautomata(id);
+ id++;
+ }
+
+ lastButton = ANY;
+ } else if (event->type == GDK_BUTTON_PRESS) {
+ dragging = item;
+ drag_x = (double) event->x;
+ drag_y = (double) event->y;
+ if (this->lastButton != TRANSITION)
+ this->lastButton = ANY;
+ }
+ } else if ((event->button == 3) && item) {
+ if(menuPopupItem) {
+ this->showingMenuPopup = true;
+ this->selectedItem = item;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Showing menu popup" << END_COLOR << std::endl;
+
+ menuPopupItem->popup(event->button, event->time);
+ }
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_item_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event) {
+ if (event->button == 1) {
+ dragging.reset();
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Button release event" << END_COLOR << std::endl;
+
+ if (this->lastButton == TRANSITION) {
+ if (transitionsCounter % 2 == 0) {
+ this->lastItem = item;
+ } else {
+ this->create_new_transition(item);
+ this->lastItem = item;
+
+ this->state = NONE;
+ }
+ transitionsCounter += 1;
+ }
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_item_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventMotion* event) {
+ if (item && dragging && item == dragging) {
+ double new_x = event->x;
+ double new_y = event->y;
+
+ this->currentSubautomata->moveGuiNode(item, new_x - drag_x, new_y - drag_y);
+ this->currentSubautomata->moveGuiTransition(item);
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_item_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event) {
+ if (item) {
+ if (this->state == ALL) {
+ this->state = NONE;
+ } else if (this->state == NONE) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Changing node width to 3" << END_COLOR << std::endl;
+
+ this->currentSubautomata->changeGuiNodeWidth(item, 3);
+ }
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_item_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event) {
+ if (item) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Changing node width to 1" << END_COLOR << std::endl;
+
+ this->currentSubautomata->changeGuiNodeWidth(item, 1);
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_transition_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event ) {
+ if ((event->button == 1) && item && (event->type == GDK_BUTTON_PRESS)) {
+ dragging = item;
+ drag_x = (double) event->x;
+ drag_y = (double) event->y;
+ if (this->lastButton != TRANSITION)
+ this->lastButton = ANY;
+ } else if ((event->button == 3) && item) {
+ if (menuPopupTransition) {
+ this->selectedItem = item;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Showing menu transition popup" << END_COLOR << std::endl;
+
+ menuPopupTransition->popup(event->button, event->time);
+ }
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_transition_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event) {
+ if (event->button == 1)
+ dragging.reset();
+
+ return false;
+}
+
+bool VisualHFSM::on_transition_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventMotion* event) {
+ if (item && dragging && item == dragging) {
+ double new_x = event->x;
+ double new_y = event->y;
+
+ this->currentSubautomata->moveJustGuiTransition(item, new_x - drag_x, new_y - drag_y);
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_transition_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event) {
+ if (item) {
+ if (this->state == NONE) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Changing transition width to 3" << END_COLOR << std::endl;
+
+ this->currentSubautomata->changeGuiTransitionWidth(item, 3);
+ }
+ }
+
+ return false;
+}
+
+bool VisualHFSM::on_transition_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event) {
+ if (item) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Changing transition width to 1" << END_COLOR << std::endl;
+
+ this->currentSubautomata->changeGuiTransitionWidth(item, 1);
+ }
+
+ return false;
+}
+
+/*************************************************************
+ * OF THE BUTTONS
+ *************************************************************/
+void VisualHFSM::on_options_clicked_up () {
+ lastButton = UP;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Going up" << END_COLOR << std::endl;
+
+ GuiSubautomata* guisub = this->getSubautomata(this->currentSubautomata->getIdFather());
+ if (guisub != NULL) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "It is ok to get the father" << END_COLOR << std::endl;
+
+ this->currentSubautomata->hideAll();
+ guisub->showAll();
+ this->currentSubautomata = guisub;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Got the father" << END_COLOR << std::endl;
+ }
+}
+
+void VisualHFSM::on_options_clicked_transition () {
+ lastButton = TRANSITION;
+ transitionsCounter = 0;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Create a transition?" << END_COLOR << std::endl;
+}
+
+void VisualHFSM::on_options_clicked_state () {
+ lastButton = STATE;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Create a state?" << END_COLOR << std::endl;
+}
+
+void VisualHFSM::on_options_clicked_save () {
+ lastButton = SAVE;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Save automata" << END_COLOR << std::endl;
+
+ if (this->filepath.empty())
+ this->on_options_clicked_save_as();
+ else
+ this->on_save_file(this->filepath);
+}
+
+void VisualHFSM::on_options_clicked_save_as () {
+ lastButton = SAVE_AS;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Save as..." << END_COLOR << std::endl;
+
+ this->sfdialog = new SaveFileDialog();
+ this->sfdialog->init();
+ this->sfdialog->signal_path().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_save_file));
+}
+
+void VisualHFSM::on_options_clicked_open () {
+ lastButton = OPEN;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Open automata" << END_COLOR << std::endl;
+
+ this->lfdialog = new LoadFileDialog();
+ this->lfdialog->init();
+ this->lfdialog->signal_path().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_load_file));
+}
+
+void VisualHFSM::on_options_clicked_interfaces () {
+ lastButton = INTERFACES;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Import interfaces" << END_COLOR << std::endl;
+
+ ImportDialog* idialog = new ImportDialog(this->currentSubautomata);
+ idialog->init();
+}
+
+void VisualHFSM::on_options_clicked_timer () {
+ lastButton = TIMER;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Timer of this automata" << END_COLOR << std::endl;
+
+ TimerDialog* tdialog = new TimerDialog(this->currentSubautomata);
+ tdialog->init();
+}
+
+void VisualHFSM::on_options_clicked_variables () {
+ lastButton = VARIABLES;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Variables for this automata" << END_COLOR << std::endl;
+
+ FunVarDialog* fvdialog = new FunVarDialog(this->currentSubautomata);
+ fvdialog->init();
+}
+
+void VisualHFSM::on_options_clicked_generate_code () {
+ lastButton = GENERATE_CODE;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Generating code..." << END_COLOR << std::endl;
+
+ MySaxParser parser;
+ parser.set_substitute_entities(true);
+ parser.parse_file(this->filepath);
+
+ std::string cpppath(this->filepath);
+ std::string cfgpath(this->filepath);
+ std::string cmakepath(this->filepath);
+ if ( (this->replace(cpppath, std::string(".xml"), std::string(".cpp"))) &&
+ (this->replace(cfgpath, std::string(".xml"), std::string(".cfg"))) &&
+ (this->replaceFile(cmakepath, std::string("/"), std::string("CMakeLists.txt"))) ) {
+ Generate generate(parser.getListSubautomata(), cpppath, cfgpath, cmakepath);
+ generate.init();
+ } else {
+ std::cout << BEGIN_GREEN << VISUAL << "Impossible to generate code" << END_COLOR << std::endl;
+ }
+}
+
+void VisualHFSM::on_options_clicked_compile () {
+ lastButton = COMPILE;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Starting compilation?" << END_COLOR << std::endl;
+
+ std::string directory(this->filepath);
+
+ size_t last_pos = directory.find_last_of(std::string("/"));
+ if (last_pos == std::string::npos) {
+ std::cout << "Impossible to compile" << std::endl;
+ return;
+ }
+
+ directory.erase(last_pos + 1, std::string::npos);
+ std::string directoryBuild(directory + "build");
+
+ std::string hoption("-H" + directory);
+ std::string boption("-B" + directoryBuild);
+
+ std::string cmake("cmake " + hoption + " " + boption);
+ std::string make("make -C " + directoryBuild);
+
+ system(cmake.c_str());
+ system(make.c_str());
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Compilation done!" << END_COLOR << std::endl;
+}
+
+/*************************************************************
+ * IN GENERAL
+ *************************************************************/
+void VisualHFSM::on_save_file ( std::string path ) {
+ if (this->lastButton == SAVE_AS) {
+ std::string str(".xml");
+ if (!this->hasEnding(path, str))
+ this->filepath = std::string(path + str);
+ else
+ this->filepath = std::string(path);
+
+ delete this->sfdialog;
+ }
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Saving file... " << this->filepath << END_COLOR << std::endl;
+
+ SaveFile savefile(this->filepath, &this->subautomataList);
+ savefile.init();
+}
+
+void VisualHFSM::on_load_file ( std::string path ) {
+ this->filepath = std::string(path);
+
+ delete this->lfdialog;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Loading file... " << this->filepath << END_COLOR << std::endl;
+
+ try {
+ MySaxParser parser;
+ parser.set_substitute_entities(true);
+ parser.parse_file(filepath);
+
+ this->removeAllGui();
+ if (!this->loadSubautomata(parser.getListSubautomata()))
+ std::cout << "ERROR loading subautomata" << std::endl;
+ } catch ( const xmlpp::exception& ex ) {
+ std::cout << "libxml++ exception: " << ex.what() << std::endl;
+ }
+}
+
+GuiSubautomata* VisualHFSM::getSubautomata ( int idSubautomata ) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Getting subautomata with ID: " << idSubautomata << END_COLOR << std::endl;
+
+ std::list<GuiSubautomata>::iterator subautomataListIterator = this->subautomataList.begin();
+ while ( (subautomataListIterator->getId() != idSubautomata) &&
+ (subautomataListIterator != this->subautomataList.end()) )
+ subautomataListIterator++;
+
+ if (subautomataListIterator != this->subautomataList.end())
+ return &*subautomataListIterator;
+
+ return NULL;
+}
+
+GuiSubautomata* VisualHFSM::getSubautomataWithIdFather ( int idFather ) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Getting subautomata with ID father: " << idFather << END_COLOR << std::endl;
+
+ std::list<GuiSubautomata>::iterator subautomataListIterator = this->subautomataList.begin();
+ while ( (subautomataListIterator->getIdFather() != idFather) &&
+ (subautomataListIterator != this->subautomataList.end()) )
+ subautomataListIterator++;
+
+ if (subautomataListIterator != this->subautomataList.end())
+ return &*subautomataListIterator;
+
+ return NULL;
+}
+
+int VisualHFSM::loadSubautomata ( std::list<SubAutomata> subList ) {
+ this->removeAllSubautomata();
+ std::list<SubAutomata>::iterator subListIterator = subList.begin();
+ while ( subListIterator != subList.end() ) {
+ int id = subListIterator->getId();
+ int idFather = subListIterator->getIdFather();
+
+ GuiSubautomata guisub(id, idFather);
+ this->subautomataList.push_back(guisub);
+ this->currentSubautomata = this->getSubautomata(id);
+ this->id = id + 1;
+
+ this->currentSubautomata->setFunctions(subListIterator->getFunctions());
+ this->currentSubautomata->setTime(subListIterator->getTime());
+ this->currentSubautomata->setVariables(subListIterator->getVariables());
+ this->currentSubautomata->setInterfaces(*(subListIterator->getInterfaces()));
+
+ std::list<Node> nodeList = subListIterator->getNodeList();
+ std::list<Node>::iterator nodeListIterator = nodeList.begin();
+ while ( nodeListIterator != nodeList.end() ) {
+ int idNode = nodeListIterator->getId();
+ Point* nodePoint = subListIterator->getNodePoint(idNode);
+ this->event_x = nodePoint->getX();
+ this->event_y = nodePoint->getY();
+ this->idguinode = idNode;
+ this->create_new_state(nodeListIterator->getIdSubautomataSon());
+ std::cout << "Es nodo inicial: " << nodeListIterator->isInitial() << std::endl;
+ this->currentSubautomata->setIsInitialLastGuiNode(nodeListIterator->isInitial());
+ this->currentSubautomata->setNameLastGuiNode(nodeListIterator->getName());
+ this->currentSubautomata->setCodeLastGuiNode(nodeListIterator->getCode());
+ nodeListIterator++;
+ }
+
+ std::list<Transition> transList = subListIterator->getTransList();
+ std::list<Transition>::iterator transListIterator = transList.begin();
+ while ( transListIterator != transList.end() ) {
+ int idTransition = transListIterator->getId();
+ Point* ptransition = subListIterator->getTransPoint(idTransition);
+
+ int idOrigin = transListIterator->getIdOrigin();
+ Point* porigin = subListIterator->getNodePoint(idOrigin);
+
+ int idDestiny = transListIterator->getIdDestiny();
+ Point* pdestiny = subListIterator->getNodePoint(idDestiny);
+
+ this->lastItem = this->currentSubautomata->getGuiNodeItem(idOrigin);
+ this->theOtherItem = this->currentSubautomata->getGuiNodeItem(idDestiny);
+
+ this->create_new_transition(*porigin, *pdestiny, *ptransition, idTransition);
+ this->currentSubautomata->setTransLastGuiTransition(transListIterator->getType(), transListIterator->getCode());
+ this->currentSubautomata->setNameLastGuiTransition(transListIterator->getName());
+ this->state = NONE;
+
+ transListIterator++;
+ }
+
+ if (idFather != 0)
+ this->currentSubautomata->hideAll();
+
+ subListIterator++;
+ }
+
+ this->currentSubautomata = this->getSubautomataWithIdFather(0);
+
+ return 1;
+}
+
+void VisualHFSM::removeAllGui () {
+ for ( std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ ) {
+ std::list<GuiNode>* nodeList = subListIterator->getListGuiNodes();
+ for ( std::list<GuiNode>::iterator nodeListIterator = nodeList->begin();
+ nodeListIterator != nodeList->end(); nodeListIterator++ ) {
+ this->root->remove_child(this->root->find_child(nodeListIterator->getEllipse()));
+ this->root->remove_child(this->root->find_child(nodeListIterator->getEllipseInitial()));
+ this->root->remove_child(this->root->find_child(nodeListIterator->getText()));
+ }
+
+ std::list<GuiTransition>* transList = subListIterator->getListGuiTransitions();
+ for ( std::list<GuiTransition>::iterator transListIterator = transList->begin();
+ transListIterator != transList->end(); transListIterator++ ) {
+ this->root->remove_child(this->root->find_child(transListIterator->getLeftLine()));
+ this->root->remove_child(this->root->find_child(transListIterator->getRightLine()));
+ this->root->remove_child(this->root->find_child(transListIterator->getMidpoint()));
+ this->root->remove_child(this->root->find_child(transListIterator->getTextModel()));
+ }
+ }
+}
+
+void VisualHFSM::removeAllSubautomata () {
+ for ( std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
+ subListIterator != this->subautomataList.end(); subListIterator++ )
+ subListIterator->removeAll();
+
+ this->subautomataList.clear();
+}
+
+bool VisualHFSM::hasEnding ( std::string const &fullString, std::string const &ending ) {
+ if (fullString.length() >= ending.length()) {
+ return (0 == fullString.compare (fullString.length() - ending.length(),
+ ending.length(), ending));
+ } else {
+ return false;
+ }
+}
+
+bool VisualHFSM::replaceFile ( std::string& str, const std::string& character, std::string to ) {
+ size_t last_pos = str.find_last_of(character);
+ if (last_pos == std::string::npos)
+ return false;
+
+ str.replace(last_pos + 1, std::string::npos, to);
+
+ return true;
+}
+
+bool VisualHFSM::replace ( std::string& str, const std::string& from, const std::string& to) {
+ size_t start_pos = str.find(from);
+ if (start_pos == std::string::npos)
+ return false;
+
+ str.replace(start_pos, from.length(), to);
+
+ return true;
+}
+
+bool VisualHFSM::fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather ) {
+ bool cont = true;
+ Gtk::TreeModel::Children::iterator iter = child.begin();
+ while ( cont && (iter != child.end()) ) {
+ Gtk::TreeModel::Row therow = *iter;
+ if (therow[m_Columns.m_col_id] == idNodeFather) {
+ Gtk::TreeModel::Row row = *(refTreeModel->append(therow.children()));
+ row[m_Columns.m_col_id] = this->idguinode;
+ row[m_Columns.m_col_name] = nameNode;
+ cont = false;
+ } else {
+ cont = this->fillTreeView(nameNode, therow.children(), idNodeFather);
+ iter++;
+ }
+ }
+
+ return cont;
+}
+
+bool VisualHFSM::removeFromTreeView ( int id, Gtk::TreeModel::Children child ) {
+ bool cont = true;
+ Gtk::TreeModel::Children::iterator iter = child.begin();
+ while ( cont && (iter != child.end()) ) {
+ Gtk::TreeModel::Row therow = *iter;
+ if (therow[m_Columns.m_col_id] == id) {
+ refTreeModel->erase(therow);
+ cont = false;
+ } else {
+ cont = this->removeFromTreeView(id, therow.children());
+ iter++;
+ }
+ }
+
+ return cont;
+}
+
+int VisualHFSM::getIdNodeInSubautomata ( int subautomataId ) {
+ std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
+ while ( (subListIterator->getId() != subautomataId) &&
+ (subListIterator != this->subautomataList.end()) )
+ subListIterator++;
+
+ std::list<GuiNode>* guiNodeList = subListIterator->getListGuiNodes();
+ std::list<GuiNode>::iterator guiNodeListIterator = guiNodeList->begin();
+ while ( (guiNodeListIterator->getIdSubautomataSon() != this->currentSubautomata->getId()) &&
+ (guiNodeListIterator != guiNodeList->end()) )
+ guiNodeListIterator++;
+
+ return guiNodeListIterator->getId();
+}
+
+void VisualHFSM::removeRecursively ( GuiSubautomata* guisub, GuiNode* gnode ) {
+ int idSubautomataSon = gnode->getIdSubautomataSon();
+ if (idSubautomataSon == 0) {
+ this->remove(guisub, gnode);
+ } else {
+ std::cout << "entramos con id guisub: " << guisub->getId() << std::endl;
+ GuiSubautomata* subautomata = this->getSubautomata(idSubautomataSon);
+ std::list<GuiNode>* guiNodeList = subautomata->getListGuiNodes();
+ for ( std::list<GuiNode>::iterator guiNodeListIterator = guiNodeList->begin();
+ guiNodeListIterator != guiNodeList->end(); guiNodeListIterator++ ) {
+ this->removeRecursively(subautomata, &*guiNodeListIterator);
+ }
+ this->remove(guisub, gnode);
+ }
+}
+
+void VisualHFSM::remove ( GuiSubautomata* guisub, GuiNode* gnode ) {
+ std::cout << "removing node with id: " << gnode->getId() << " from the automata with id: " << guisub->getId() << std::endl;
+ root->remove_child(root->find_child(gnode->getEllipse()));
+ root->remove_child(root->find_child(gnode->getEllipseInitial()));
+ root->remove_child(root->find_child(gnode->getText()));
+
+ std::list<GuiTransition> nodeTrans =
+ guisub->getAllGuiTransitionsWith(gnode->getId());
+ std::list<GuiTransition>::iterator nodeTransIterator = nodeTrans.begin();
+
+ while ( nodeTransIterator != nodeTrans.end() ) {
+ root->remove_child(root->find_child(nodeTransIterator->getLeftLine()));
+ root->remove_child(root->find_child(nodeTransIterator->getRightLine()));
+ root->remove_child(root->find_child(nodeTransIterator->getMidpoint()));
+ root->remove_child(root->find_child(nodeTransIterator->getTextModel()));
+ nodeTransIterator++;
+ }
+
+ guisub->removeGuiNode(gnode->getId());
+}
+
+int VisualHFSM::getIdSubautomataWithNode ( int idNode ) {
+ int id = 0;
+ std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
+ while ( (id == 0) && (subListIterator != this->subautomataList.end()) ) {
+ std::list<GuiNode>* nodeList = subListIterator->getListGuiNodes();
+ std::list<GuiNode>::iterator nodeListIterator = nodeList->begin();
+ while ( (id == 0) && (nodeListIterator != nodeList->end()) ) {
+ if (nodeListIterator->getId() == idNode)
+ id = subListIterator->getId();
+ else
+ nodeListIterator++;
+ }
+ subListIterator++;
+ }
+
+ return id;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/visualhfsm.h
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,243 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef VISUALHFSM_H
+#define VISUALHFSM_H
+
+#include <iostream>
+#include <stdio.h>
+#include <gtkmm/stock.h>
+#include <math.h>
+#include <sigc++/sigc++.h>
+#include <libxml++/libxml++.h>
+
+#include "xmlparser.h"
+#include "savefile.h"
+#include "generate.h"
+#include "guisubautomata.h"
+#include "popups/funvardialog.h"
+#include "popups/importdialog.h"
+#include "popups/loadfiledialog.h"
+#include "popups/timerdialog.h"
+#include "popups/savefiledialog.h"
+
+typedef enum Button {
+ UP,
+ TRANSITION,
+ STATE,
+ SAVE,
+ SAVE_AS,
+ OPEN,
+ INTERFACES,
+ TIMER,
+ VARIABLES,
+ GENERATE_CODE,
+ COMPILE,
+ ANY
+} Button;
+
+typedef enum TypeInitial {
+ NORMAL,
+ INIT,
+ TEXT,
+ ALL,
+ TRANS_LEFT,
+ TRANS_RIGHT,
+ TRANS_MIDPOINT,
+ NONE
+} TypeInitial;
+
+// Definition of this class
+class VisualHFSM : public Gtk::Window {
+public:
+ // Constructor
+ VisualHFSM ();
+
+ // Destructor
+ virtual ~VisualHFSM ();
+
+ // Methods for signals from save and load files
+ void on_save_file ( std::string path );
+ void on_load_file ( std::string path );
+
+private:
+ // Main window
+ Gtk::Viewport* viewport_schema;
+ Goocanvas::Canvas* canvas;
+
+ // For the draggin item
+ Glib::RefPtr<Goocanvas::Item> dragging;
+ int drag_x, drag_y;
+
+ // The state to determine the action (create signals or not, add the item to the node...)
+ TypeInitial state;
+
+ // The ID for the subautomata created
+ int id, idguinode, idguitransition;
+
+ // GroupModel for the items
+ Glib::RefPtr<Goocanvas::ItemModel> root;
+ // The scrolled window that contains everything
+ Gtk::ScrolledWindow* sw;
+
+ // The treeview
+ //Tree model columns:
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ ModelColumns () { add(m_col_id); add(m_col_name); }
+
+ Gtk::TreeModelColumn<int> m_col_id;
+ Gtk::TreeModelColumn<Glib::ustring> m_col_name;
+ };
+ ModelColumns m_Columns;
+
+ Gtk::TreeView* treeview;
+ Glib::RefPtr<Gtk::TreeStore> refTreeModel;
+
+ // Popup menus
+ Glib::RefPtr<Gtk::ActionGroup> actionGroupTransition;
+ Glib::RefPtr<Gtk::UIManager> UIManagerTransition;
+ Gtk::Menu* menuPopupTransition;
+
+ Glib::RefPtr<Gtk::ActionGroup> actionGroupItem;
+ Glib::RefPtr<Gtk::UIManager> UIManagerItem;
+ Gtk::Menu* menuPopupItem;
+
+ bool showingMenuPopup, copyPressed;
+
+ Glib::RefPtr<Gtk::ActionGroup> actionGroupPaste;
+ Glib::RefPtr<Gtk::UIManager> UIManagerPaste;
+ Gtk::Menu* menuPopupPaste;
+
+ // Options for the selected item
+ Glib::RefPtr<Goocanvas::Item> selectedItem;
+ bool isSelected;
+ Glib::RefPtr<Goocanvas::Item> textItem;
+
+ // Options for the creation of transitions
+ Glib::RefPtr<Goocanvas::Item> lastItem, theOtherItem, leftItemTrans, rightItemTrans;
+ int transitionsCounter;
+
+ // Where the mouse is
+ float event_x, event_y;
+
+ // The subautomata list and current subautomata
+ std::list <GuiSubautomata> subautomataList;
+ GuiSubautomata* currentSubautomata;
+
+ // Buttons
+ Gtk::Button *button_up, *button_transition, *button_state, *button_save;
+ Gtk::Button *button_save_as, *button_open, *button_interfaces;
+ Gtk::Button *button_timer, *button_variables, *button_generate_code, *button_compile;
+
+ // For files (load and save)
+ Gtk::Button *button_cancelfile, *button_openfile, *button_savefile;
+ std::string filepath;
+ SaveFileDialog* sfdialog;
+ LoadFileDialog* lfdialog;
+
+ Button lastButton;
+
+ // Internal methods
+ int get_all_widgets ();
+ void assign_signals ();
+ void create_menu_transition ();
+ void create_menu_item ();
+ void create_menu_paste ();
+ void create_new_state ( int idSubautomataSon );
+ void create_new_transition ( const Glib::RefPtr<Goocanvas::Item>& item );
+ void create_new_transition ( Point origin, Point final, Point midpoint, int id );
+
+ // Methods for signals
+ // Of the menus
+ void on_menu_transition_rename ();
+ void on_menu_transition_edit ();
+ void on_menu_transition_remove ();
+
+ void on_menu_state_rename ();
+ void on_menu_state_edit ();
+ void on_menu_state_markasinitial ();
+ void on_menu_state_copy ();
+ void on_menu_state_remove ();
+
+ void on_menu_canvas_paste ();
+
+ // Of the treeview
+
+ // Of the schema
+ bool on_schema_event ( GdkEvent* event );
+
+ void on_item_created ( const Glib::RefPtr<Goocanvas::Item>& item,
+ const Glib::RefPtr<Goocanvas::ItemModel>& model );
+ bool on_item_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event );
+ bool on_item_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event );
+ bool on_item_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventMotion* event );
+ bool on_item_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event );
+ bool on_item_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event );
+ bool on_transition_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event );
+ bool on_transition_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventButton* event );
+ bool on_transition_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventMotion* event );
+ bool on_transition_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event );
+ bool on_transition_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
+ GdkEventCrossing* event );
+
+ // Of buttons
+ void on_options_clicked_up ();
+ void on_options_clicked_transition ();
+ void on_options_clicked_state ();
+ void on_options_clicked_save ();
+ void on_options_clicked_save_as ();
+ void on_options_clicked_open ();
+ void on_options_clicked_interfaces ();
+ void on_options_clicked_timer ();
+ void on_options_clicked_variables ();
+ void on_options_clicked_generate_code ();
+ void on_options_clicked_compile ();
+
+ // General
+ GuiSubautomata* getSubautomata ( int idSubautomata );
+ GuiSubautomata* getSubautomataWithIdFather ( int idFather );
+ int loadSubautomata ( std::list<SubAutomata> subautomataList );
+ void removeAllGui ();
+ void removeAllSubautomata ();
+ bool hasEnding ( std::string const &fullString, std::string const &ending );
+ bool replaceFile ( std::string& str, const std::string& character, std::string to );
+ bool replace ( std::string& str, const std::string& from, const std::string& to );
+
+ bool fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather );
+ bool removeFromTreeView ( int id, Gtk::TreeModel::Children child );
+ int getIdNodeInSubautomata ( int subautomataId );
+
+ void removeRecursively ( GuiSubautomata* guisub, GuiNode* gnode );
+ void remove ( GuiSubautomata* guisub, GuiNode* gnode );
+
+ int getIdSubautomataWithNode ( int idNode );
+}; // Class VisualHFSM
+
+#endif // VISUALHFSM_H
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/xmlparser.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/xmlparser.cpp 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,315 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "xmlparser.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+MySaxParser::MySaxParser () : xmlpp::SaxParser() {
+ this->mapStringValues["VisualHFSM"] = E_VISUALHFSM;
+ this->mapStringValues["SubAutomata"] = E_SUBAUTOMATA;
+ this->mapStringValues["state"] = E_STATE;
+ this->mapStringValues["posx"] = E_POSX;
+ this->mapStringValues["posy"] = E_POSY;
+ this->mapStringValues["name"] = E_NAME;
+ this->mapStringValues["idSubautomataSon"] = E_IDSUBAUTOMATASON;
+ this->mapStringValues["code"] = E_CODE;
+ this->mapStringValues["transition"] = E_TRANSITION;
+ this->mapStringValues["origin"] = E_ORIGIN;
+ this->mapStringValues["destiny"] = E_DESTINY;
+ this->mapStringValues["trans"] = E_TRANS;
+ this->mapStringValues["libraries"] = E_LIBRARIES;
+ this->mapStringValues["lib"] = E_LIB;
+ this->mapStringValues["iteration_time"] = E_ITERATION;
+ this->mapStringValues["variables"] = E_VARS;
+ this->mapStringValues["functions"] = E_FUNCTIONS;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+MySaxParser::~MySaxParser () {}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+std::list<SubAutomata> MySaxParser::getListSubautomata () {
+ return this->subautomataList;
+}
+
+/*************************************************************
+ * OVERRIDES
+ *************************************************************/
+void MySaxParser::on_start_document () {
+// std::cout << "on_start_document()" << std::endl;
+}
+
+void MySaxParser::on_end_document () {
+// std::cout << "on_end_document()" << std::endl;
+}
+
+void MySaxParser::on_start_element ( const Glib::ustring& name,
+ const AttributeList& attributes ) {
+ switch (this->mapStringValues[name.c_str()]) {
+ case E_VISUALHFSM :
+ this->option = E_VISUALHFSM;
+ break;
+ case E_SUBAUTOMATA: {
+ int idSubautomata, idFather;
+ for (xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin();
+ iter != attributes.end(); iter++) {
+ if (iter->name.compare("id") == 0) {
+ std::stringstream toint(iter->value);
+ toint >> idSubautomata;
+ } else if (iter->name.compare("idFather") == 0) {
+ std::stringstream toint(iter->value);
+ toint >> idFather;
+ }
+ }
+ SubAutomata newsubautomata(idSubautomata, idFather);
+ this->subautomataList.push_back(newsubautomata);
+ this->subautomata = this->getSubautomataWithId(idSubautomata);
+ this->option = E_SUBAUTOMATA;
+ break;
+ }
+ case E_STATE: {
+ int idNode;
+ bool initial;
+ for (xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin();
+ iter != attributes.end(); iter++) {
+ if (iter->name.compare("id") == 0) {
+ std::stringstream toint(iter->value);
+ toint >> idNode;
+ } else if (iter->name.compare("initial") == 0) {
+ if (iter->value.compare("true") == 0)
+ initial = true;
+ else
+ initial = false;
+ }
+ }
+ this->node = new Node(idNode, initial);
+ this->state = true;
+ this->option = E_STATE;
+ break;
+ }
+ case E_POSX:
+ this->option = E_POSX;
+ break;
+ case E_POSY:
+ this->option = E_POSY;
+ break;
+ case E_NAME:
+ this->option = E_NAME;
+ break;
+ case E_IDSUBAUTOMATASON:
+ this->option = E_IDSUBAUTOMATASON;
+ break;
+ case E_CODE:
+ this->option = E_CODE;
+ this->code.clear();
+ break;
+ case E_TRANSITION: {
+ int idTransition;
+ for (xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin();
+ iter != attributes.end(); iter++) {
+ if (iter->name.compare("id") == 0) {
+ std::stringstream toint(iter->value);
+ toint >> idTransition;
+ }
+ }
+ this->transition = new Transition(idTransition);
+ this->option = E_TRANSITION;
+ break;
+ }
+ case E_ORIGIN:
+ this->option = E_ORIGIN;
+ break;
+ case E_DESTINY:
+ this->option = E_DESTINY;
+ break;
+ case E_TRANS: {
+ for (xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin();
+ iter != attributes.end(); iter++) {
+ if (iter->name.compare("type") == 0) {
+ this->type = iter->value;
+ }
+ }
+ this->option = E_TRANS;
+ this->code.clear();
+ break;
+ }
+ case E_LIBRARIES:
+ this->option = E_LIBRARIES;
+ break;
+ case E_LIB:
+ this->option = E_LIB;
+ this->code.clear();
+ break;
+ case E_ITERATION:
+ this->option = E_ITERATION;
+ break;
+ case E_VARS:
+ this->option = E_VARS;
+ break;
+ case E_FUNCTIONS:
+ this->option = E_FUNCTIONS;
+ this->code.clear();
+ break;
+ default:
+ break;
+ }
+}
+
+void MySaxParser::on_end_element ( const Glib::ustring& name ) {
+ switch (this->mapStringValues[name]) {
+ case E_STATE:
+ this->state = false;
+ this->subautomata->addNode(this->node->copy(), this->point->copyAsPointer());
+ break;
+ case E_CODE:
+ this->node->setCode(this->code);
+ break;
+ case E_TRANSITION:
+ this->subautomata->addTransition(this->transition->copy(), this->point->copyAsPointer());
+ break;
+ case E_TRANS:
+ this->transition->setTrans(this->type, this->code);
+ break;
+ case E_LIB:
+ this->listInterfaces.push_back(this->code);
+ break;
+ case E_LIBRARIES:
+ this->subautomata->setInterfaces(this->listInterfaces);
+ this->listInterfaces.clear();
+ break;
+ case E_FUNCTIONS:
+ this->subautomata->setFunctions(this->code);
+ break;
+ default:
+ break;
+ }
+}
+
+void MySaxParser::on_characters ( const Glib::ustring& text ) {
+ switch (this->option) {
+ case E_VISUALHFSM:
+ break;
+ case E_SUBAUTOMATA:
+ break;
+ case E_STATE:
+ break;
+ case E_POSX: {
+ this->x = atof(text.c_str());
+ break;
+ }
+ case E_POSY: {
+ this->point = new Point(this->x, atof(text.c_str()));
+ break;
+ }
+ case E_NAME: {
+ if (this->state)
+ this->node->setName(text);
+ else
+ this->transition->setName(text);
+ break;
+ }
+ case E_IDSUBAUTOMATASON: {
+ int idSubautomataSon;
+ std::stringstream toint(text);
+ toint >> idSubautomataSon;
+ this->node->setIdSubautomataSon(idSubautomataSon);
+ break;
+ }
+ case E_CODE: {
+ this->code += text;
+ break;
+ }
+ case E_TRANSITION:
+ break;
+ case E_ORIGIN: {
+ int origin;
+ std::stringstream toint(text);
+ toint >> origin;
+ this->transition->setIdOrigin(origin);
+ break;
+ }
+ case E_DESTINY: {
+ int destiny;
+ std::stringstream toint(text);
+ toint >> destiny;
+ this->transition->setIdDestiny(destiny);
+ break;
+ }
+ case E_TRANS: {
+ this->code += text;
+ break;
+ }
+ case E_LIB: {
+ this->code += text;
+ break;
+ }
+ case E_ITERATION: {
+ this->subautomata->setTime(text);
+ break;
+ }
+ case E_VARS: {
+ this->subautomata->setVariables(text);
+ break;
+ }
+ case E_FUNCTIONS: {
+ this->code += text;
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void MySaxParser::on_comment ( const Glib::ustring& text ) {
+// std::cout << "on_comment(): " << text << std::endl;
+}
+
+void MySaxParser::on_warning ( const Glib::ustring& text ) {
+ std::cout << "on_warning(): " << text << std::endl;
+}
+
+void MySaxParser::on_error ( const Glib::ustring& text ) {
+ std::cout << "on_error(): " << text << std::endl;
+}
+
+void MySaxParser::on_fatal_error ( const Glib::ustring& text ) {
+ std::cout << "on_fatal_error(): " << text << std::endl;
+}
+
+/*************************************************************
+ * PRIVATE FUNCTIONS
+ *************************************************************/
+SubAutomata* MySaxParser::getSubautomataWithId ( int id ) {
+ std::list<SubAutomata>::iterator subautomataListIterator = this->subautomataList.begin();
+ while ( (subautomataListIterator->getId() != id) &&
+ (subautomataListIterator != this->subautomataList.end()) )
+ subautomataListIterator++;
+
+ if (subautomataListIterator != this->subautomataList.end())
+ return &*subautomataListIterator;
+
+ return NULL;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/xmlparser.h
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/xmlparser.h 2013-10-10 16:28:39 UTC (rev 1036)
@@ -0,0 +1,103 @@
+/*
+ * 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 <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef XMLPARSER_H
+#define XMLPARSER_H
+
+#include <map>
+#include <iostream>
+#include <stdlib.h>
+#include <libxml++/libxml++.h>
+
+#include "common.h"
+#include "point.h"
+#include "node.h"
+#include "transition.h"
+#include "subautomata.h"
+
+typedef enum Element {
+ E_VISUALHFSM,
+ E_SUBAUTOMATA,
+ E_STATE,
+ E_POSX,
+ E_POSY,
+ E_NAME,
+ E_IDSUBAUTOMATASON,
+ E_CODE,
+ E_TRANSITION,
+ E_ORIGIN,
+ E_DESTINY,
+ E_TRANS,
+ E_LIBRARIES,
+ E_LIB,
+ E_ITERATION,
+ E_VARS,
+ E_FUNCTIONS
+} Element;
+
+// Definition of this class
+class MySaxParser : public xmlpp::SaxParser {
+public:
+ // Constructor
+ MySaxParser ();
+
+ // Destructor
+ virtual ~MySaxParser ();
+
+ // Getters
+ std::list<SubAutomata> getListSubautomata ();
+
+protected:
+ // Overrides:
+ virtual void on_start_document ();
+ virtual void on_end_document ();
+ virtual void on_start_element ( const Glib::ustring& name,
+ const AttributeList& attributes );
+ virtual void on_end_element ( const Glib::ustring& name );
+ virtual void on_characters ( const Glib::ustring& characters );
+ virtual void on_comment ( const Glib::ustring& text );
+ virtual void on_warning ( const Glib::ustring& text );
+ virtual void on_error ( const Glib::ustring& text );
+ virtual void on_fatal_error ( const Glib::ustring& text );
+
+private:
+ // Data structure
+ std::list <SubAutomata> subautomataList;
+ std::map<std::string, Element> mapStringValues;
+
+ bool state;
+ float x;
+ std::string type;
+
+ Element option;
+
+ SubAutomata* subautomata;
+ Transition* transition;
+ Node* node;
+ Point* point;
+
+ std::list<std::string> listInterfaces;
+ std::string code;
+
+ // Private functions
+ SubAutomata* getSubautomataWithId ( int id );
+}; // MySaxParser
+
+#endif // XMLPARSER_H
\ No newline at end of file
More information about the Jderobot-admin
mailing list