Documentation of NewMapWin.
authorhegyi
Wed, 11 Jan 2006 15:49:06 +0000
changeset 18904a583e07d4b8
parent 1889 edcb68a93a95
child 1891 56a718d144c4
Documentation of NewMapWin.
gui/main_win.cc
gui/new_map_win.h
     1.1 --- a/gui/main_win.cc	Wed Jan 11 15:06:17 2006 +0000
     1.2 +++ b/gui/main_win.cc	Wed Jan 11 15:49:06 2006 +0000
     1.3 @@ -457,7 +457,7 @@
     1.4  void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge)
     1.5  {
     1.6    int i=0;
     1.7 -  for(;((i<tabnames.size())&&(tabnames[i]!=tabname));i++)
     1.8 +  for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++)
     1.9      {
    1.10      }
    1.11    createNewMapWinAfterSignal(tabs[i], itisedge);
     2.1 --- a/gui/new_map_win.h	Wed Jan 11 15:06:17 2006 +0000
     2.2 +++ b/gui/new_map_win.h	Wed Jan 11 15:49:06 2006 +0000
     2.3 @@ -11,52 +11,124 @@
     2.4  #include <libgnomecanvasmm/polygon.h>
     2.5  #include <stack>
     2.6  
     2.7 +///Graphical interface for node/edge map creation.
     2.8 +
     2.9  ///This class is responsible for creating a window,
    2.10  ///on which the parameters of a new map can be set.
    2.11 -
    2.12  class NewMapWin : public Gtk::Dialog
    2.13  {
    2.14 +  ///The \ref NoteBookTab in which the new map has to be placed.
    2.15    NoteBookTab & mytab;
    2.16  
    2.17  public:
    2.18 +
    2.19 +  ///Struct to be able to evaluate expressions.
    2.20 +
    2.21 +  ///Initial values of map elements can be given
    2.22 +  ///by numbers or by expressions. From expressions
    2.23 +  ///we build first a tree. This is the data structure
    2.24 +  ///that can store one tree element.
    2.25    struct tree_node
    2.26    {
    2.27 +    ///Character stored in this tree element
    2.28      char ch;
    2.29 +    ///Left child of tree element.
    2.30      tree_node * left_child;
    2.31 +    ///Right child of tree element.
    2.32      tree_node * right_child;
    2.33    };
    2.34    
    2.35 -  ///Constructor of NewMapWin creates the widgets shown in NewMapWin.
    2.36 +  ///Constructor of NewMapWin.
    2.37 +
    2.38 +  ///It creates the widgets shown in
    2.39 +  ///NewMapWin.
    2.40    NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true);
    2.41  
    2.42 -  ///Signal on button is connected to this function,
    2.43 -  ///Therefore this function determines whether to
    2.44 -  ///call the map/creatort function, and if yes, it
    2.45 -  //tells it the attributes.(name, default value)
    2.46 +  ///Callback function for OK button. It creates the map.
    2.47 +  
    2.48 +  ///This function determines whether the input is correct:
    2.49 +  ///the name of new map must not be already used, the expression
    2.50 +  ///that gives tha initial values of map elements has to be valid.
    2.51 +  ///If input is correct it creates and registrates the new map
    2.52 +  ///to the correct place. (\ref mytab)
    2.53    virtual void on_response(int response_id);
    2.54  
    2.55 +  ///Close window if Esc key pressed.
    2.56    virtual bool closeIfEscapeIsPressed(GdkEventKey*);
    2.57  
    2.58 -  ///Function that creates a tree from an appropriately manipulated string
    2.59 -  tree_node * weightedString2Tree(std::string, std::vector<unsigned int> &, int);
    2.60 +  ///Function that creates a tree from an appropriately manipulated string.
    2.61  
    2.62 -  ///Function  that creates a string from a tree by postorder reading.
    2.63 -  std::string postOrder(tree_node *);
    2.64 +  ///Tree is builded according to priorities of operations in expression given by string.
    2.65 +  ///Priorities are indicated in a vector that contains weights for each operation.
    2.66 +  ///\param to_tree string to build tree from
    2.67 +  ///\param weights weights (priorities)
    2.68 +  ///\param offset this function call is recursive. This parameter tells us,
    2.69 +  ///with which part of the string do we have to deal with.
    2.70 +  tree_node * weightedString2Tree(std::string to_tree, std::vector<unsigned int> & weights, int offset);
    2.71  
    2.72 -  std::string string2Polishform(std::string, bool);
    2.73 +  ///Function that creates a string from a tree by postorder reading.
    2.74  
    2.75 -  bool validVariable(std::string, bool);
    2.76 +  ///This is the last step of creating polishform
    2.77 +  ///from a given expression string.
    2.78 +  ///\param root the root of the tree to read through
    2.79 +  std::string postOrder(tree_node * root);
    2.80  
    2.81 -  void deleteTree(tree_node *);
    2.82 +  ///From the given expression it creates expression given in polish form.
    2.83  
    2.84 +  ///First it substitutes variables and numbers in the given expression.
    2.85 +  ///The substitutions will be one character long local variables.
    2.86 +  ///The substituted-substitution pair is registrated in \ref ch2var.
    2.87 +  ///After that it gives weights fo each character in substituted expression.
    2.88 +  ///Weights are calculated according to the priority of operations in expression.
    2.89 +  ///Then it creates tree (\ref tree_node) from the weighted string. (\ref weightedString2Tree)
    2.90 +  ///\param to_polish the string to turn into polish_form
    2.91 +  ///\param itisedge do we have to create an edgemap or a nodemap.
    2.92 +  ///It is important, because variables are maps and if expression
    2.93 +  ///citates a map that does not exists the expression is not valid.
    2.94 +  ///But to determine, whether the map exists we have to know where
    2.95 +  ///to search for it. And of course for a new edgemap only edgemaps can be serve with values. 
    2.96 +  std::string string2Polishform(std::string to_polish, bool itisedge);
    2.97 +
    2.98 +  ///Returns whether a string can be used as value in an expression.
    2.99 +
   2.100 +  ///The given string has to be either a mapname or a number. If it is a mapname
   2.101 +  ///we have to know whether it is an edgemap or a nodemap.
   2.102 +  ///\param variable the string about the function has to determine whether it is usable in expressions
   2.103 +  ///\param itisedge should the mapname be between edgemaps, or nodemaps
   2.104 +  bool validVariable(std::string variable, bool itisedge);
   2.105 +
   2.106 +  ///Deletes the whole tree created for translating string to polishform.
   2.107 + 
   2.108 +  ///\param root
   2.109 +  ///root of the tree
   2.110 +  void deleteTree(tree_node * root);
   2.111 +
   2.112 +  ///Dictionary of substitutions in expression.
   2.113 +
   2.114 +  ///Variables and numbers are substituted with one character long variables in expressions.
   2.115 +  ///This is the dictionary.
   2.116    std::map<char, std::string> ch2var;
   2.117  
   2.118 -  Gtk::Entry name, default_value;
   2.119 +  ///Entry which gives us the name of new map.
   2.120 +  Gtk::Entry name;
   2.121  
   2.122 +  ///Entry which gives us the initial values of elements of new map.
   2.123 +
   2.124 +  ///Initial value can be a number or an expression after that the
   2.125 +  ///initial value for each map element can be calculated.
   2.126 +  Gtk::Entry default_value;
   2.127 +
   2.128 +  ///GTK Designing object.
   2.129    Gtk::Table * table;
   2.130 +
   2.131 +  ///Information holder in window.
   2.132    Gtk::Label * label;
   2.133  
   2.134 -  Gtk::RadioButton node, edge;
   2.135 +  ///If selected, nodemap will be created.
   2.136 +  Gtk::RadioButton node;
   2.137 +
   2.138 +  ///If selected, edgemap will be created.
   2.139 +  Gtk::RadioButton edge;
   2.140  };
   2.141  
   2.142  #endif //NEWMAPWIN_H