[Lemon-commits] [lemon_svn] hegyi: r2465 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:52:53 CET 2006
Author: hegyi
Date: Wed Jan 11 16:49:06 2006
New Revision: 2465
Modified:
hugo/trunk/gui/main_win.cc
hugo/trunk/gui/new_map_win.h
Log:
Documentation of NewMapWin.
Modified: hugo/trunk/gui/main_win.cc
==============================================================================
--- hugo/trunk/gui/main_win.cc (original)
+++ hugo/trunk/gui/main_win.cc Wed Jan 11 16:49:06 2006
@@ -457,7 +457,7 @@
void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge)
{
int i=0;
- for(;((i<tabnames.size())&&(tabnames[i]!=tabname));i++)
+ for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++)
{
}
createNewMapWinAfterSignal(tabs[i], itisedge);
Modified: hugo/trunk/gui/new_map_win.h
==============================================================================
--- hugo/trunk/gui/new_map_win.h (original)
+++ hugo/trunk/gui/new_map_win.h Wed Jan 11 16:49:06 2006
@@ -11,52 +11,124 @@
#include <libgnomecanvasmm/polygon.h>
#include <stack>
+///Graphical interface for node/edge map creation.
+
///This class is responsible for creating a window,
///on which the parameters of a new map can be set.
-
class NewMapWin : public Gtk::Dialog
{
+ ///The \ref NoteBookTab in which the new map has to be placed.
NoteBookTab & mytab;
public:
+
+ ///Struct to be able to evaluate expressions.
+
+ ///Initial values of map elements can be given
+ ///by numbers or by expressions. From expressions
+ ///we build first a tree. This is the data structure
+ ///that can store one tree element.
struct tree_node
{
+ ///Character stored in this tree element
char ch;
+ ///Left child of tree element.
tree_node * left_child;
+ ///Right child of tree element.
tree_node * right_child;
};
- ///Constructor of NewMapWin creates the widgets shown in NewMapWin.
+ ///Constructor of NewMapWin.
+
+ ///It creates the widgets shown in
+ ///NewMapWin.
NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true);
- ///Signal on button is connected to this function,
- ///Therefore this function determines whether to
- ///call the map/creatort function, and if yes, it
- //tells it the attributes.(name, default value)
+ ///Callback function for OK button. It creates the map.
+
+ ///This function determines whether the input is correct:
+ ///the name of new map must not be already used, the expression
+ ///that gives tha initial values of map elements has to be valid.
+ ///If input is correct it creates and registrates the new map
+ ///to the correct place. (\ref mytab)
virtual void on_response(int response_id);
+ ///Close window if Esc key pressed.
virtual bool closeIfEscapeIsPressed(GdkEventKey*);
- ///Function that creates a tree from an appropriately manipulated string
- tree_node * weightedString2Tree(std::string, std::vector<unsigned int> &, int);
+ ///Function that creates a tree from an appropriately manipulated string.
- ///Function that creates a string from a tree by postorder reading.
- std::string postOrder(tree_node *);
+ ///Tree is builded according to priorities of operations in expression given by string.
+ ///Priorities are indicated in a vector that contains weights for each operation.
+ ///\param to_tree string to build tree from
+ ///\param weights weights (priorities)
+ ///\param offset this function call is recursive. This parameter tells us,
+ ///with which part of the string do we have to deal with.
+ tree_node * weightedString2Tree(std::string to_tree, std::vector<unsigned int> & weights, int offset);
+
+ ///Function that creates a string from a tree by postorder reading.
+
+ ///This is the last step of creating polishform
+ ///from a given expression string.
+ ///\param root the root of the tree to read through
+ std::string postOrder(tree_node * root);
+
+ ///From the given expression it creates expression given in polish form.
+
+ ///First it substitutes variables and numbers in the given expression.
+ ///The substitutions will be one character long local variables.
+ ///The substituted-substitution pair is registrated in \ref ch2var.
+ ///After that it gives weights fo each character in substituted expression.
+ ///Weights are calculated according to the priority of operations in expression.
+ ///Then it creates tree (\ref tree_node) from the weighted string. (\ref weightedString2Tree)
+ ///\param to_polish the string to turn into polish_form
+ ///\param itisedge do we have to create an edgemap or a nodemap.
+ ///It is important, because variables are maps and if expression
+ ///citates a map that does not exists the expression is not valid.
+ ///But to determine, whether the map exists we have to know where
+ ///to search for it. And of course for a new edgemap only edgemaps can be serve with values.
+ std::string string2Polishform(std::string to_polish, bool itisedge);
+
+ ///Returns whether a string can be used as value in an expression.
+
+ ///The given string has to be either a mapname or a number. If it is a mapname
+ ///we have to know whether it is an edgemap or a nodemap.
+ ///\param variable the string about the function has to determine whether it is usable in expressions
+ ///\param itisedge should the mapname be between edgemaps, or nodemaps
+ bool validVariable(std::string variable, bool itisedge);
+
+ ///Deletes the whole tree created for translating string to polishform.
+
+ ///\param root
+ ///root of the tree
+ void deleteTree(tree_node * root);
- std::string string2Polishform(std::string, bool);
+ ///Dictionary of substitutions in expression.
- bool validVariable(std::string, bool);
+ ///Variables and numbers are substituted with one character long variables in expressions.
+ ///This is the dictionary.
+ std::map<char, std::string> ch2var;
- void deleteTree(tree_node *);
+ ///Entry which gives us the name of new map.
+ Gtk::Entry name;
- std::map<char, std::string> ch2var;
+ ///Entry which gives us the initial values of elements of new map.
- Gtk::Entry name, default_value;
+ ///Initial value can be a number or an expression after that the
+ ///initial value for each map element can be calculated.
+ Gtk::Entry default_value;
+ ///GTK Designing object.
Gtk::Table * table;
+
+ ///Information holder in window.
Gtk::Label * label;
- Gtk::RadioButton node, edge;
+ ///If selected, nodemap will be created.
+ Gtk::RadioButton node;
+
+ ///If selected, edgemap will be created.
+ Gtk::RadioButton edge;
};
#endif //NEWMAPWIN_H
More information about the Lemon-commits
mailing list