No segmentation fault will be occured if two nodes are exactly overlap each other, AND they are connected.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
24 #include <all_include.h>
26 #include <libgnomecanvasmm.h>
27 #include <libgnomecanvasmm/polygon.h>
30 ///Graphical interface for node/edge map creation.
32 ///This class is responsible for creating a window,
33 ///on which the parameters of a new map can be set.
34 class NewMapWin : public Gtk::Dialog
36 ///The \ref NoteBookTab in which the new map has to be placed.
41 ///Struct to be able to evaluate expressions.
43 ///Initial values of map elements can be given
44 ///by numbers or by expressions. From expressions
45 ///we build first a tree according to the priorities
46 ///of operations in the expression. This is the data
48 ///that can store one tree element.
51 ///Character stored in this tree element
53 ///Left child of tree element.
54 tree_node * left_child;
55 ///Right child of tree element.
56 tree_node * right_child;
59 ///Constructor of NewMapWin.
61 ///It creates the widgets shown in
63 NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true);
65 ///Callback function for OK button. It creates the map.
67 ///This function determines whether the input is correct:
68 ///the name of new map must not be already used, the expression
69 ///that gives tha initial values of map elements has to be valid.
70 ///If input is correct it creates and registrates the new map
71 ///to the correct place. (\ref mytab)
72 virtual void on_response(int response_id);
74 ///Close window if Esc key pressed.
75 virtual bool closeIfEscapeIsPressed(GdkEventKey*);
77 ///Function that creates a tree from an appropriately manipulated string.
79 ///Tree is builded according to priorities of operations in expression given by string.
80 ///Priorities are indicated in a vector that contains weights for each operation.
81 ///\param to_tree string to build tree from
82 ///\param weights weights (priorities)
83 ///\param offset this function call is recursive. This parameter tells us,
84 ///with which part of the string do we have to deal with.
85 tree_node * weightedString2Tree(std::string to_tree, std::vector<unsigned int> & weights, int offset);
87 ///Function that creates a string from a tree by postorder reading.
89 ///This is the last step of creating polishform
90 ///from a given expression string.
91 ///\param root the root of the tree to read through
92 std::string postOrder(tree_node * root);
94 ///From the given expression it creates expression given in polish form.
96 ///First it substitutes variables and numbers in the given expression.
97 ///The substitutions will be one character long local variables.
98 ///The substituted-substitution pair is registrated in \ref ch2var.
99 ///After that it gives weights fo each character in substituted expression.
100 ///Weights are calculated according to the priority of operations in expression.
101 ///Then it creates tree (\ref tree_node) from the weighted string. (\ref weightedString2Tree)
102 ///\param to_polish the string to turn into polish_form
103 ///\param itisedge do we have to create an edgemap or a nodemap.
104 ///It is important, because variables are maps and if expression
105 ///citates a map that does not exists the expression is not valid.
106 ///But to determine, whether the map exists we have to know where
107 ///to search for it. And of course for a new edgemap only edgemaps can be serve with values.
108 std::string string2Polishform(std::string to_polish, bool itisedge);
110 ///Returns whether a string can be used as value in an expression.
112 ///The given string has to be either a mapname or a number. If it is a mapname
113 ///we have to know whether it is an edgemap or a nodemap.
114 ///\param variable the string about the function has to determine whether it is usable in expressions
115 ///\param itisedge should the mapname be between edgemaps, or nodemaps
116 bool validVariable(std::string variable, bool itisedge);
118 ///Deletes the whole tree created for translating string to polishform.
122 void deleteTree(tree_node * root);
124 ///Dictionary of substitutions in expression.
126 ///Variables and numbers are substituted with one character long variables in expressions.
127 ///This is the dictionary.
128 std::map<char, std::string> ch2var;
130 ///Entry which gives us the name of new map.
133 ///Entry which gives us the initial values of elements of new map.
135 ///Initial value can be a number or an expression after that the
136 ///initial value for each map element can be calculated.
137 Gtk::Entry default_value;
139 ///GTK Designing object.
142 ///Information holder in window.
145 ///If selected, nodemap will be created.
146 Gtk::RadioButton node;
148 ///If selected, edgemap will be created.
149 Gtk::RadioButton edge;