SVN revision 3500 made compilable with Lemon 1.0.
authorPeter Hegyi <hegyi@tmit.bme.hu>
Mon, 07 Jul 2008 08:10:39 -0500
changeset 167188bd752db
parent 0 0e4f009eab8b
child 2 fdb8a163000f
SVN revision 3500 made compilable with Lemon 1.0.
.hgignore
AUTHORS
COPYING
Doxyfile
LICENSE
Makefile.am
NEWS
README
algobox.cc
algobox.h
algowin.cc
algowin.h
all_include.h
autopackage/default.apspec.in
background_chooser_dialog.cc
background_chooser_dialog.h
bootstrap
color.lgf
configure.ac
design_win.cc
design_win.h
dijkstrabox.cc
dijkstrabox.h
eps_win.cc
eps_win.h
file_import_dialog.cc
file_import_dialog.h
gdc-broken_edge.cc
gettext.h
glemon.spec.in
graph-displayer.cc
graph_displayer_canvas-edge.cc
graph_displayer_canvas-event.cc
graph_displayer_canvas-node.cc
graph_displayer_canvas-zoom.cc
graph_displayer_canvas.cc
graph_displayer_canvas.h
graphocska.lgf
gui_reader.cc
gui_reader.h
gui_writer.cc
gui_writer.h
i18n.h
icons/addlink.png
icons/addnode.png
icons/delete.png
icons/editlink.png
icons/editnode.png
icons/eps.png
icons/move.png
icons/newmap.png
io_helper.cc
io_helper.h
kruskalbox.cc
kruskalbox.h
m4/Makefile.am
main_win.cc
main_win.h
map_value.cc
map_value.h
map_value_map.cc
map_value_map.h
map_win.cc
map_win.h
mapselector.cc
mapselector.h
mapstorage.cc
mapstorage.h
nbtab.cc
nbtab.h
new_map_win.cc
new_map_win.h
po/LINGUAS
po/Makevars
po/POTFILES.in
po/glemon.pot
po/hu.po
save_details_dialog.cc
save_details_dialog.h
save_details_widget.cc
save_details_widget.h
xml.h
xymap.h
     1.1 --- a/.hgignore	Mon Jun 23 11:48:43 2008 +0100
     1.2 +++ b/.hgignore	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -26,6 +26,24 @@
     1.4  .libs/*
     1.5  .deps/*
     1.6  demo/*.eps
     1.7 +m4/*.m4
     1.8 +ABOUT-NLS
     1.9 +autopackage/default.apspec
    1.10 +glemon
    1.11 +glemon.spec
    1.12 +guipixbufs.h
    1.13 +po/boldquot.sed
    1.14 +po/en@boldquot.header
    1.15 +po/en@quot.header
    1.16 +po/hu.gmo
    1.17 +po/insert-header.sin
    1.18 +po/Makefile.in.in
    1.19 +po/Makevars.template
    1.20 +po/POTFILES
    1.21 +po/quot.sed
    1.22 +po/remove-potcdate.sin
    1.23 +po/Rules-quot
    1.24 +po/stamp-po
    1.25  
    1.26  syntax: regexp
    1.27  (.*/)?\#[^/]*\#$
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/AUTHORS	Mon Jul 07 08:10:39 2008 -0500
     2.3 @@ -0,0 +1,1 @@
     2.4 +To be filled
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/COPYING	Mon Jul 07 08:10:39 2008 -0500
     3.3 @@ -0,0 +1,1 @@
     3.4 +To be filled
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/Doxyfile	Mon Jul 07 08:10:39 2008 -0500
     4.3 @@ -0,0 +1,273 @@
     4.4 +# Doxyfile 1.4.5
     4.5 +
     4.6 +#---------------------------------------------------------------------------
     4.7 +# Project related configuration options
     4.8 +#---------------------------------------------------------------------------
     4.9 +PROJECT_NAME           = glemon
    4.10 +PROJECT_NUMBER         = 0.1
    4.11 +OUTPUT_DIRECTORY       = 
    4.12 +CREATE_SUBDIRS         = NO
    4.13 +OUTPUT_LANGUAGE        = English
    4.14 +USE_WINDOWS_ENCODING   = NO
    4.15 +BRIEF_MEMBER_DESC      = YES
    4.16 +REPEAT_BRIEF           = YES
    4.17 +ABBREVIATE_BRIEF       = "The $name class" \
    4.18 +                         "The $name widget" \
    4.19 +                         "The $name file" \
    4.20 +                         is \
    4.21 +                         provides \
    4.22 +                         specifies \
    4.23 +                         contains \
    4.24 +                         represents \
    4.25 +                         a \
    4.26 +                         an \
    4.27 +                         the
    4.28 +ALWAYS_DETAILED_SEC    = NO
    4.29 +INLINE_INHERITED_MEMB  = NO
    4.30 +FULL_PATH_NAMES        = YES
    4.31 +STRIP_FROM_PATH        = .
    4.32 +STRIP_FROM_INC_PATH    = 
    4.33 +SHORT_NAMES            = NO
    4.34 +JAVADOC_AUTOBRIEF      = NO
    4.35 +MULTILINE_CPP_IS_BRIEF = NO
    4.36 +DETAILS_AT_TOP         = NO
    4.37 +INHERIT_DOCS           = YES
    4.38 +SEPARATE_MEMBER_PAGES  = NO
    4.39 +TAB_SIZE               = 8
    4.40 +ALIASES                = 
    4.41 +OPTIMIZE_OUTPUT_FOR_C  = NO
    4.42 +OPTIMIZE_OUTPUT_JAVA   = NO
    4.43 +BUILTIN_STL_SUPPORT    = NO
    4.44 +DISTRIBUTE_GROUP_DOC   = NO
    4.45 +SUBGROUPING            = YES
    4.46 +#---------------------------------------------------------------------------
    4.47 +# Build related configuration options
    4.48 +#---------------------------------------------------------------------------
    4.49 +EXTRACT_ALL            = YES
    4.50 +EXTRACT_PRIVATE        = YES
    4.51 +EXTRACT_STATIC         = YES
    4.52 +EXTRACT_LOCAL_CLASSES  = YES
    4.53 +EXTRACT_LOCAL_METHODS  = NO
    4.54 +HIDE_UNDOC_MEMBERS     = NO
    4.55 +HIDE_UNDOC_CLASSES     = NO
    4.56 +HIDE_FRIEND_COMPOUNDS  = NO
    4.57 +HIDE_IN_BODY_DOCS      = NO
    4.58 +INTERNAL_DOCS          = NO
    4.59 +CASE_SENSE_NAMES       = YES
    4.60 +HIDE_SCOPE_NAMES       = NO
    4.61 +SHOW_INCLUDE_FILES     = YES
    4.62 +INLINE_INFO            = YES
    4.63 +SORT_MEMBER_DOCS       = YES
    4.64 +SORT_BRIEF_DOCS        = NO
    4.65 +SORT_BY_SCOPE_NAME     = NO
    4.66 +GENERATE_TODOLIST      = YES
    4.67 +GENERATE_TESTLIST      = YES
    4.68 +GENERATE_BUGLIST       = YES
    4.69 +GENERATE_DEPRECATEDLIST= YES
    4.70 +ENABLED_SECTIONS       = 
    4.71 +MAX_INITIALIZER_LINES  = 30
    4.72 +SHOW_USED_FILES        = YES
    4.73 +SHOW_DIRECTORIES       = YES
    4.74 +FILE_VERSION_FILTER    = 
    4.75 +#---------------------------------------------------------------------------
    4.76 +# configuration options related to warning and progress messages
    4.77 +#---------------------------------------------------------------------------
    4.78 +QUIET                  = NO
    4.79 +WARNINGS               = YES
    4.80 +WARN_IF_UNDOCUMENTED   = YES
    4.81 +WARN_IF_DOC_ERROR      = YES
    4.82 +WARN_NO_PARAMDOC       = NO
    4.83 +WARN_FORMAT            = "$file:$line: $text"
    4.84 +WARN_LOGFILE           = 
    4.85 +#---------------------------------------------------------------------------
    4.86 +# configuration options related to the input files
    4.87 +#---------------------------------------------------------------------------
    4.88 +INPUT                  = .
    4.89 +FILE_PATTERNS          = *.c \
    4.90 +                         *.cc \
    4.91 +                         *.cxx \
    4.92 +                         *.cpp \
    4.93 +                         *.c++ \
    4.94 +                         *.d \
    4.95 +                         *.java \
    4.96 +                         *.ii \
    4.97 +                         *.ixx \
    4.98 +                         *.ipp \
    4.99 +                         *.i++ \
   4.100 +                         *.inl \
   4.101 +                         *.h \
   4.102 +                         *.hh \
   4.103 +                         *.hxx \
   4.104 +                         *.hpp \
   4.105 +                         *.h++ \
   4.106 +                         *.idl \
   4.107 +                         *.odl \
   4.108 +                         *.cs \
   4.109 +                         *.php \
   4.110 +                         *.php3 \
   4.111 +                         *.inc \
   4.112 +                         *.m \
   4.113 +                         *.mm \
   4.114 +                         *.dox \
   4.115 +                         *.py \
   4.116 +                         *.C \
   4.117 +                         *.CC \
   4.118 +                         *.C++ \
   4.119 +                         *.II \
   4.120 +                         *.I++ \
   4.121 +                         *.H \
   4.122 +                         *.HH \
   4.123 +                         *.H++ \
   4.124 +                         *.CS \
   4.125 +                         *.PHP \
   4.126 +                         *.PHP3 \
   4.127 +                         *.M \
   4.128 +                         *.MM \
   4.129 +                         *.PY
   4.130 +RECURSIVE              = NO
   4.131 +EXCLUDE                = 
   4.132 +EXCLUDE_SYMLINKS       = NO
   4.133 +EXCLUDE_PATTERNS       = 
   4.134 +EXAMPLE_PATH           = 
   4.135 +EXAMPLE_PATTERNS       = *
   4.136 +EXAMPLE_RECURSIVE      = NO
   4.137 +IMAGE_PATH             = 
   4.138 +INPUT_FILTER           = 
   4.139 +FILTER_PATTERNS        = 
   4.140 +FILTER_SOURCE_FILES    = NO
   4.141 +#---------------------------------------------------------------------------
   4.142 +# configuration options related to source browsing
   4.143 +#---------------------------------------------------------------------------
   4.144 +SOURCE_BROWSER         = YES
   4.145 +INLINE_SOURCES         = NO
   4.146 +STRIP_CODE_COMMENTS    = YES
   4.147 +REFERENCED_BY_RELATION = YES
   4.148 +REFERENCES_RELATION    = YES
   4.149 +USE_HTAGS              = NO
   4.150 +VERBATIM_HEADERS       = YES
   4.151 +#---------------------------------------------------------------------------
   4.152 +# configuration options related to the alphabetical class index
   4.153 +#---------------------------------------------------------------------------
   4.154 +ALPHABETICAL_INDEX     = NO
   4.155 +COLS_IN_ALPHA_INDEX    = 5
   4.156 +IGNORE_PREFIX          = 
   4.157 +#---------------------------------------------------------------------------
   4.158 +# configuration options related to the HTML output
   4.159 +#---------------------------------------------------------------------------
   4.160 +GENERATE_HTML          = YES
   4.161 +HTML_OUTPUT            = html
   4.162 +HTML_FILE_EXTENSION    = .html
   4.163 +HTML_HEADER            = 
   4.164 +HTML_FOOTER            = 
   4.165 +HTML_STYLESHEET        = 
   4.166 +HTML_ALIGN_MEMBERS     = YES
   4.167 +GENERATE_HTMLHELP      = NO
   4.168 +CHM_FILE               = 
   4.169 +HHC_LOCATION           = 
   4.170 +GENERATE_CHI           = NO
   4.171 +BINARY_TOC             = NO
   4.172 +TOC_EXPAND             = NO
   4.173 +DISABLE_INDEX          = NO
   4.174 +ENUM_VALUES_PER_LINE   = 4
   4.175 +GENERATE_TREEVIEW      = NO
   4.176 +TREEVIEW_WIDTH         = 250
   4.177 +#---------------------------------------------------------------------------
   4.178 +# configuration options related to the LaTeX output
   4.179 +#---------------------------------------------------------------------------
   4.180 +GENERATE_LATEX         = NO
   4.181 +LATEX_OUTPUT           = latex
   4.182 +LATEX_CMD_NAME         = latex
   4.183 +MAKEINDEX_CMD_NAME     = makeindex
   4.184 +COMPACT_LATEX          = NO
   4.185 +PAPER_TYPE             = a4wide
   4.186 +EXTRA_PACKAGES         = 
   4.187 +LATEX_HEADER           = 
   4.188 +PDF_HYPERLINKS         = NO
   4.189 +USE_PDFLATEX           = NO
   4.190 +LATEX_BATCHMODE        = NO
   4.191 +LATEX_HIDE_INDICES     = NO
   4.192 +#---------------------------------------------------------------------------
   4.193 +# configuration options related to the RTF output
   4.194 +#---------------------------------------------------------------------------
   4.195 +GENERATE_RTF           = NO
   4.196 +RTF_OUTPUT             = rtf
   4.197 +COMPACT_RTF            = NO
   4.198 +RTF_HYPERLINKS         = NO
   4.199 +RTF_STYLESHEET_FILE    = 
   4.200 +RTF_EXTENSIONS_FILE    = 
   4.201 +#---------------------------------------------------------------------------
   4.202 +# configuration options related to the man page output
   4.203 +#---------------------------------------------------------------------------
   4.204 +GENERATE_MAN           = NO
   4.205 +MAN_OUTPUT             = man
   4.206 +MAN_EXTENSION          = .3
   4.207 +MAN_LINKS              = NO
   4.208 +#---------------------------------------------------------------------------
   4.209 +# configuration options related to the XML output
   4.210 +#---------------------------------------------------------------------------
   4.211 +GENERATE_XML           = NO
   4.212 +XML_OUTPUT             = xml
   4.213 +XML_SCHEMA             = 
   4.214 +XML_DTD                = 
   4.215 +XML_PROGRAMLISTING     = YES
   4.216 +#---------------------------------------------------------------------------
   4.217 +# configuration options for the AutoGen Definitions output
   4.218 +#---------------------------------------------------------------------------
   4.219 +GENERATE_AUTOGEN_DEF   = NO
   4.220 +#---------------------------------------------------------------------------
   4.221 +# configuration options related to the Perl module output
   4.222 +#---------------------------------------------------------------------------
   4.223 +GENERATE_PERLMOD       = NO
   4.224 +PERLMOD_LATEX          = NO
   4.225 +PERLMOD_PRETTY         = YES
   4.226 +PERLMOD_MAKEVAR_PREFIX = 
   4.227 +#---------------------------------------------------------------------------
   4.228 +# Configuration options related to the preprocessor   
   4.229 +#---------------------------------------------------------------------------
   4.230 +ENABLE_PREPROCESSING   = YES
   4.231 +MACRO_EXPANSION        = NO
   4.232 +EXPAND_ONLY_PREDEF     = NO
   4.233 +SEARCH_INCLUDES        = YES
   4.234 +INCLUDE_PATH           = 
   4.235 +INCLUDE_FILE_PATTERNS  = 
   4.236 +PREDEFINED             = 
   4.237 +EXPAND_AS_DEFINED      = 
   4.238 +SKIP_FUNCTION_MACROS   = YES
   4.239 +#---------------------------------------------------------------------------
   4.240 +# Configuration::additions related to external references   
   4.241 +#---------------------------------------------------------------------------
   4.242 +TAGFILES               = 
   4.243 +GENERATE_TAGFILE       = 
   4.244 +ALLEXTERNALS           = NO
   4.245 +EXTERNAL_GROUPS        = YES
   4.246 +PERL_PATH              = /usr/bin/perl
   4.247 +#---------------------------------------------------------------------------
   4.248 +# Configuration options related to the dot tool   
   4.249 +#---------------------------------------------------------------------------
   4.250 +CLASS_DIAGRAMS         = NO
   4.251 +HIDE_UNDOC_RELATIONS   = YES
   4.252 +HAVE_DOT               = YES
   4.253 +CLASS_GRAPH            = YES
   4.254 +COLLABORATION_GRAPH    = YES
   4.255 +GROUP_GRAPHS           = YES
   4.256 +UML_LOOK               = NO
   4.257 +TEMPLATE_RELATIONS     = NO
   4.258 +INCLUDE_GRAPH          = YES
   4.259 +INCLUDED_BY_GRAPH      = YES
   4.260 +CALL_GRAPH             = YES
   4.261 +GRAPHICAL_HIERARCHY    = YES
   4.262 +DIRECTORY_GRAPH        = YES
   4.263 +DOT_IMAGE_FORMAT       = png
   4.264 +DOT_PATH               = 
   4.265 +DOTFILE_DIRS           = 
   4.266 +MAX_DOT_GRAPH_WIDTH    = 1024
   4.267 +MAX_DOT_GRAPH_HEIGHT   = 1024
   4.268 +MAX_DOT_GRAPH_DEPTH    = 1000
   4.269 +DOT_TRANSPARENT        = NO
   4.270 +DOT_MULTI_TARGETS      = NO
   4.271 +GENERATE_LEGEND        = YES
   4.272 +DOT_CLEANUP            = YES
   4.273 +#---------------------------------------------------------------------------
   4.274 +# Configuration::additions related to the search engine   
   4.275 +#---------------------------------------------------------------------------
   4.276 +SEARCHENGINE           = NO
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/LICENSE	Mon Jul 07 08:10:39 2008 -0500
     5.3 @@ -0,0 +1,33 @@
     5.4 +gLEMON code without an explicit copyright is covered by the following
     5.5 +copyright/license:
     5.6 +
     5.7 +Copyright (C) 2003-2006 Egervary Jeno Kombinatorikus Optimalizalasi
     5.8 +Kutatocsoport (Egervary Combinatorial Optimization Research Group,
     5.9 +EGRES).
    5.10 +
    5.11 +Permission is hereby granted, free of charge, to any person or organization
    5.12 +obtaining a copy of the software and accompanying documentation covered by
    5.13 +this license (the "Software") to use, reproduce, display, distribute,
    5.14 +execute, and transmit the Software, and to prepare derivative works of the
    5.15 +Software, and to permit third-parties to whom the Software is furnished to
    5.16 +do so, all subject to the following:
    5.17 +
    5.18 +The copyright notices in the Software and this entire statement, including
    5.19 +the above license grant, this restriction and the following disclaimer,
    5.20 +must be included in all copies of the Software, in whole or in part, and
    5.21 +all derivative works of the Software, unless such copies or derivative
    5.22 +works are solely in the form of machine-executable object code generated by
    5.23 +a source language processor.
    5.24 +
    5.25 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    5.26 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    5.27 +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
    5.28 +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
    5.29 +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
    5.30 +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    5.31 +DEALINGS IN THE SOFTWARE.
    5.32 +
    5.33 +===========================================================================
    5.34 +This license is a verbatim copy of the Boost Software License, Version 1.0.
    5.35 +
    5.36 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/Makefile.am	Mon Jul 07 08:10:39 2008 -0500
     6.3 @@ -0,0 +1,167 @@
     6.4 +AM_CPPFLAGS = -I$(top_srcdir) -DLOCALEDIR=\""$(datadir)/locale"\"
     6.5 +
     6.6 +SUBDIRS = po m4
     6.7 +
     6.8 +bin_PROGRAMS = glemon
     6.9 +BUILT_SOURCES = guipixbufs.h
    6.10 +CLEANFILES = guipixbufs.h
    6.11 +
    6.12 +glemon_SOURCES = \
    6.13 +	all_include.h \
    6.14 +	algobox.cc \
    6.15 +	algobox.h \
    6.16 +	algowin.cc \
    6.17 +	algowin.h \
    6.18 +	gdc-broken_edge.cc \
    6.19 +	graph_displayer_canvas.cc \
    6.20 +	graph_displayer_canvas.h \
    6.21 +	graph_displayer_canvas-edge.cc \
    6.22 +	graph_displayer_canvas-event.cc \
    6.23 +	graph_displayer_canvas-node.cc \
    6.24 +	graph_displayer_canvas-zoom.cc \
    6.25 +	graph-displayer.cc \
    6.26 +	kruskalbox.cc \
    6.27 +	kruskalbox.h \
    6.28 +	main_win.cc \
    6.29 +	main_win.h \
    6.30 +	mapstorage.cc \
    6.31 +	mapstorage.h \
    6.32 +	map_win.cc \
    6.33 +	map_win.h \
    6.34 +	mapselector.cc \
    6.35 +	mapselector.h \
    6.36 +	nbtab.h \
    6.37 +	nbtab.cc \
    6.38 +	new_map_win.cc \
    6.39 +	new_map_win.h \
    6.40 +	xymap.h \
    6.41 +	gui_reader.h \
    6.42 +	gui_reader.cc \
    6.43 +	gui_writer.h \
    6.44 +	gui_writer.cc \
    6.45 +	xml.h \
    6.46 +	guipixbufs.h \
    6.47 +	i18n.h \
    6.48 +	gettext.h \
    6.49 +	design_win.h \
    6.50 +	design_win.cc \
    6.51 +	dijkstrabox.h \
    6.52 +	dijkstrabox.cc \
    6.53 +	file_import_dialog.h \
    6.54 +	file_import_dialog.cc \
    6.55 +	map_value.h \
    6.56 +	map_value.cc \
    6.57 +	map_value_map.h \
    6.58 +	map_value_map.cc \
    6.59 +	save_details_widget.h \
    6.60 +	save_details_widget.cc \
    6.61 +	save_details_dialog.h \
    6.62 +	save_details_dialog.cc \
    6.63 +	io_helper.h \
    6.64 +	io_helper.cc \
    6.65 +	background_chooser_dialog.h \
    6.66 +	background_chooser_dialog.cc \
    6.67 +	eps_win.h \
    6.68 +	eps_win.cc
    6.69 +
    6.70 +glemon_CXXFLAGS = $(GTK_CFLAGS) $(LEMON_CFLAGS)
    6.71 +# glemon_LDFLAGS = $(GTK_LIBS) $(LEMON_LIBS)
    6.72 +glemon_LDADD = $(GTK_LIBS) $(LEMON_LIBS) $(LIBINTL)
    6.73 +
    6.74 +IMAGES = \
    6.75 +	icons/addlink.png \
    6.76 +	icons/addnode.png \
    6.77 +	icons/delete.png \
    6.78 +	icons/editlink.png \
    6.79 +	icons/editnode.png \
    6.80 +	icons/move.png \
    6.81 +	icons/newmap.png \
    6.82 +	icons/eps.png
    6.83 +
    6.84 +VARIABLES = \
    6.85 +	gui_icons_addlink $(srcdir)/icons/addlink.png \
    6.86 +	gui_icons_addnode $(srcdir)/icons/addnode.png \
    6.87 +	gui_icons_delete $(srcdir)/icons/delete.png \
    6.88 +	gui_icons_editlink $(srcdir)/icons/editlink.png \
    6.89 +	gui_icons_editnode $(srcdir)/icons/editnode.png \
    6.90 +	gui_icons_move $(srcdir)/icons/move.png \
    6.91 +	gui_icons_newmap $(srcdir)/icons/newmap.png \
    6.92 +	gui_icons_eps $(srcdir)/icons/eps.png
    6.93 +	
    6.94 +guipixbufs.h: $(IMAGES)
    6.95 +	gdk-pixbuf-csource \
    6.96 +	--raw --build-list $(VARIABLES) > guipixbufs.h ||  \
    6.97 +	( rm -f guipixbufs.h && false )
    6.98 +
    6.99 +EXTRA_DIST = \
   6.100 +	$(IMAGES) \
   6.101 +	guipixbufs.h \
   6.102 +	glemon.spec \
   6.103 +	AUTHORS \
   6.104 +	COPYING \
   6.105 +	LICENSE \
   6.106 +	NEWS \
   6.107 +	README \
   6.108 +	ABOUT-NLS
   6.109 +
   6.110 +MRPROPERFILES = \
   6.111 +	Makefile.in \
   6.112 +	configure \
   6.113 +	config.h.in \
   6.114 +	aclocal.m4 \
   6.115 +	ABOUT-NLS \
   6.116 +	m4/Makefile.in \
   6.117 +	m4/lib-link.m4 \
   6.118 +	m4/printf-posix.m4 \
   6.119 +	m4/uintmax_t.m4 \
   6.120 +	m4/signed.m4 \
   6.121 +	m4/iconv.m4 \
   6.122 +	m4/inttypes.m4 \
   6.123 +	m4/longlong.m4 \
   6.124 +	m4/glibc21.m4 \
   6.125 +	m4/inttypes_h.m4 \
   6.126 +	m4/codeset.m4 \
   6.127 +	m4/longdouble.m4 \
   6.128 +	m4/nls.m4 \
   6.129 +	m4/intmax.m4 \
   6.130 +	m4/lib-prefix.m4 \
   6.131 +	m4/glibc2.m4 \
   6.132 +	m4/xsize.m4 \
   6.133 +	m4/lcmessage.m4 \
   6.134 +	m4/lib-ld.m4 \
   6.135 +	m4/ulonglong.m4 \
   6.136 +	m4/wint_t.m4 \
   6.137 +	m4/progtest.m4 \
   6.138 +	m4/inttypes-pri.m4 \
   6.139 +	m4/stdint_h.m4 \
   6.140 +	m4/intdiv0.m4 \
   6.141 +	m4/isc-posix.m4 \
   6.142 +	m4/po.m4 \
   6.143 +	m4/size_max.m4 \
   6.144 +	m4/gettext.m4 \
   6.145 +	m4/wchar_t.m4 \
   6.146 +	po/Rules-quot \
   6.147 +	po/en@quot.header \
   6.148 +	po/insert-header.sin \
   6.149 +	po/quot.sed \
   6.150 +	po/en@boldquot.header \
   6.151 +	po/boldquot.sed \
   6.152 +	po/Makevars.template \
   6.153 +	po/remove-potcdate.sin \
   6.154 +	po/Makefile.in.in \
   6.155 +	build-aux/mkinstalldirs \
   6.156 +	build-aux/config.rpath \
   6.157 +	build-aux/depcomp \
   6.158 +	build-aux/missing \
   6.159 +	build-aux/config.guess \
   6.160 +	build-aux/config.sub \
   6.161 +	build-aux/install-sh
   6.162 +
   6.163 +mrproper:
   6.164 +	$(MAKE) $(AM_MAKEFLAGS) maintainer-clean
   6.165 +	-rm -f $(MRPROPERFILES)
   6.166 +
   6.167 +rpm: dist
   6.168 +	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
   6.169 +
   6.170 +.PHONY: mrproper
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/NEWS	Mon Jul 07 08:10:39 2008 -0500
     7.3 @@ -0,0 +1,1 @@
     7.4 +To be filled
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/README	Mon Jul 07 08:10:39 2008 -0500
     8.3 @@ -0,0 +1,1 @@
     8.4 +To be filled
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/algobox.cc	Mon Jul 07 08:10:39 2008 -0500
     9.3 @@ -0,0 +1,211 @@
     9.4 +/* -*- C++ -*-
     9.5 + *
     9.6 + * This file is a part of LEMON, a generic C++ optimization library
     9.7 + *
     9.8 + * Copyright (C) 2003-2006
     9.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    9.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    9.11 + *
    9.12 + * Permission to use, modify and distribute this software is granted
    9.13 + * provided that this copyright notice appears in all copies. For
    9.14 + * precise terms see the accompanying LICENSE file.
    9.15 + *
    9.16 + * This software is provided "AS IS" with no warranty of any kind,
    9.17 + * express or implied, and with no claim as to its suitability for any
    9.18 + * purpose.
    9.19 + *
    9.20 + */
    9.21 +
    9.22 +#include <algobox.h>
    9.23 +#include <mapstorage.h>
    9.24 +#include <mapselector.h>
    9.25 +
    9.26 +enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes;
    9.27 +enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for arcs;
    9.28 +
    9.29 +AlgoBox::AlgoBox(std::vector<std::string> tabnames)
    9.30 +{
    9.31 +  init(tabnames);
    9.32 +}
    9.33 +
    9.34 +void AlgoBox::init(std::vector<std::string> tabnames)
    9.35 +{
    9.36 +  set_spacing(5);
    9.37 +
    9.38 +  update_tablist(tabnames);
    9.39 +
    9.40 +  //if active tab is changed, the map names in cbt/s have to be updated
    9.41 +  tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change));
    9.42 +
    9.43 +  pack_start(tabcbt);
    9.44 +  build_box();
    9.45 +
    9.46 +  show_all_children();
    9.47 +};
    9.48 +
    9.49 +void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt)
    9.50 +{
    9.51 +  std::string actname=cbt.get_active_text();
    9.52 +  int prev_act=-1;
    9.53 +
    9.54 +  cbt.clear();
    9.55 +  int actptr=0;
    9.56 +
    9.57 +  std::vector< std::string >::iterator emsi=stringlist.begin();
    9.58 +  for(;emsi!=stringlist.end();emsi++)
    9.59 +    {
    9.60 +      if(actname==*emsi)
    9.61 +	{
    9.62 +	  prev_act=actptr;
    9.63 +	}
    9.64 +
    9.65 +      cbt.append_text(*emsi);
    9.66 +      actptr++;
    9.67 +    }
    9.68 +
    9.69 +  if(prev_act!=-1)
    9.70 +    {
    9.71 +      cbt.set_active(prev_act);
    9.72 +    }
    9.73 +  else if(actptr>0) //so there is item in the list
    9.74 +    {
    9.75 +      //cbt.set_active(0);
    9.76 +    }
    9.77 +}
    9.78 +
    9.79 +void AlgoBox::update_tablist( std::vector< std::string > tl )
    9.80 +{
    9.81 +  update_cbt(tl, tabcbt);
    9.82 +  emit_tab_change();
    9.83 +}
    9.84 +
    9.85 +void AlgoBox::update_maplist(MapStorage * ms)
    9.86 +{
    9.87 +  mapstorage=ms;
    9.88 +  std::vector<std::string> n_nml;
    9.89 +  std::vector<std::string> s_nml;
    9.90 +  std::vector<std::string> n_eml;
    9.91 +  std::vector<std::string> s_eml;
    9.92 +  if(mapstorage!=NULL)
    9.93 +    {
    9.94 +      mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
    9.95 +      mapstorage->signal_arc_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::arcmaplist_changed));
    9.96 +      n_nml=mapstorage->getNodeMapList(NUM);
    9.97 +      s_nml=mapstorage->getNodeMapList(STR);
    9.98 +      n_eml=mapstorage->getArcMapList(NUM);
    9.99 +      s_eml=mapstorage->getArcMapList(STR);
   9.100 +    }
   9.101 +  for(int i=0;i<(int)nodemapcbts.size();i++)
   9.102 +    {
   9.103 +      (nodemapcbts[i])->update_list(n_nml, s_nml);
   9.104 +      //update_cbt(nml, *(nodemapcbts[i]));
   9.105 +    }
   9.106 +  for(int i=0;i<(int)arcmapcbts.size();i++)
   9.107 +    {
   9.108 +      (arcmapcbts[i])->update_list(n_eml, s_eml);
   9.109 +      //update_cbt(eml, *(arcmapcbts[i]));
   9.110 +    }
   9.111 +  signal_maplist_updated.emit();
   9.112 +}
   9.113 +
   9.114 +void AlgoBox::nodemaplist_changed(std::string newmap, MapValue::Type type)
   9.115 +{
   9.116 +  for(int i=0;i<(int)nodemapcbts.size();i++)
   9.117 +    {
   9.118 +      (nodemapcbts[i])->append_text(newmap, type);
   9.119 +    }
   9.120 +}
   9.121 +
   9.122 +void AlgoBox::arcmaplist_changed(std::string newmap, MapValue::Type type)
   9.123 +{
   9.124 +  for(int i=0;i<(int)arcmapcbts.size();i++)
   9.125 +    {
   9.126 +      (arcmapcbts[i])->append_text(newmap, type);
   9.127 +    }
   9.128 +}
   9.129 +
   9.130 +void AlgoBox::run()
   9.131 +{
   9.132 +  std::cout << "Start algorithm." << std::endl;
   9.133 +}
   9.134 +
   9.135 +void AlgoBox::build_box()
   9.136 +{
   9.137 +  pack_start(*(new Gtk::HSeparator()));
   9.138 +
   9.139 +  Gtk::Label * label=new Gtk::Label("Specific part for each algorithm.");
   9.140 +      
   9.141 +  pack_start(*label);
   9.142 +  pack_start(*(new Gtk::HSeparator()));
   9.143 +
   9.144 +  label=new Gtk::Label("Maps in chosen tab:");
   9.145 +      
   9.146 +  pack_start(*label);
   9.147 +
   9.148 +  for(int i=0;i<NODE_INPUT_NUM;i++)
   9.149 +    {
   9.150 +      std::ostringstream o;
   9.151 +      o << "NodeInput " << i+1 << ":";
   9.152 +
   9.153 +      addMapSelector(o.str(), false);
   9.154 +    }
   9.155 +
   9.156 +  pack_start(*(new Gtk::HSeparator()));
   9.157 +
   9.158 +  for(int i=0;i<EDGE_INPUT_NUM;i++)
   9.159 +    {
   9.160 +
   9.161 +      std::ostringstream o;
   9.162 +      o << "ArcInput " << i+1 << ":";
   9.163 +
   9.164 +      addMapSelector(o.str(), true);
   9.165 +    }
   9.166 +
   9.167 +  pack_start(*(new Gtk::HSeparator()));
   9.168 +}
   9.169 +
   9.170 +void AlgoBox::addMapSelector(std::string inputname, bool itisarc, MapType type)
   9.171 +{
   9.172 +  std::vector<std::string> empty_vector;
   9.173 +
   9.174 +  MapSelector * msp=new MapSelector(empty_vector,empty_vector,"",inputname,itisarc, false, type);
   9.175 +
   9.176 +  if(itisarc)
   9.177 +    {
   9.178 +      arcmapcbts.resize(arcmapcbts.size()+1);
   9.179 +      arcmapcbts[arcmapcbts.size()-1]=msp;
   9.180 +    }
   9.181 +  else
   9.182 +    {
   9.183 +      nodemapcbts.resize(nodemapcbts.size()+1);
   9.184 +      nodemapcbts[nodemapcbts.size()-1]=msp;
   9.185 +    }
   9.186 +
   9.187 +  msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
   9.188 +
   9.189 +  pack_start(*msp);
   9.190 +}
   9.191 +
   9.192 +sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
   9.193 +{
   9.194 +  return signal_maplist_need;
   9.195 +}
   9.196 +
   9.197 +void AlgoBox::emit_tab_change()
   9.198 +{
   9.199 +  std::string active_tab=tabcbt.get_active_text();
   9.200 +  if(active_tab!="")
   9.201 +    {
   9.202 +      signal_maplist_need.emit(active_tab);
   9.203 +    }
   9.204 +  else
   9.205 +    {
   9.206 +      std::vector<std::string> empty_vector;
   9.207 +      update_maplist(NULL);
   9.208 +    }
   9.209 +}
   9.210 +
   9.211 +void AlgoBox::emit_new_map_signal(bool itisarc)
   9.212 +{
   9.213 +  signal_newmapwin_need.emit(tabcbt.get_active_text(), itisarc);
   9.214 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/algobox.h	Mon Jul 07 08:10:39 2008 -0500
    10.3 @@ -0,0 +1,189 @@
    10.4 +/* -*- C++ -*-
    10.5 + *
    10.6 + * This file is a part of LEMON, a generic C++ optimization library
    10.7 + *
    10.8 + * Copyright (C) 2003-2006
    10.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   10.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   10.11 + *
   10.12 + * Permission to use, modify and distribute this software is granted
   10.13 + * provided that this copyright notice appears in all copies. For
   10.14 + * precise terms see the accompanying LICENSE file.
   10.15 + *
   10.16 + * This software is provided "AS IS" with no warranty of any kind,
   10.17 + * express or implied, and with no claim as to its suitability for any
   10.18 + * purpose.
   10.19 + *
   10.20 + */
   10.21 +
   10.22 +#ifndef ALGOBOX_H
   10.23 +#define ALGOBOX_H
   10.24 +
   10.25 +class MapStorage;
   10.26 +class MapSelector;
   10.27 +
   10.28 +#include <all_include.h>
   10.29 +#include <libgnomecanvasmm.h>
   10.30 +#include <libgnomecanvasmm/polygon.h>
   10.31 +#include "map_value.h"
   10.32 +
   10.33 +///Ancestor class of algorithm digraphical interface classes.
   10.34 +
   10.35 +///It also demonstrates, how should an algorithm digraphical interface
   10.36 +///work. Children of this class have the same functions and attributes,
   10.37 +///therefore with all of them can the holder \ref AlgoWin communicate
   10.38 +///in the same way.
   10.39 +///
   10.40 +///IMPORTANT! In a child class only the following tasks are to do:
   10.41 +///
   10.42 +///-call \ref init function with correct parameters from correctly parametrized constructor
   10.43 +///
   10.44 +///-implement \ref build_box function
   10.45 +///
   10.46 +///-implement \ref run function
   10.47 +///
   10.48 +///because all other thing is automatically done in \ref init function!
   10.49 +
   10.50 +class AlgoBox : public Gtk::VBox
   10.51 +{
   10.52 +  ///Signal emitted in case of need for list of maps.
   10.53 +
   10.54 +  ///If the user has selected different tab to work on
   10.55 +  ///new maps are selected as well. These new maps should be
   10.56 +  ///provided for \ref AlgoBox. To get these maps, \ref AlgoBox
   10.57 +  ///emits this signal.
   10.58 +  sigc::signal<void, std::string> signal_maplist_need;
   10.59 +
   10.60 +  ///Signal emitted in case of need for \ref NewMapWin.
   10.61 +
   10.62 +  ///If user wants to create a new for an input, or output
   10.63 +  ///it can let \ref NewMapWin popped up from here as well.
   10.64 +  ///In that case will be this signal emitted.
   10.65 +  sigc::signal<void, std::string, bool> signal_newmapwin_need;
   10.66 +
   10.67 +  ///Signal emitted when maplists are updated after tab change
   10.68 +  sigc::signal<void> signal_maplist_updated;
   10.69 +
   10.70 +
   10.71 +protected:
   10.72 +  ///Holder of tabnames.
   10.73 +  Gtk::ComboBoxText tabcbt;
   10.74 +
   10.75 +  ///Holder of widgets, in which nodemaps can be selected to work on.
   10.76 +  std::vector<MapSelector *> nodemapcbts;
   10.77 +
   10.78 +  ///Holder of widgets, in which arcmaps can be selected to work on.
   10.79 +  std::vector<MapSelector *> arcmapcbts;
   10.80 +
   10.81 +  ///Maps of selected tabs.
   10.82 +  MapStorage * mapstorage;
   10.83 +
   10.84 +public:
   10.85 +  ///Empty constructor called by children.
   10.86 +  AlgoBox(){};
   10.87 +
   10.88 +  ///Constructor
   10.89 +
   10.90 +  ///Calls \ref init function
   10.91 +  ///with the provided parameters. \ref init function
   10.92 +  ///is needed, because it is virtual, therefore the
   10.93 +  ///functions of the proper class will be called when
   10.94 +  ///running.
   10.95 +  ///\param tablist list of tabs in \ref MainWin
   10.96 +  AlgoBox(std::vector<std::string> tablist);
   10.97 +
   10.98 +  ///Initiates \ref AlgoBox.
   10.99 +
  10.100 +  ///Creates the digraphical interface for the realized algorithm, initiates variables, connects signals.
  10.101 +  ///
  10.102 +  ///List of tabs in \ref MainWin is required, but no one
  10.103 +  ///will be selected automatically. Every other
  10.104 +  ///entry field remains empty (unselected), until a \ref NoteBookTab
  10.105 +  ///is selected.
  10.106 +  ///
  10.107 +  ///It also have to bind all the signals to the correct place.
  10.108 +  ///This function is virtual, in all type of children of
  10.109 +  ///\ref AlgoBox the correct function willbe called.
  10.110 +  ///
  10.111 +  ///Therefore it is IMPORTANT that only \ref run and \ref build_box
  10.112 +  ///has to be implemented in children of \ref AlgoBox, every other
  10.113 +  ///thing will automatically work properly by the help of this
  10.114 +  ///function that must be called in constructor of child!!!
  10.115 +  virtual void init(std::vector<std::string>);
  10.116 +
  10.117 +  ///Signal emitted, when selected tab changes, and new list of maps required.
  10.118 +  sigc::signal<void, std::string> signal_maplist_needed();
  10.119 +
  10.120 +  ///Emitted if user wants to create a new map for inpuit or output.
  10.121 +  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
  10.122 +
  10.123 +  sigc::signal<void> signal_upon_maplist_updated(){return signal_maplist_updated;};
  10.124 +
  10.125 +  ///Emits signal that requires list of maps for the recently selected \ref NoteBookTab.
  10.126 +  void emit_tab_change();
  10.127 +
  10.128 +  ///Interface, through which \ref AlgoBox can be notified about tab addition, deletion in \ref MainWin
  10.129 +
  10.130 +  ///\param tl list
  10.131 +  ///of new tab state.
  10.132 +  void update_tablist( std::vector< std::string > tl );
  10.133 +
  10.134 +  ///Interface, through which \ref AlgoBox can get the maps of the recently selected \ref NoteBookTab
  10.135 +
  10.136 +  ///\param ms the maps
  10.137 +  ///of the recently selected \ref NoteBookTab
  10.138 +  void update_maplist( MapStorage * ms);
  10.139 +
  10.140 +  ///Interface, through which \ref AlgoBox can be notified about nodemap addition.
  10.141 +
  10.142 +  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
  10.143 +  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
  10.144 +  ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
  10.145 +  void nodemaplist_changed(std::string, MapValue::Type);
  10.146 +
  10.147 +  ///Interface, through which \ref AlgoBox can be notified about arcmap addition.
  10.148 +
  10.149 +  ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
  10.150 +  ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
  10.151 +  ///in \ref arcmapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
  10.152 +  void arcmaplist_changed(std::string, MapValue::Type);
  10.153 +
  10.154 +  ///Aid function to provide data for a given entry.
  10.155 +
  10.156 +  ///At the moment it is only used for updating info
  10.157 +  ///in \ref tabcbt. It clears it first, after that
  10.158 +  ///inserts the data got from caller, and if there
  10.159 +  ///was previously selected item it switches entry
  10.160 +  ///to that.
  10.161 +  ///\param tl list of entries (at the moment tabs in \ref MainWin)
  10.162 +  ///\param cbt the entry to update (at the moment only \ref tabcbt)
  10.163 +  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText & cbt);
  10.164 +
  10.165 +  ///Runs the ralized algorithm.
  10.166 +
  10.167 +  ///Prepare the data for it
  10.168 +  ///and after that postprocess it if necessary.
  10.169 +  ///This is only a demo here, but in children it
  10.170 +  ///runs the algorithm really.
  10.171 +  virtual void run();
  10.172 +
  10.173 +  ///Creates the layout of the \ref AlgoBox
  10.174 +
  10.175 +  ///Place all the entries
  10.176 +  ///required. Run and close button is not
  10.177 +  ///its responsibility!
  10.178 +  virtual void build_box();
  10.179 +
  10.180 +  ///Emits \ref signal_newmapwin_need if user wants to create new input or output map.
  10.181 +
  10.182 +  ///Called in case of pressing \ref MapSelector::newbut.
  10.183 +  ///\param itisarc arc or nodemap is required.
  10.184 +  virtual void emit_new_map_signal(bool itisarc);
  10.185 +
  10.186 +  ///Aid function to make addition of \ref MapSelector easy in \ref build_box.
  10.187 +
  10.188 +  ///\param label label to show in \ref MapSelector
  10.189 +  ///\param itisarc whether arc or nodemaps stored in \ref MapSelector
  10.190 +  void addMapSelector(std::string label, bool itisarc, MapType type = ALL);
  10.191 +};
  10.192 +#endif //ALGOBOX_H
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/algowin.cc	Mon Jul 07 08:10:39 2008 -0500
    11.3 @@ -0,0 +1,117 @@
    11.4 +/* -*- C++ -*-
    11.5 + *
    11.6 + * This file is a part of LEMON, a generic C++ optimization library
    11.7 + *
    11.8 + * Copyright (C) 2003-2006
    11.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   11.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   11.11 + *
   11.12 + * Permission to use, modify and distribute this software is granted
   11.13 + * provided that this copyright notice appears in all copies. For
   11.14 + * precise terms see the accompanying LICENSE file.
   11.15 + *
   11.16 + * This software is provided "AS IS" with no warranty of any kind,
   11.17 + * express or implied, and with no claim as to its suitability for any
   11.18 + * purpose.
   11.19 + *
   11.20 + */
   11.21 +
   11.22 +#include <algowin.h>
   11.23 +#include <algobox.h>
   11.24 +#include <kruskalbox.h>
   11.25 +#include <dijkstrabox.h>
   11.26 +
   11.27 +sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
   11.28 +{
   11.29 +  return signal_closed;
   11.30 +}
   11.31 +
   11.32 +sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
   11.33 +{
   11.34 +  return signal_maplist_need;
   11.35 +}
   11.36 +
   11.37 +bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
   11.38 +{
   11.39 +  if(e->keyval==GDK_Escape)
   11.40 +  {
   11.41 +    on_hide();
   11.42 +  }
   11.43 +  return true;
   11.44 +}
   11.45 +
   11.46 +AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
   11.47 +{
   11.48 +  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
   11.49 +
   11.50 +  Gtk::VBox * vbox=new Gtk::VBox();
   11.51 +  vbox->set_spacing(5);
   11.52 +
   11.53 +  Gtk::Label * label=new Gtk::Label("Select digraph:");
   11.54 +
   11.55 +  switch(algoid)
   11.56 +    {
   11.57 +    case 0:
   11.58 +      ab=new AlgoBox(tabnames);
   11.59 +      set_title("Algo Win Demo");
   11.60 +      break;
   11.61 +    case 1:
   11.62 +      ab=new KruskalBox(tabnames);
   11.63 +      set_title("Kruskal Algorithm");
   11.64 +      break;
   11.65 +    case 2:
   11.66 +      ab=new DijkstraBox(tabnames);
   11.67 +      set_title("Dijkstra Algorithm");
   11.68 +      break;
   11.69 +    case 3:
   11.70 +      ab=new SuurballeBox(tabnames);
   11.71 +      set_title("Suurballe Algorithm");
   11.72 +      break;
   11.73 +    default:
   11.74 +      break;
   11.75 +    }
   11.76 +  ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
   11.77 +  ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
   11.78 +
   11.79 +  runbutton=new Gtk::Button("Run");
   11.80 +  runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
   11.81 +  runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
   11.82 +
   11.83 +  closebutton=new Gtk::Button("Close");
   11.84 +  closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
   11.85 +  closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
   11.86 +      
   11.87 +  Gtk::HBox * hbox=new Gtk::HBox();
   11.88 +
   11.89 +  hbox->pack_start(*runbutton);
   11.90 +  hbox->pack_start(*closebutton);
   11.91 +
   11.92 +  vbox->pack_start(*label);
   11.93 +  vbox->pack_start(*ab);
   11.94 +  vbox->pack_start(*hbox);
   11.95 +      
   11.96 +  add(*vbox);
   11.97 +
   11.98 +  show_all_children();
   11.99 +};
  11.100 +
  11.101 +void AlgoWin::update_tablist(std::vector<std::string> tabnames)
  11.102 +{
  11.103 +  ab->update_tablist(tabnames);
  11.104 +}
  11.105 +
  11.106 +void AlgoWin::update_maplist(MapStorage * mapstorage)
  11.107 +{
  11.108 +  ab->update_maplist(mapstorage);
  11.109 +}
  11.110 +
  11.111 +void AlgoWin::on_hide()
  11.112 +{
  11.113 +  signal_closed.emit(this);
  11.114 +  Gtk::Window::on_hide();
  11.115 +}
  11.116 +
  11.117 +void AlgoWin::emit_tab_change(std::string newtab)
  11.118 +{
  11.119 +  signal_maplist_need.emit(this, newtab);
  11.120 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/algowin.h	Mon Jul 07 08:10:39 2008 -0500
    12.3 @@ -0,0 +1,147 @@
    12.4 +/* -*- C++ -*-
    12.5 + *
    12.6 + * This file is a part of LEMON, a generic C++ optimization library
    12.7 + *
    12.8 + * Copyright (C) 2003-2006
    12.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   12.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   12.11 + *
   12.12 + * Permission to use, modify and distribute this software is granted
   12.13 + * provided that this copyright notice appears in all copies. For
   12.14 + * precise terms see the accompanying LICENSE file.
   12.15 + *
   12.16 + * This software is provided "AS IS" with no warranty of any kind,
   12.17 + * express or implied, and with no claim as to its suitability for any
   12.18 + * purpose.
   12.19 + *
   12.20 + */
   12.21 +
   12.22 +#ifndef ALGOWIN_H
   12.23 +#define ALGOWIN_H
   12.24 +
   12.25 +#include <all_include.h>
   12.26 +#include <libgnomecanvasmm.h>
   12.27 +#include <libgnomecanvasmm/polygon.h>
   12.28 +
   12.29 +class AlgoBox;
   12.30 +class MapStorage;
   12.31 +
   12.32 +///Algorithm identifiers.
   12.33 +enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
   12.34 +
   12.35 +///Window displaying digraphical interface for different algorithms.
   12.36 +
   12.37 +///This class displays a digraphical interface to set up
   12.38 +///and run different algorithms. Different algorithms need
   12.39 +///different inputs, running methods, etc. Therefore
   12.40 +///class \ref AlgoWin is only a holder of a base class, the so
   12.41 +///called AlgoBox. \ref AlgoBox is the ancestor of other
   12.42 +///classes. These child classes realize interfaces of different
   12.43 +///algorithms, but as their common ancestor is \ref AlgoBox
   12.44 +///the interface of them is the same. \ref AlgoWin communicates
   12.45 +///with these classes through this common interface. But it the
   12.46 +///real object to be placed in \ref AlgoWin depends on the algorithm
   12.47 +///which the \ref AlgoWin actually has to display. It gets the
   12.48 +///id of algorithm to display at initialization, and therefore it is
   12.49 +///able to place in itself the requested child of \ref AlgoBox
   12.50 +/// visualizing the appropriate algorithm.
   12.51 +class AlgoWin : public Gtk::Window
   12.52 +{
   12.53 +private:
   12.54 +  ///Algorithm specific part of \ref AlgoWin
   12.55 +  AlgoBox * ab;
   12.56 +
   12.57 +  ///Run button.
   12.58 +
   12.59 +  ///If pressed, algorithm should run.
   12.60 +  ///That is why common ancestor of different
   12.61 +  ///algorithm realizer classes have to be. In case of
   12.62 +  ///pressing run button a common method can be called.
   12.63 +  Gtk::Button * runbutton;
   12.64 +
   12.65 +  ///Close button. If pressed, \ref AlgoWin should close.
   12.66 +  Gtk::Button * closebutton;
   12.67 +
   12.68 +protected:
   12.69 +  ///Signal emitted upon close of window
   12.70 +
   12.71 +  ///It is necessary, because \ref MainWin have to
   12.72 +  ///score the opened \ref AlgoWin s, to be able to communicate
   12.73 +  ///with them: let them know about changement in tabs, maps, etc.
   12.74 +  ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it.
   12.75 +  ///Therefore signal contains address of emitter \ref AlgoWin.
   12.76 +  sigc::signal<void, AlgoWin *> signal_closed;
   12.77 +
   12.78 +  ///Signal indicating that informatino on certain maplist is required.
   12.79 +
   12.80 +  ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor
   12.81 +  ///algorithm class. User can select the digraph (the holder \ref NoteBookTab) on
   12.82 +  ///which the algorithm should run. But different digraphs (\ref NoteBookTab) have
   12.83 +  ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox,
   12.84 +  ///caught and reemitted by \ref AlgoWin.
   12.85 +  ///
   12.86 +  ///Signal contains the address of \ref AlgoWin to let \ref MainWin know
   12.87 +  ///where should the information needed forwarded, and the name of
   12.88 +  ///\ref NoteBookTab, of which maps are inquired.
   12.89 +  sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
   12.90 +
   12.91 +  ///Signal that indicates that a \ref NewMapWin should be popped up.
   12.92 +
   12.93 +  ///This is a forwarded signal. If \ref AlgoBox emits a signal
   12.94 +  ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it.
   12.95 +  ///
   12.96 +  ///Signal contains the name of \ref NoteBookTab, in which the new map
   12.97 +  ///should be created and a boolean that indicates whether an arc or a
   12.98 +  ///nodemap should be created.
   12.99 +  sigc::signal<void, std::string, bool> signal_newmapwin_need;
  12.100 +
  12.101 +public:
  12.102 +  ///Close window if escape key is pressed.
  12.103 +  bool closeIfEscapeIsPressed(GdkEventKey* e);
  12.104 +
  12.105 +  ///Returns \ref signal_closed to be bindable somewhere.
  12.106 +  sigc::signal<void, AlgoWin *> signal_closing();
  12.107 +
  12.108 +  ///Returns \ref signal_maplist_need to be bindable somewhere.
  12.109 +  sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
  12.110 +
  12.111 +  ///Returns \ref signal_newmapwin_need to be bindable somewhere.
  12.112 +  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
  12.113 +
  12.114 +  ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs.
  12.115 +  void emit_tab_change(std::string);
  12.116 +
  12.117 +  ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin.
  12.118 +  void emit_new_map_signal(std::string tabname, bool itisarc){signal_newmapwin_need.emit(tabname, itisarc);};
  12.119 +
  12.120 +  ///Constructor
  12.121 +
  12.122 +  ///It builds the window according to the information provided
  12.123 +  ///by the creator. It needs the identifier of the algorithm
  12.124 +  ///to visualize, and a list of name of \ref NoteBookTab s that can
  12.125 +  ///be found in \ref MainWin.
  12.126 +  ///\param algoid identifier of algorithm to show
  12.127 +  ///\param tablist list of tabs in \ref MainWin
  12.128 +  AlgoWin(int algoid, std::vector<std::string> tablist);
  12.129 +
  12.130 +  ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox
  12.131 +
  12.132 +  ///In case of changement in tabs in \ref MainWin
  12.133 +  ///\ref MainWin automatically updates tablist in
  12.134 +  ///\ref AlgoWin s.
  12.135 +  void update_tablist(std::vector<std::string> tabnames);
  12.136 +
  12.137 +  ///Forwards list of requested maps toward \ref AlgoBox
  12.138 +
  12.139 +  ///Upon catching the signal in which \ref AlgoBox requests
  12.140 +  ///list of maps \ref MainWin responds
  12.141 +  ///through this function.
  12.142 +  void update_maplist(MapStorage *);
  12.143 +
  12.144 +  ///Called when window is closing.
  12.145 +
  12.146 +  ///\ref AlgoWin has to be deregistrated in \ref MainWin
  12.147 +  ///thereforeit emits signal \ref signal_closed.
  12.148 +  void on_hide();
  12.149 +};
  12.150 +#endif //ALGOWIN_H
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/all_include.h	Mon Jul 07 08:10:39 2008 -0500
    13.3 @@ -0,0 +1,73 @@
    13.4 +/* -*- C++ -*-
    13.5 + *
    13.6 + * This file is a part of LEMON, a generic C++ optimization library
    13.7 + *
    13.8 + * Copyright (C) 2003-2006
    13.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   13.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   13.11 + *
   13.12 + * Permission to use, modify and distribute this software is granted
   13.13 + * provided that this copyright notice appears in all copies. For
   13.14 + * precise terms see the accompanying LICENSE file.
   13.15 + *
   13.16 + * This software is provided "AS IS" with no warranty of any kind,
   13.17 + * express or implied, and with no claim as to its suitability for any
   13.18 + * purpose.
   13.19 + *
   13.20 + */
   13.21 +
   13.22 +#ifndef ALL_INCLUDE_H
   13.23 +#define ALL_INCLUDE_H
   13.24 +
   13.25 +#include <fstream>
   13.26 +#include <iostream>
   13.27 +
   13.28 +#include <vector>
   13.29 +
   13.30 +#include <lemon/list_graph.h>
   13.31 +#include <lemon/graph_utils.h>
   13.32 +#include <lemon/maps.h>
   13.33 +#include <lemon/error.h>
   13.34 +#include <lemon/dim2.h>
   13.35 +
   13.36 +enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // arc properties;
   13.37 +enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties;
   13.38 +enum {N_MAPS, E_MAPS, ARROWS, PAR, EPS_PROPERTY_NUM}; // eps properties;
   13.39 +enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, MAP_EDIT, TOOL_NUM}; // tools;
   13.40 +#define RANGE 3
   13.41 +#define WIN_WIDTH 900
   13.42 +#define WIN_HEIGHT 600
   13.43 +#define MIN_EDGE_WIDTH 2
   13.44 +#define MAX_EDGE_WIDTH 40
   13.45 +#define MIN_NODE_RADIUS 2
   13.46 +#define MAX_NODE_RADIUS 80
   13.47 +
   13.48 +#ifndef MAIN_PART
   13.49 +extern std::vector <std::string> arc_property_strings;
   13.50 +extern std::vector <double> arc_property_defaults;
   13.51 +extern std::vector <std::string> node_property_strings;
   13.52 +extern std::vector <double> node_property_defaults;
   13.53 +extern int longest_property_string_length;
   13.54 +#endif //MAIN_PART
   13.55 +
   13.56 +using namespace lemon;
   13.57 +
   13.58 +typedef lemon::dim2::Point<double> XY;
   13.59 +typedef ListDigraph Digraph;
   13.60 +typedef Digraph::Node Node;
   13.61 +typedef Digraph::Arc Arc;
   13.62 +typedef Digraph::ArcIt ArcIt;
   13.63 +typedef Digraph::InArcIt InArcIt;
   13.64 +typedef Digraph::OutArcIt OutArcIt;
   13.65 +typedef Digraph::NodeIt NodeIt;
   13.66 +
   13.67 +const std::string prog_name = "LEMON Digraph Editor";
   13.68 +
   13.69 +enum MapType
   13.70 +{
   13.71 +  NUM  = 1 << 0,
   13.72 +  STR  = 1 << 1,
   13.73 +  ALL  = (1 << 0) | (1 << 1)
   13.74 +};
   13.75 +
   13.76 +#endif // ALL_INCLUDE_H
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/autopackage/default.apspec.in	Mon Jul 07 08:10:39 2008 -0500
    14.3 @@ -0,0 +1,44 @@
    14.4 +# -*-shell-script-*-
    14.5 +
    14.6 +[Meta]
    14.7 +RootName: @lemon.cs.elte.hu/glemon:$SOFTWAREVERSION
    14.8 +DisplayName: glemon
    14.9 +ShortName: glemon
   14.10 +Maintainer: The LEMON Developers - http://lemon.cs.elte.hu/
   14.11 +Packager: Alpar Juttner <alpar@cs.elte.hu>
   14.12 +Summary: Graphical graph and network editor for the LEMON Graph Format
   14.13 +SoftwareVersion: @VERSION@
   14.14 +AutopackageTarget: 0.7
   14.15 +
   14.16 +# Only uncomment InterfaceVersion if your package exposes interfaces to other software,
   14.17 +# for instance if it includes DSOs or python/perl modules. See the developer guide for more info,
   14.18 +# or ask on autopackage-dev if you don't understand interface versioning in autopackage.
   14.19 +#
   14.20 +# InterfaceVersion: 0.0
   14.21 +
   14.22 +PackageVersion: 1
   14.23 +
   14.24 +[Description]
   14.25 +Graphical graph and network editor for the LEMON Graph Format
   14.26 +
   14.27 +[BuildPrepare]
   14.28 +prepareBuild
   14.29 +
   14.30 +[BuildUnprepare]
   14.31 +unprepareBuild
   14.32 +
   14.33 +[Imports]
   14.34 +echo '*' | import
   14.35 +
   14.36 +[Prepare]
   14.37 +# Dependency checking
   14.38 +#require @whatever.you/need 1.0
   14.39 +
   14.40 +[Install]
   14.41 +# Put your installation script here
   14.42 +#installExe bin/*
   14.43 +copyFiles * $PREFIX
   14.44 +
   14.45 +[Uninstall]
   14.46 +# Usually just the following line is enough to uninstall everything
   14.47 +uninstallFromLog
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/background_chooser_dialog.cc	Mon Jul 07 08:10:39 2008 -0500
    15.3 @@ -0,0 +1,52 @@
    15.4 +#include <background_chooser_dialog.h>
    15.5 +#include <gtkmm/stock.h>
    15.6 +#include <mapstorage.h>
    15.7 +
    15.8 +BackgroundChooserDialog::BackgroundChooserDialog(MapStorage* ms) :
    15.9 +  mapstorage(ms),
   15.10 +  btnClear(Gtk::Stock::CLEAR)
   15.11 +{
   15.12 +  set_has_separator(false);
   15.13 +
   15.14 +  Gtk::VBox* pVBox = get_vbox();
   15.15 +
   15.16 +  lblBackground.set_text("<b>Background image file</b>");
   15.17 +  lblBackground.set_use_markup();
   15.18 +  lblBackground.set_alignment(Gtk::ALIGN_LEFT);
   15.19 +  lblScaling.set_text("<b>Scaling factor</b>");
   15.20 +  lblScaling.set_use_markup();
   15.21 +  lblScaling.set_alignment(Gtk::ALIGN_LEFT);
   15.22 +  fcbBackground.set_width_chars(30);
   15.23 +  fcbBackground.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
   15.24 +  if (mapstorage->isBackgroundSet())
   15.25 +  {
   15.26 +    fcbBackground.set_filename(mapstorage->getBackgroundFilename());
   15.27 +  }
   15.28 +
   15.29 +  fcbBackground.signal_selection_changed().connect(
   15.30 +    sigc::mem_fun(*this, &BackgroundChooserDialog::setBackground));
   15.31 +
   15.32 +  btnClear.signal_clicked().connect(
   15.33 +    sigc::mem_fun(*this, &BackgroundChooserDialog::clearBackground));
   15.34 +
   15.35 +  pVBox->pack_start(lblBackground, Gtk::PACK_SHRINK);
   15.36 +  pVBox->pack_start(box, Gtk::PACK_SHRINK);
   15.37 +  box.pack_start(fcbBackground, Gtk::PACK_EXPAND_WIDGET);
   15.38 +  box.pack_start(btnClear, Gtk::PACK_SHRINK);
   15.39 +  pVBox->pack_start(lblScaling, Gtk::PACK_SHRINK);
   15.40 +  pVBox->pack_start(sbScaling, Gtk::PACK_SHRINK);
   15.41 +
   15.42 +  add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
   15.43 +
   15.44 +  show_all_children();
   15.45 +}
   15.46 +
   15.47 +void BackgroundChooserDialog::clearBackground()
   15.48 +{
   15.49 +  fcbBackground.unselect_all();
   15.50 +}
   15.51 +
   15.52 +void BackgroundChooserDialog::setBackground()
   15.53 +{
   15.54 +  mapstorage->setBackground(fcbBackground.get_filename());
   15.55 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/background_chooser_dialog.h	Mon Jul 07 08:10:39 2008 -0500
    16.3 @@ -0,0 +1,27 @@
    16.4 +#ifndef BACKGROUND_CHOOSER_DIALOG
    16.5 +#define BACKGROUND_CHOOSER_DIALOG
    16.6 +
    16.7 +#include <gtkmm/dialog.h>
    16.8 +#include <gtkmm/label.h>
    16.9 +#include <gtkmm/filechooserbutton.h>
   16.10 +#include <gtkmm/spinbutton.h>
   16.11 +
   16.12 +class MapStorage;
   16.13 +
   16.14 +class BackgroundChooserDialog : public Gtk::Dialog
   16.15 +{
   16.16 +  private:
   16.17 +    MapStorage* mapstorage;
   16.18 +    Gtk::Label lblBackground;
   16.19 +    Gtk::Label lblScaling;
   16.20 +    Gtk::FileChooserButton fcbBackground;
   16.21 +    Gtk::SpinButton sbScaling;
   16.22 +    Gtk::HBox box;
   16.23 +    Gtk::Button btnClear;
   16.24 +    void clearBackground();
   16.25 +    void setBackground();
   16.26 +  public:
   16.27 +    BackgroundChooserDialog(MapStorage* ms);
   16.28 +};
   16.29 +
   16.30 +#endif
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/bootstrap	Mon Jul 07 08:10:39 2008 -0500
    17.3 @@ -0,0 +1,85 @@
    17.4 +#!/bin/bash
    17.5 +
    17.6 +quiet=0
    17.7 +function quiet { [[ $quiet == 1 ]]; }
    17.8 +
    17.9 +if [[ "$1" == "-q" ]]; then
   17.10 +  quiet=1
   17.11 +  shift
   17.12 +fi
   17.13 +
   17.14 +prev=
   17.15 +for option
   17.16 +do
   17.17 +  if test -n "$prev"
   17.18 +  then
   17.19 +    eval "$prev=\$option"
   17.20 +    prev=
   17.21 +    continue
   17.22 +  fi
   17.23 +
   17.24 +  optarg=`expr "x$option" : 'x[^=]*=\(.*\)'`
   17.25 +
   17.26 +  case $option in
   17.27 +
   17.28 +  -amver | --amver)
   17.29 +    prev=amver ;;
   17.30 +  -amver=* | --amver=*)
   17.31 +    amver=$optarg ;;
   17.32 +
   17.33 +  -acver | --acver)
   17.34 +    prev=acver ;;
   17.35 +  -acver=* | --acver=*)
   17.36 +    acver=$optarg ;;
   17.37 +
   17.38 +  --help | -h)
   17.39 +    cat << EOF
   17.40 +Usage: $0 [OPTION]
   17.41 +
   17.42 +Options:
   17.43 +  -h, --help            display this help and exit
   17.44 +      --amver=VERSION   use VERSION version of automake
   17.45 +      --acver=VERSION   use VERSION version of autoconf
   17.46 +
   17.47 +Expamle:
   17.48 +  $0 --amver=1.8 --acver=2.59
   17.49 +EOF
   17.50 +    exit 0
   17.51 +    ;;
   17.52 +
   17.53 +  *)
   17.54 +    cat << EOF >&2
   17.55 +$0: unrecognized option: $option
   17.56 +Try \`$0 --help' for more information.
   17.57 +EOF
   17.58 +    exit 1
   17.59 +    ;;
   17.60 +
   17.61 +  esac
   17.62 +done
   17.63 +
   17.64 +automake=automake
   17.65 +aclocal=aclocal
   17.66 +autoconf=autoconf
   17.67 +autoheader=autoheader
   17.68 +
   17.69 +if test -n "$amver"
   17.70 +then
   17.71 +  automake=automake-$amver
   17.72 +  aclocal=aclocal-$amver
   17.73 +fi
   17.74 +
   17.75 +if test -n "$acver"
   17.76 +then
   17.77 +  autoconf=autoconf-$acver
   17.78 +  autoheader=autoheader-$acver
   17.79 +fi
   17.80 +
   17.81 +set -e
   17.82 +quiet || set -x
   17.83 +
   17.84 +autopoint
   17.85 +$aclocal -I m4
   17.86 +$autoconf
   17.87 +$autoheader
   17.88 +$automake --add-missing --copy --gnu
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/color.lgf	Mon Jul 07 08:10:39 2008 -0500
    18.3 @@ -0,0 +1,370 @@
    18.4 +@nodes 
    18.5 +coordinates_x	coordinates_y	label	
    18.6 +-357	-128	1	
    18.7 +-298	-135	2	
    18.8 +-229	-140	3	
    18.9 +-160	-146	4	
   18.10 +-84	-149	5	
   18.11 +-3	-155	6	
   18.12 +76	-155	7	
   18.13 +155	-151	8	
   18.14 +229	-138	9	
   18.15 +298	-113	10	
   18.16 +362	-88	11	
   18.17 +433	-53	12	
   18.18 +447	3	13	
   18.19 +416	59	14	
   18.20 +338	69	15	
   18.21 +281	31	16	
   18.22 +217	6	17	
   18.23 +143	-1	18	
   18.24 +69	-1	19	
   18.25 +-7	3	20	
   18.26 +-73	3	21	
   18.27 +-137	-3	22	
   18.28 +-193	-26	23	
   18.29 +-255	-30	24	
   18.30 +-303	-2	25	
   18.31 +-348	37	26	
   18.32 +-355	92	27	
   18.33 +-335	145	28	
   18.34 +-299	181	29	
   18.35 +-229	186	30	
   18.36 +-164	154	31	
   18.37 +-104	126	32	
   18.38 +-46	134	33	
   18.39 +0	169	34	
   18.40 +47	197	35	
   18.41 +100	195	36	
   18.42 +141	161	37	
   18.43 +195	134	38	
   18.44 +256	146	39	
   18.45 +314	182	40	
   18.46 +370	207	41	
   18.47 +431	244	42	
   18.48 +
   18.49 +@arcs
   18.50 +		label	
   18.51 +42	41	1	
   18.52 +41	40	2	
   18.53 +40	39	3	
   18.54 +39	38	4	
   18.55 +38	37	5	
   18.56 +37	36	6	
   18.57 +36	35	7	
   18.58 +35	34	8	
   18.59 +34	33	9	
   18.60 +33	32	10	
   18.61 +32	31	11	
   18.62 +31	30	12	
   18.63 +30	29	13	
   18.64 +29	28	14	
   18.65 +28	27	15	
   18.66 +27	26	16	
   18.67 +26	25	17	
   18.68 +25	24	18	
   18.69 +24	23	19	
   18.70 +23	22	20	
   18.71 +22	21	21	
   18.72 +21	20	22	
   18.73 +20	19	23	
   18.74 +19	18	24	
   18.75 +18	17	25	
   18.76 +17	16	26	
   18.77 +16	15	27	
   18.78 +15	14	28	
   18.79 +14	13	29	
   18.80 +13	12	30	
   18.81 +12	11	31	
   18.82 +11	10	32	
   18.83 +10	9	33	
   18.84 +9	8	34	
   18.85 +8	7	35	
   18.86 +7	6	36	
   18.87 +6	5	37	
   18.88 +5	4	38	
   18.89 +4	3	39	
   18.90 +3	2	40	
   18.91 +2	1	41	
   18.92 +
   18.93 +@gui
   18.94 +<arrow_pos>
   18.95 + <item>
   18.96 +  <first>1</first>
   18.97 +  <second>
   18.98 +   <x>400.5</x><y>225.5</y>
   18.99 +  </second>
  18.100 + </item>
  18.101 + <item>
  18.102 +  <first>2</first>
  18.103 +  <second>
  18.104 +   <x>342</x><y>194.5</y>
  18.105 +  </second>
  18.106 + </item>
  18.107 + <item>
  18.108 +  <first>3</first>
  18.109 +  <second>
  18.110 +   <x>285</x><y>164</y>
  18.111 +  </second>
  18.112 + </item>
  18.113 + <item>
  18.114 +  <first>4</first>
  18.115 +  <second>
  18.116 +   <x>225.5</x><y>140</y>
  18.117 +  </second>
  18.118 + </item>
  18.119 + <item>
  18.120 +  <first>5</first>
  18.121 +  <second>
  18.122 +   <x>168</x><y>147.5</y>
  18.123 +  </second>
  18.124 + </item>
  18.125 + <item>
  18.126 +  <first>6</first>
  18.127 +  <second>
  18.128 +   <x>120.5</x><y>178</y>
  18.129 +  </second>
  18.130 + </item>
  18.131 + <item>
  18.132 +  <first>7</first>
  18.133 +  <second>
  18.134 +   <x>73.5</x><y>196</y>
  18.135 +  </second>
  18.136 + </item>
  18.137 + <item>
  18.138 +  <first>8</first>
  18.139 +  <second>
  18.140 +   <x>23.5</x><y>183</y>
  18.141 +  </second>
  18.142 + </item>
  18.143 + <item>
  18.144 +  <first>9</first>
  18.145 +  <second>
  18.146 +   <x>-23</x><y>151.5</y>
  18.147 +  </second>
  18.148 + </item>
  18.149 + <item>
  18.150 +  <first>10</first>
  18.151 +  <second>
  18.152 +   <x>-75</x><y>130</y>
  18.153 +  </second>
  18.154 + </item>
  18.155 + <item>
  18.156 +  <first>11</first>
  18.157 +  <second>
  18.158 +   <x>-134</x><y>140</y>
  18.159 +  </second>
  18.160 + </item>
  18.161 + <item>
  18.162 +  <first>12</first>
  18.163 +  <second>
  18.164 +   <x>-196.5</x><y>170</y>
  18.165 +  </second>
  18.166 + </item>
  18.167 + <item>
  18.168 +  <first>13</first>
  18.169 +  <second>
  18.170 +   <x>-264</x><y>183.5</y>
  18.171 +  </second>
  18.172 + </item>
  18.173 + <item>
  18.174 +  <first>14</first>
  18.175 +  <second>
  18.176 +   <x>-317</x><y>163</y>
  18.177 +  </second>
  18.178 + </item>
  18.179 + <item>
  18.180 +  <first>15</first>
  18.181 +  <second>
  18.182 +   <x>-345</x><y>118.5</y>
  18.183 +  </second>
  18.184 + </item>
  18.185 + <item>
  18.186 +  <first>16</first>
  18.187 +  <second>
  18.188 +   <x>-351.5</x><y>64.5</y>
  18.189 +  </second>
  18.190 + </item>
  18.191 + <item>
  18.192 +  <first>17</first>
  18.193 +  <second>
  18.194 +   <x>-325.5</x><y>17.5</y>
  18.195 +  </second>
  18.196 + </item>
  18.197 + <item>
  18.198 +  <first>18</first>
  18.199 +  <second>
  18.200 +   <x>-279</x><y>-16</y>
  18.201 +  </second>
  18.202 + </item>
  18.203 + <item>
  18.204 +  <first>19</first>
  18.205 +  <second>
  18.206 +   <x>-224</x><y>-28</y>
  18.207 +  </second>
  18.208 + </item>
  18.209 + <item>
  18.210 +  <first>20</first>
  18.211 +  <second>
  18.212 +   <x>-165</x><y>-14.5</y>
  18.213 +  </second>
  18.214 + </item>
  18.215 + <item>
  18.216 +  <first>21</first>
  18.217 +  <second>
  18.218 +   <x>-105</x><y>0</y>
  18.219 +  </second>
  18.220 + </item>
  18.221 + <item>
  18.222 +  <first>22</first>
  18.223 +  <second>
  18.224 +   <x>-40</x><y>3</y>
  18.225 +  </second>
  18.226 + </item>
  18.227 + <item>
  18.228 +  <first>23</first>
  18.229 +  <second>
  18.230 +   <x>31</x><y>1</y>
  18.231 +  </second>
  18.232 + </item>
  18.233 + <item>
  18.234 +  <first>24</first>
  18.235 +  <second>
  18.236 +   <x>106</x><y>-1</y>
  18.237 +  </second>
  18.238 + </item>
  18.239 + <item>
  18.240 +  <first>25</first>
  18.241 +  <second>
  18.242 +   <x>180</x><y>2.5</y>
  18.243 +  </second>
  18.244 + </item>
  18.245 + <item>
  18.246 +  <first>26</first>
  18.247 +  <second>
  18.248 +   <x>249</x><y>18.5</y>
  18.249 +  </second>
  18.250 + </item>
  18.251 + <item>
  18.252 +  <first>27</first>
  18.253 +  <second>
  18.254 +   <x>309.5</x><y>50</y>
  18.255 +  </second>
  18.256 + </item>
  18.257 + <item>
  18.258 +  <first>28</first>
  18.259 +  <second>
  18.260 +   <x>377</x><y>64</y>
  18.261 +  </second>
  18.262 + </item>
  18.263 + <item>
  18.264 +  <first>29</first>
  18.265 +  <second>
  18.266 +   <x>431.5</x><y>31</y>
  18.267 +  </second>
  18.268 + </item>
  18.269 + <item>
  18.270 +  <first>30</first>
  18.271 +  <second>
  18.272 +   <x>440</x><y>-25</y>
  18.273 +  </second>
  18.274 + </item>
  18.275 + <item>
  18.276 +  <first>31</first>
  18.277 +  <second>
  18.278 +   <x>397.5</x><y>-70.5</y>
  18.279 +  </second>
  18.280 + </item>
  18.281 + <item>
  18.282 +  <first>32</first>
  18.283 +  <second>
  18.284 +   <x>330</x><y>-100.5</y>
  18.285 +  </second>
  18.286 + </item>
  18.287 + <item>
  18.288 +  <first>33</first>
  18.289 +  <second>
  18.290 +   <x>263.5</x><y>-125.5</y>
  18.291 +  </second>
  18.292 + </item>
  18.293 + <item>
  18.294 +  <first>34</first>
  18.295 +  <second>
  18.296 +   <x>192</x><y>-144.5</y>
  18.297 +  </second>
  18.298 + </item>
  18.299 + <item>
  18.300 +  <first>35</first>
  18.301 +  <second>
  18.302 +   <x>115.5</x><y>-153</y>
  18.303 +  </second>
  18.304 + </item>
  18.305 + <item>
  18.306 +  <first>36</first>
  18.307 +  <second>
  18.308 +   <x>36.5</x><y>-155</y>
  18.309 +  </second>
  18.310 + </item>
  18.311 + <item>
  18.312 +  <first>37</first>
  18.313 +  <second>
  18.314 +   <x>-43.5</x><y>-152</y>
  18.315 +  </second>
  18.316 + </item>
  18.317 + <item>
  18.318 +  <first>38</first>
  18.319 +  <second>
  18.320 +   <x>-122</x><y>-147.5</y>
  18.321 +  </second>
  18.322 + </item>
  18.323 + <item>
  18.324 +  <first>39</first>
  18.325 +  <second>
  18.326 +   <x>-194.5</x><y>-143</y>
  18.327 +  </second>
  18.328 + </item>
  18.329 + <item>
  18.330 +  <first>40</first>
  18.331 +  <second>
  18.332 +   <x>-263.5</x><y>-137.5</y>
  18.333 +  </second>
  18.334 + </item>
  18.335 + <item>
  18.336 +  <first>41</first>
  18.337 +  <second>
  18.338 +   <x>-327.5</x><y>-131.5</y>
  18.339 +  </second>
  18.340 + </item>
  18.341 +</arrow_pos>
  18.342 +<active_nodemaps>
  18.343 + <item>
  18.344 +  <first>0</first>
  18.345 +  <second></second>
  18.346 + </item>
  18.347 + <item>
  18.348 +  <first>1</first>
  18.349 +  <second>label</second>
  18.350 + </item>
  18.351 + <item>
  18.352 +  <first>2</first>
  18.353 +  <second></second>
  18.354 + </item>
  18.355 +</active_nodemaps>
  18.356 +<active_edgemaps>
  18.357 + <item>
  18.358 +  <first>0</first>
  18.359 +  <second></second>
  18.360 + </item>
  18.361 + <item>
  18.362 +  <first>1</first>
  18.363 +  <second>label</second>
  18.364 + </item>
  18.365 + <item>
  18.366 +  <first>2</first>
  18.367 +  <second></second>
  18.368 + </item>
  18.369 +</active_edgemaps>
  18.370 +<redesign-attraction>0.05</redesign-attraction>
  18.371 +<redesign-propulsation>40000</redesign-propulsation>
  18.372 +<redesign-iteration>20</redesign-iteration>
  18.373 +@end
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/configure.ac	Mon Jul 07 08:10:39 2008 -0500
    19.3 @@ -0,0 +1,76 @@
    19.4 +dnl Process this file with autoconf to produce a configure script.
    19.5 +
    19.6 +dnl Version information.
    19.7 +m4_define([glemon_version_major], [0])
    19.8 +m4_define([glemon_version_minor], [5])
    19.9 +m4_define([glemon_version_micro], [90])
   19.10 +m4_define([glemon_version_nano], [])
   19.11 +m4_define([glemon_version_tag], [svn])
   19.12 +m4_define([glemon_svn_revision], [m4_normalize(esyscmd([svn info |grep ^Revision |cut -d ' ' -f 2]))])
   19.13 +m4_define([glemon_version], [glemon_version_major().glemon_version_minor()ifelse(glemon_version_micro(), [], [], [.glemon_version_micro()])ifelse(glemon_version_nano(), [], [], [.glemon_version_nano()])ifelse(glemon_version_tag(), [], [], glemon_version_tag(), [svn], [[_]glemon_version_tag()[]glemon_svn_revision()], [[_]glemon_version_tag()])])
   19.14 +
   19.15 +AC_PREREQ([2.59])
   19.16 +AC_INIT([gLEMON], [glemon_version()], [etik-ol@cs.elte.hu], [glemon])
   19.17 +AC_CONFIG_AUX_DIR([build-aux])
   19.18 +AC_CONFIG_MACRO_DIR([m4])
   19.19 +AM_INIT_AUTOMAKE([-Wall -Werror foreign])
   19.20 +AC_CONFIG_SRCDIR([main_win.h])
   19.21 +AC_CONFIG_HEADERS([config.h])
   19.22 +
   19.23 +dnl Checks for programs.
   19.24 +AC_PROG_CXX
   19.25 +AC_PROG_CC
   19.26 +AM_GNU_GETTEXT_VERSION([0.14.2])
   19.27 +AM_GNU_GETTEXT([external])
   19.28 +
   19.29 +dnl Checks for libraries.
   19.30 +PKG_CHECK_MODULES([GTK], [libgnomecanvasmm-2.6 >= 2.6.0 gtkmm-2.4 >= 2.6])
   19.31 +
   19.32 +AC_ARG_WITH([lemon],
   19.33 +AS_HELP_STRING([--with-lemon@<:@=PREFIX@:>@], [search for LEMON under PREFIX]), [], [with_lemon=no])
   19.34 +if test x"$with_lemon" != x"no"; then
   19.35 +  export PKG_CONFIG_PATH="$with_lemon/lib/pkgconfig/:$PKG_CONFIG_PATH"
   19.36 +fi
   19.37 +
   19.38 +PKG_CHECK_MODULES([LEMON], [lemon >= 0.6.90])
   19.39 +
   19.40 +dnl Checks for header files.
   19.41 +AC_CHECK_HEADERS([libintl.h locale.h])
   19.42 +
   19.43 +dnl Checks for typedefs, structures, and compiler characteristics.
   19.44 +AC_HEADER_STDBOOL
   19.45 +AC_C_CONST
   19.46 +
   19.47 +dnl Checks for library functions.
   19.48 +AC_CHECK_FUNCS([setlocale sqrt])
   19.49 +
   19.50 +AC_CONFIG_FILES([
   19.51 +Makefile
   19.52 +glemon.spec
   19.53 +autopackage/default.apspec
   19.54 +po/Makefile.in
   19.55 +m4/Makefile
   19.56 +])
   19.57 +
   19.58 +AC_OUTPUT
   19.59 +
   19.60 +echo
   19.61 +echo '****************************** SUMMARY ******************************'
   19.62 +echo
   19.63 +echo Package version............... : $PACKAGE-$VERSION
   19.64 +echo
   19.65 +echo C++ compiler.................. : $CXX
   19.66 +echo C++ compiles flags............ : $CXXFLAGS
   19.67 +echo
   19.68 +echo LEMON CFLAGS.................. : $LEMON_CFLAGS
   19.69 +echo LEMON LIBS.................... : $LEMON_LIBS
   19.70 +echo
   19.71 +echo The packace will be installed in
   19.72 +echo -n '  '
   19.73 +echo $prefix.
   19.74 +echo
   19.75 +echo '*********************************************************************'
   19.76 +
   19.77 +echo
   19.78 +echo configure complete, now type \'make\' and then \'make install\'.
   19.79 +echo
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/design_win.cc	Mon Jul 07 08:10:39 2008 -0500
    20.3 @@ -0,0 +1,98 @@
    20.4 +/* -*- C++ -*-
    20.5 + *
    20.6 + * This file is a part of LEMON, a generic C++ optimization library
    20.7 + *
    20.8 + * Copyright (C) 2003-2006
    20.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   20.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   20.11 + *
   20.12 + * Permission to use, modify and distribute this software is granted
   20.13 + * provided that this copyright notice appears in all copies. For
   20.14 + * precise terms see the accompanying LICENSE file.
   20.15 + *
   20.16 + * This software is provided "AS IS" with no warranty of any kind,
   20.17 + * express or implied, and with no claim as to its suitability for any
   20.18 + * purpose.
   20.19 + *
   20.20 + */
   20.21 +
   20.22 +#include <design_win.h>
   20.23 +
   20.24 +bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
   20.25 +{
   20.26 +  if(e->keyval==GDK_Escape)
   20.27 +  {
   20.28 +    on_hide();
   20.29 +  }
   20.30 +  return true;
   20.31 +}
   20.32 +
   20.33 +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
   20.34 +{
   20.35 +  set_title(title);
   20.36 +
   20.37 +  //mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title));
   20.38 +
   20.39 +  signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
   20.40 +
   20.41 +  Gtk::VBox * vbox=new Gtk::VBox();
   20.42 +  vbox->set_spacing(5);
   20.43 +
   20.44 +  Gtk::Label * attraction_label=new Gtk::Label("Arc elasticity: ");
   20.45 +  Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
   20.46 +  Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
   20.47 +
   20.48 +  Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
   20.49 +  Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
   20.50 +  Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
   20.51 +
   20.52 +  attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
   20.53 +  propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
   20.54 +  iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
   20.55 +
   20.56 +  close_button=new Gtk::Button("Redesign");
   20.57 +
   20.58 +  attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
   20.59 +  propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
   20.60 +  iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
   20.61 +  close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
   20.62 +
   20.63 +  table.attach(*attraction_label,0,1,0,1);
   20.64 +  table.attach(*propulsation_label,0,1,1,2);
   20.65 +  table.attach(*iteration_label,0,1,2,3);
   20.66 +  table.attach(*attraction,1,2,0,1);
   20.67 +  table.attach(*propulsation,1,2,1,2);
   20.68 +  table.attach(*iteration,1,2,2,3);
   20.69 +  table.attach(*close_button,0,2,3,4);
   20.70 +
   20.71 +  add(table);
   20.72 +
   20.73 +  show_all_children();
   20.74 +};
   20.75 +
   20.76 +void DesignWin::emit_attraction()
   20.77 +{
   20.78 +  signal_attraction_ch.emit(attraction->get_value());
   20.79 +}
   20.80 +
   20.81 +void DesignWin::emit_propulsation()
   20.82 +{
   20.83 +  signal_propulsation_ch.emit(propulsation->get_value());
   20.84 +}
   20.85 +
   20.86 +void DesignWin::emit_iteration()
   20.87 +{
   20.88 +  signal_iteration_ch.emit((int)iteration->get_value());
   20.89 +}
   20.90 +
   20.91 +void DesignWin::set_title(std::string tabname)
   20.92 +{
   20.93 +  Gtk::Window::set_title("Design Setup - "+tabname);
   20.94 +}
   20.95 +
   20.96 +void DesignWin::set_data(double attr, double propuls, int it)
   20.97 +{
   20.98 +  attraction->set_value(attr);
   20.99 +  propulsation->set_value(propuls);
  20.100 +  iteration->set_value(it);
  20.101 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/design_win.h	Mon Jul 07 08:10:39 2008 -0500
    21.3 @@ -0,0 +1,63 @@
    21.4 +/* -*- C++ -*-
    21.5 + *
    21.6 + * This file is a part of LEMON, a generic C++ optimization library
    21.7 + *
    21.8 + * Copyright (C) 2003-2006
    21.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   21.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   21.11 + *
   21.12 + * Permission to use, modify and distribute this software is granted
   21.13 + * provided that this copyright notice appears in all copies. For
   21.14 + * precise terms see the accompanying LICENSE file.
   21.15 + *
   21.16 + * This software is provided "AS IS" with no warranty of any kind,
   21.17 + * express or implied, and with no claim as to its suitability for any
   21.18 + * purpose.
   21.19 + *
   21.20 + */
   21.21 +
   21.22 +#ifndef DESWIN_H
   21.23 +#define DESWIN_H
   21.24 +
   21.25 +#include <all_include.h>
   21.26 +#include <libgnomecanvasmm.h>
   21.27 +#include <libgnomecanvasmm/polygon.h>
   21.28 +
   21.29 +class DesignWin : public Gtk::Window
   21.30 +{
   21.31 +private:
   21.32 +  Gtk::SpinButton * attraction;
   21.33 +  Gtk::SpinButton * propulsation;
   21.34 +  Gtk::SpinButton * iteration;
   21.35 +  Gtk::Table table;
   21.36 +  Gtk::Button * close_button;
   21.37 +
   21.38 +  sigc::signal<void, double> signal_attraction_ch;
   21.39 +  sigc::signal<void, double> signal_propulsation_ch;
   21.40 +  sigc::signal<void, int> signal_iteration_ch;
   21.41 +  sigc::signal<void> close_run_pr;
   21.42 +
   21.43 +  void emit_attraction();
   21.44 +  void emit_propulsation();
   21.45 +  void emit_iteration();
   21.46 +  void emit_closerun(){close_run_pr.emit();};
   21.47 +
   21.48 +public:
   21.49 +  ///Close window if escape key is pressed.
   21.50 +  bool closeIfEscapeIsPressed(GdkEventKey* e);
   21.51 +
   21.52 +  ///Constructor
   21.53 +
   21.54 +  ///It builds the window.
   21.55 +  DesignWin(const std::string&, double, double, int);
   21.56 +
   21.57 +  sigc::signal<void, double> signal_attraction(){return signal_attraction_ch;};
   21.58 +  sigc::signal<void, double> signal_propulsation(){return signal_propulsation_ch;};
   21.59 +  sigc::signal<void, int> signal_iteration(){return signal_iteration_ch;};
   21.60 +  sigc::signal<void> close_run(){return close_run_pr;};
   21.61 +
   21.62 +  void set_title(std::string);
   21.63 +
   21.64 +  void set_data(double, double, int);
   21.65 +};
   21.66 +#endif //DESWIN_H
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/dijkstrabox.cc	Mon Jul 07 08:10:39 2008 -0500
    22.3 @@ -0,0 +1,247 @@
    22.4 +/* -*- C++ -*-
    22.5 + *
    22.6 + * This file is a part of LEMON, a generic C++ optimization library
    22.7 + *
    22.8 + * Copyright (C) 2003-2006
    22.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   22.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   22.11 + *
   22.12 + * Permission to use, modify and distribute this software is granted
   22.13 + * provided that this copyright notice appears in all copies. For
   22.14 + * precise terms see the accompanying LICENSE file.
   22.15 + *
   22.16 + * This software is provided "AS IS" with no warranty of any kind,
   22.17 + * express or implied, and with no claim as to its suitability for any
   22.18 + * purpose.
   22.19 + *
   22.20 + */
   22.21 +
   22.22 +#include <mapstorage.h>
   22.23 +#include <mapselector.h>
   22.24 +#include <algobox.h>
   22.25 +#include <dijkstrabox.h>
   22.26 +
   22.27 +#include <lemon/dijkstra.h>
   22.28 +
   22.29 +//No Suurballe in Lemon 1.0
   22.30 +//#include <lemon/suurballe.h>
   22.31 +#include <lemon/path.h>
   22.32 +
   22.33 +enum {INPUT, OUTPUT, MAP_NUM};
   22.34 +
   22.35 +DijkstraBox::DijkstraBox(std::vector<std::string> t):AlgoBox()
   22.36 +{
   22.37 +  init(t);
   22.38 +}
   22.39 +    
   22.40 +SuurballeBox::SuurballeBox(std::vector<std::string> t):DijkstraBox(t)
   22.41 +{
   22.42 +  Gtk::Adjustment * adjustment=new Gtk::Adjustment(2, 1, 20, 1, 5);
   22.43 +  num_set = new Gtk::SpinButton(*adjustment, 5,0);
   22.44 +
   22.45 +  Gtk::Label * label=new Gtk::Label("No. of paths to find: ");
   22.46 +//   hbox.pack_start(*label);
   22.47 +//   hbox.pack_start(*num_set);
   22.48 +//   hbox.show_all_children();
   22.49 +
   22.50 +  table.attach(*label, 0,1,2,3);
   22.51 +  table.attach(*num_set, 1,2,2,3);
   22.52 +
   22.53 +
   22.54 +//   pack_start(hbox);
   22.55 +}
   22.56 +    
   22.57 +void DijkstraBox::run()
   22.58 +{
   22.59 +  if(
   22.60 +      tabcbt.get_active_text()!="" &&
   22.61 +      (arcmapcbts[INPUT])->get_active_text()!="" &&
   22.62 +      (arcmapcbts[OUTPUT])->get_active_text()!="" &&
   22.63 +      source.get_active_text()!="" &&
   22.64 +      target.get_active_text()!=""
   22.65 +    )
   22.66 +  {
   22.67 +    const Digraph &g=mapstorage->digraph;
   22.68 +    Node from, to;
   22.69 +
   22.70 +    get_from_to(from, to, (Digraph&)g);
   22.71 +
   22.72 +    std::ostringstream o;
   22.73 +
   22.74 +    if(!(from==to))
   22.75 +    {
   22.76 +      std::string inputmapName = arcmapcbts[INPUT]->get_active_text();
   22.77 +      std::string outputmapName = arcmapcbts[OUTPUT]->get_active_text();
   22.78 +
   22.79 +      MapStorage::NumericArcMap& inputmap = mapstorage->getNumericArcMap(inputmapName);
   22.80 +      MapStorage::NumericArcMap& outputmap = mapstorage->getNumericArcMap(outputmapName);
   22.81 +
   22.82 +      //zero out output map
   22.83 +      for (ArcIt i(g); i!=INVALID; ++i)
   22.84 +      {
   22.85 +        outputmap[i]=0;
   22.86 +      }
   22.87 +
   22.88 +      Dijkstra<Digraph, MapStorage::NumericArcMap > dijkstra(g, inputmap);
   22.89 +      dijkstra.run(from, to);
   22.90 +
   22.91 +      if(dijkstra.reached(to))
   22.92 +      {
   22.93 +        Node n=to;
   22.94 +        int length=0;
   22.95 +        while (n!=INVALID && n!=from)
   22.96 +        {
   22.97 +          Arc e=dijkstra.predArc(n);
   22.98 +          outputmap[e]=1;
   22.99 +          n=dijkstra.predNode(n);
  22.100 +          length++;
  22.101 +        }
  22.102 +        o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
  22.103 +      }
  22.104 +      else
  22.105 +      {
  22.106 +        o << "Result: failed to find shortest path between ";
  22.107 +        o << source.get_active_text() << " and " << target.get_active_text();
  22.108 +      }
  22.109 +      resultlabel.set_text(o.str());
  22.110 +
  22.111 +      mapstorage->mapChanged(true, (arcmapcbts[OUTPUT])->get_active_text());
  22.112 +      //   mapstorage->changeActiveMap(true, E_COLOR,
  22.113 +      // 			      (arcmapcbts[OUTPUT])->get_active_text());
  22.114 +      //   mapstorage->changeActiveMap(true, E_TEXT,
  22.115 +      // 			      (arcmapcbts[INPUT])->get_active_text());
  22.116 +    }
  22.117 +  }
  22.118 +}
  22.119 +
  22.120 +void SuurballeBox::run()
  22.121 +{
  22.122 +  if(
  22.123 +     tabcbt.get_active_text()!="" &&
  22.124 +     (arcmapcbts[INPUT])->get_active_text()!="" &&
  22.125 +     (arcmapcbts[OUTPUT])->get_active_text()!="" &&
  22.126 +     source.get_active_text()!="" &&
  22.127 +     target.get_active_text()!=""
  22.128 +     )
  22.129 +    {
  22.130 +      const Digraph &g=mapstorage->digraph;
  22.131 +      Node from, to;
  22.132 +
  22.133 +      get_from_to(from, to, (Digraph&)g);
  22.134 +
  22.135 +      std::ostringstream o;
  22.136 +
  22.137 +      if(!(from==to))
  22.138 +	{
  22.139 +          MapStorage::NumericArcMap& inputmap=
  22.140 +	    mapstorage->getNumericArcMap(arcmapcbts[INPUT]->get_active_text());
  22.141 +          MapStorage::NumericArcMap& outputmap=
  22.142 +	    mapstorage->getNumericArcMap(arcmapcbts[OUTPUT]->get_active_text());
  22.143 +
  22.144 +	  //zero out output map
  22.145 +	  for (ArcIt i(g); i!=INVALID; ++i)
  22.146 +	    {
  22.147 +	      outputmap[i]=0;
  22.148 +	    }
  22.149 +	  
  22.150 +	  //No Suurballe in Lemon 1.0
  22.151 +	  //Suurballe<Digraph, MapStorage::NumericArcMap > sb((Digraph&)g, inputmap, from, to);
  22.152 +	  
  22.153 +	  int found=0;
  22.154 +	  //No Suurballe in Lemon 1.0
  22.155 +	  //found=sb.run(num_set->get_value_as_int());
  22.156 +	  if(found)
  22.157 +	    {
  22.158 +	      for(int j=0;j<found;j++)
  22.159 +		{
  22.160 +		  Path<Digraph> path;
  22.161 +		  //No Suurballe in Lemon 1.0
  22.162 +		  //path=sb.path(j);
  22.163 +		  for(int k=0;k<path.length();k++)
  22.164 +		    {
  22.165 +		      outputmap[path.nth(k)]=j+1;
  22.166 +		    }
  22.167 +		}
  22.168 +	      o << "Result: found " << found << " paths between ";
  22.169 +	      o << source.get_active_text() << " and " << target.get_active_text();
  22.170 +	    }
  22.171 +	  else
  22.172 +	    {
  22.173 +	      o << "Result: failed to find shortest path between ";
  22.174 +	      o << source.get_active_text() << " and " << target.get_active_text();
  22.175 +	    }
  22.176 +	  resultlabel.set_text(o.str());
  22.177 +	  
  22.178 +	  mapstorage->mapChanged(true, (arcmapcbts[OUTPUT])->get_active_text());
  22.179 +	  //   mapstorage->changeActiveMap(true, E_COLOR,
  22.180 +	  // 			      (arcmapcbts[OUTPUT])->get_active_text());
  22.181 +	  //   mapstorage->changeActiveMap(true, E_TEXT,
  22.182 +	  // 			      (arcmapcbts[INPUT])->get_active_text());
  22.183 +	}
  22.184 +    }
  22.185 +}
  22.186 +    
  22.187 +void DijkstraBox::build_box()
  22.188 +{
  22.189 +  //if active tab is changed, labels of digraph nodes had to be loaded into comboboxes
  22.190 +  //this can be done after the maps are loaded into ComboBoxes
  22.191 +  signal_upon_maplist_updated().connect(sigc::mem_fun(*this, &DijkstraBox::maplists_updated));
  22.192 +
  22.193 +  addMapSelector("Cost map: ", true, NUM);
  22.194 +  addMapSelector("Arcs of path here: ", true, NUM);
  22.195 +
  22.196 +  Gtk::Label * source_label=new Gtk::Label("Source: ");
  22.197 +  Gtk::Label * target_label=new Gtk::Label("Target: ");
  22.198 +
  22.199 +  table.attach(*source_label, 0,1,0,1);
  22.200 +  table.attach(*target_label, 0,1,1,2);
  22.201 +  table.attach(source, 1,2,0,1);
  22.202 +  table.attach(target, 1,2,1,2);
  22.203 +
  22.204 +
  22.205 +  pack_start(table);
  22.206 +
  22.207 +  resultlabel.set_text("Result: algorithm is not run yet.");
  22.208 +  pack_start(resultlabel);
  22.209 +}
  22.210 +
  22.211 +void SuurballeBox::build_box()
  22.212 +{
  22.213 +}
  22.214 +
  22.215 +void DijkstraBox::maplists_updated()
  22.216 +{
  22.217 +  if(tabcbt.get_active_text()!="")
  22.218 +    {
  22.219 +      source.clear();
  22.220 +      target.clear();
  22.221 +      const Digraph &g=mapstorage->digraph;
  22.222 +      for (NodeIt i(g); i!=INVALID; ++i)
  22.223 +	{
  22.224 +	  std::ostringstream text;
  22.225 +	  text << mapstorage->getLabel(i);
  22.226 +	  source.prepend_text(text.str());
  22.227 +	  target.prepend_text(text.str());
  22.228 +	}
  22.229 +    }
  22.230 +}
  22.231 +
  22.232 +void DijkstraBox::get_from_to(Node & from, Node & to, Digraph & g)
  22.233 +{
  22.234 +  int assigned=0;
  22.235 +  for (NodeIt i(g); (i!=INVALID) && (assigned<2); ++i)
  22.236 +    {
  22.237 +      std::ostringstream text;
  22.238 +      text << mapstorage->getLabel(i);
  22.239 +      if(!(text.str().compare(source.get_active_text())))
  22.240 +	{
  22.241 +	  from=i;
  22.242 +	  assigned++;
  22.243 +	}
  22.244 +      if(!(text.str().compare(target.get_active_text())))
  22.245 +	{
  22.246 +	  to=i;
  22.247 +	  assigned++;
  22.248 +	}
  22.249 +    }
  22.250 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/dijkstrabox.h	Mon Jul 07 08:10:39 2008 -0500
    23.3 @@ -0,0 +1,91 @@
    23.4 +/* -*- C++ -*-
    23.5 + *
    23.6 + * This file is a part of LEMON, a generic C++ optimization library
    23.7 + *
    23.8 + * Copyright (C) 2003-2006
    23.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   23.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   23.11 + *
   23.12 + * Permission to use, modify and distribute this software is granted
   23.13 + * provided that this copyright notice appears in all copies. For
   23.14 + * precise terms see the accompanying LICENSE file.
   23.15 + *
   23.16 + * This software is provided "AS IS" with no warranty of any kind,
   23.17 + * express or implied, and with no claim as to its suitability for any
   23.18 + * purpose.
   23.19 + *
   23.20 + */
   23.21 +
   23.22 +#ifndef DIJKSTRABOX_H
   23.23 +#define DIJKSTRABOX_H
   23.24 +
   23.25 +class AlgoBox;
   23.26 +
   23.27 +#include <all_include.h>
   23.28 +#include <libgnomecanvasmm.h>
   23.29 +#include <libgnomecanvasmm/polygon.h>
   23.30 +
   23.31 +///Digraphical interface to run Dijkstra algorithm.
   23.32 +
   23.33 +///Child of \ref AlgoBox,
   23.34 +///therefore the only task to do at implementation was to
   23.35 +///
   23.36 +///-call init function with correct parameters from correctly parametrized constructor
   23.37 +///
   23.38 +///-implement \ref build_box function
   23.39 +///
   23.40 +///-implement \ref run function
   23.41 +class DijkstraBox : public AlgoBox
   23.42 +{
   23.43 +protected:
   23.44 +  ///Shows result of Dijkstra algorithm
   23.45 +  Gtk::Label resultlabel;
   23.46 +
   23.47 +
   23.48 +  ///Table for nodeselector widgets
   23.49 +  Gtk::Table table;
   23.50 +
   23.51 +  ///Combobox for select source node
   23.52 +  Gtk::ComboBoxText source;
   23.53 +
   23.54 +  ///Combobox for select target node
   23.55 +  Gtk::ComboBoxText target;
   23.56 +
   23.57 +  ///Gets to and from node from combobox
   23.58 +  void get_from_to(Node &, Node &, Digraph &);
   23.59 +
   23.60 +public:
   23.61 +  ///Calls \ref AlgoBox::init function to initialize class properly, automatically.
   23.62 +  DijkstraBox(std::vector<std::string> t);
   23.63 +
   23.64 +  ///Prepare, run and postprocess Dijkstra algorithm.
   23.65 +
   23.66 +  ///\ref glemon works only with maps filled with double values
   23.67 +  ///at the moment. While Dijkstra nedds a bool map as output.
   23.68 +  ///As postprocess this bool map should be transformed to
   23.69 +  ///double map.
   23.70 +  virtual void run();
   23.71 +
   23.72 +  ///Builds the digraphical design of the interface.
   23.73 +  virtual void build_box();
   23.74 +
   23.75 +  void maplists_updated();
   23.76 +};
   23.77 +
   23.78 +class SuurballeBox : public DijkstraBox
   23.79 +{
   23.80 +  ///number of paths to find
   23.81 +  int num;
   23.82 +  
   23.83 +  ///Widget to set numbewr of paths to find
   23.84 +  Gtk::SpinButton * num_set;
   23.85 +
   23.86 +  ///Holder widget
   23.87 +  Gtk::HBox hbox;
   23.88 +
   23.89 +public:
   23.90 +  SuurballeBox(std::vector<std::string> t);
   23.91 +  void run();
   23.92 +  void build_box();
   23.93 +};
   23.94 +#endif //DIJKSTRABOX_H
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/eps_win.cc	Mon Jul 07 08:10:39 2008 -0500
    24.3 @@ -0,0 +1,110 @@
    24.4 +/* -*- C++ -*-
    24.5 + *
    24.6 + * This file is a part of LEMON, a generic C++ optimization library
    24.7 + *
    24.8 + * Copyright (C) 2003-2006
    24.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   24.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   24.11 + *
   24.12 + * Permission to use, modify and distribute this software is granted
   24.13 + * provided that this copyright notice appears in all copies. For
   24.14 + * precise terms see the accompanying LICENSE file.
   24.15 + *
   24.16 + * This software is provided "AS IS" with no warranty of any kind,
   24.17 + * express or implied, and with no claim as to its suitability for any
   24.18 + * purpose.
   24.19 + *
   24.20 + */
   24.21 +
   24.22 +#include <eps_win.h>
   24.23 +
   24.24 +#include <mapselector.h>
   24.25 +
   24.26 +#include <set>
   24.27 +
   24.28 +bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e)
   24.29 +{
   24.30 +  if(e->keyval==GDK_Escape)
   24.31 +  {
   24.32 +    hide();
   24.33 +  }
   24.34 +  return true;
   24.35 +}
   24.36 +
   24.37 +EpsWin::EpsWin(const std::string& title, std::vector<std::string> n_nml, std::vector<std::string> s_nml):Gtk::Dialog(title, true, true)
   24.38 +{
   24.39 +  set_default_size(200, 50);
   24.40 +
   24.41 +  set_resizable(false);
   24.42 +
   24.43 +  signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed));
   24.44 +
   24.45 +  table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false);
   24.46 +
   24.47 +  std::vector<std::string> labels;
   24.48 +  labels.resize(EPS_PROPERTY_NUM);
   24.49 +
   24.50 +  labels[N_MAPS]="Dump visualized nodemaps";
   24.51 +  labels[E_MAPS]="Dump visualizes arcmaps";
   24.52 +  labels[ARROWS]="Show arrows in directed digraphs";
   24.53 +  labels[PAR]="Indicate parallel arcs";
   24.54 +
   24.55 +  options.resize(EPS_PROPERTY_NUM);
   24.56 +
   24.57 +  for(int i=0;i<EPS_PROPERTY_NUM;i++)
   24.58 +    {
   24.59 +      options[i]=new Gtk::CheckButton(labels[i]);
   24.60 +      (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3);
   24.61 +    }
   24.62 +
   24.63 +  mapselector=new MapSelector(n_nml, s_nml, "", "Nodeshapes", false, true, NUM);
   24.64 +  mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
   24.65 +
   24.66 +  hbox.pack_start(*(new Gtk::Label("Filename")));
   24.67 +  hbox.pack_start(name);
   24.68 +
   24.69 +  Gtk::VBox * vbox=get_vbox();
   24.70 +
   24.71 +  vbox->pack_start(*table);
   24.72 +  vbox->pack_start(*mapselector);
   24.73 +  vbox->pack_start(hbox);
   24.74 +
   24.75 +  //OK button
   24.76 +  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   24.77 +  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
   24.78 +
   24.79 +  show_all_children();
   24.80 +
   24.81 +}
   24.82 +
   24.83 +bool EpsWin::on_delete_event(GdkEventAny * event)
   24.84 +{
   24.85 +  event=event;
   24.86 +  signal_eps_close.emit();
   24.87 +  return true;
   24.88 +}
   24.89 +
   24.90 +void EpsWin::on_response(int response_id)
   24.91 +{
   24.92 +  if(response_id==Gtk::RESPONSE_OK)
   24.93 +    {
   24.94 +      std::vector <bool> values;
   24.95 +      values.resize(EPS_PROPERTY_NUM);
   24.96 +      for(int i=0;i<EPS_PROPERTY_NUM;i++)
   24.97 +	{
   24.98 +	  values[i]=options[i]->get_active();
   24.99 +	}
  24.100 +      signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text());
  24.101 +    }
  24.102 +  on_delete_event(NULL);
  24.103 +}
  24.104 +
  24.105 +void EpsWin::newMapWinNeeded(bool isitarc)
  24.106 +{
  24.107 +  signal_new_map.emit(false);
  24.108 +}
  24.109 +
  24.110 +void EpsWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
  24.111 +{
  24.112 +    mapselector->append_text((Glib::ustring)newmapname, type);
  24.113 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/eps_win.h	Mon Jul 07 08:10:39 2008 -0500
    25.3 @@ -0,0 +1,109 @@
    25.4 +/* -*- C++ -*-
    25.5 + *
    25.6 + * This file is a part of LEMON, a generic C++ optimization library
    25.7 + *
    25.8 + * Copyright (C) 2003-2006
    25.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   25.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   25.11 + *
   25.12 + * Permission to use, modify and distribute this software is granted
   25.13 + * provided that this copyright notice appears in all copies. For
   25.14 + * precise terms see the accompanying LICENSE file.
   25.15 + *
   25.16 + * This software is provided "AS IS" with no warranty of any kind,
   25.17 + * express or implied, and with no claim as to its suitability for any
   25.18 + * purpose.
   25.19 + *
   25.20 + */
   25.21 +
   25.22 +#ifndef EPS_WIN_H
   25.23 +#define EPS_WIN_H
   25.24 +
   25.25 +class MapSelector;
   25.26 +
   25.27 +#include <all_include.h>
   25.28 +#include <libgnomecanvasmm.h>
   25.29 +#include <libgnomecanvasmm/polygon.h>
   25.30 +#include "map_value.h"
   25.31 +
   25.32 +///Digraph visualization setup window.
   25.33 +
   25.34 +///This class is responsible for creating a window,
   25.35 +///on which the visualization attributes can be
   25.36 +///assigned to maps.
   25.37 +class EpsWin : public Gtk::Dialog
   25.38 +{
   25.39 +protected:
   25.40 +  ///Designing element
   25.41 +  Gtk::Table * table;
   25.42 +  
   25.43 +  ///Information holder
   25.44 +  Gtk::Label * label;
   25.45 +
   25.46 +  ///configuration
   25.47 +  std::vector<Gtk::CheckButton *> options;
   25.48 +
   25.49 +  ///OK, Cancel
   25.50 +  Gtk::Button * ok, * cancel;
   25.51 +
   25.52 +  ///Container in which filename entry are organized.
   25.53 +  Gtk::HBox hbox;
   25.54 +
   25.55 +  ///Filename
   25.56 +  Gtk::Entry name;
   25.57 +
   25.58 +  MapSelector * mapselector;
   25.59 +public:
   25.60 +  ///Constructor
   25.61 +
   25.62 +  ///It creates the widgets shown in \ref EpsWin and
   25.63 +  ///binds the needed signal to the correct place.
   25.64 +  ///\param title title of window
   25.65 +  ///\param eml arcmap list
   25.66 +  ///\param nml nodemap list
   25.67 +  ///\param mw the owner \ref NoteBookTab (\ref mytab)
   25.68 +  EpsWin(const std::string& title, std::vector<std::string>, std::vector<std::string>);
   25.69 +
   25.70 +  ///Deregistrates \ref EpsWin in its \ref NoteBookTab (\ref mytab)
   25.71 +  virtual bool on_delete_event(GdkEventAny *);
   25.72 +
   25.73 +  ///Close window if Esc key pressed.
   25.74 +  virtual bool closeIfEscapeIsPressed(GdkEventKey*);
   25.75 +
   25.76 +  ///Callback function for OK button. It creates the map.
   25.77 +  
   25.78 +  ///If OK is pressed this function
   25.79 +  ///transmits the collected data to
   25.80 +  ///appropriate functions to be able
   25.81 +  ///to create EPS
   25.82 +  virtual void on_response(int response_id);
   25.83 +
   25.84 +  ///indicates that user is ready to export EPS file
   25.85 +  sigc::signal<void, std::vector<bool>, std::string, std::string > signal_eps_details;
   25.86 +
   25.87 +  ///returns \ref signal_eps_details
   25.88 +  sigc::signal<void, std::vector<bool>, std::string, std::string > signal_eps_details_ch(){return signal_eps_details;};
   25.89 +
   25.90 +  ///indicates that the windows can be closed
   25.91 +  sigc::signal<void> signal_eps_close;
   25.92 +
   25.93 +  ///returns \ref signal_eps_close
   25.94 +  sigc::signal<void> signal_eps_close_ch(){return signal_eps_close;};
   25.95 +  
   25.96 +  ///indicates that the windows can be closed
   25.97 +  sigc::signal<void, bool> signal_new_map;
   25.98 +
   25.99 +  ///returns \ref signal_eps_close
  25.100 +  sigc::signal<void, bool> signal_new_map_ch(){return signal_new_map;};
  25.101 +
  25.102 +  ///Function is called when new map is required.
  25.103 +  void newMapWinNeeded(bool);
  25.104 +
  25.105 +  ///This function inserts name of the new nodemap in the name list in \ref MapSelector s
  25.106 +
  25.107 +  ///\param new_name
  25.108 +  ///name of new map
  25.109 +  void registerNewNodeMap(std::string new_name, MapValue::Type type);
  25.110 +};
  25.111 +
  25.112 +#endif //EPS_WIN_H
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/file_import_dialog.cc	Mon Jul 07 08:10:39 2008 -0500
    26.3 @@ -0,0 +1,928 @@
    26.4 +#include "file_import_dialog.h"
    26.5 +#include <gtkmm/dialog.h>
    26.6 +#include <gtkmm/stock.h>
    26.7 +#include <gtkmm/notebook.h>
    26.8 +#include <gtkmm/messagedialog.h>
    26.9 +#include <gtkmm/frame.h>
   26.10 +#include <iostream>
   26.11 +
   26.12 +FileImportDialog::FileImportDialog(ImportData* d) :
   26.13 +  p_data(d)
   26.14 +{
   26.15 +  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   26.16 +  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
   26.17 +
   26.18 +  Gtk::VBox* pVBox = get_vbox();
   26.19 +
   26.20 +  Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook);
   26.21 +  pVBox->pack_start(*nb, Gtk::PACK_EXPAND_WIDGET);
   26.22 +
   26.23 +  Gtk::VBox* vblueMaps = Gtk::manage(new Gtk::VBox(false, 18));
   26.24 +  vblueMaps->set_border_width(12);
   26.25 +
   26.26 +  Gtk::VBox* vbArcMaps = Gtk::manage(new Gtk::VBox(false, 18));
   26.27 +  vbArcMaps->set_border_width(12);
   26.28 +
   26.29 +  Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18));
   26.30 +  vbSpecMaps->set_border_width(12);
   26.31 +
   26.32 +  nb->append_page(*vbSpecMaps, "Special Maps");
   26.33 +  nb->append_page(*vblueMaps, "Node Maps");
   26.34 +  nb->append_page(*vbArcMaps, "Arc Maps");
   26.35 +
   26.36 +  // child widgets of vbSpecMaps
   26.37 +  {
   26.38 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   26.39 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   26.40 +
   26.41 +    {
   26.42 +      Gtk::Label* label1 =
   26.43 +        Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>"));
   26.44 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   26.45 +      label1->set_use_markup();
   26.46 +      box1->pack_start(*label1);
   26.47 +
   26.48 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   26.49 +      box1->pack_start(*box2);
   26.50 +
   26.51 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   26.52 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   26.53 +
   26.54 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
   26.55 +      box2->pack_start(*box3);
   26.56 +
   26.57 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
   26.58 +      box3->pack_start(*box13);
   26.59 +
   26.60 +      rblueCoordNone.set_label("None");
   26.61 +      Gtk::RadioButtonGroup group = rblueCoordNone.get_group();
   26.62 +      box13->pack_start(rblueCoordNone);
   26.63 +
   26.64 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
   26.65 +      box3->pack_start(*box4);
   26.66 +
   26.67 +      rblueCoordOneMap.set_label("One Map");
   26.68 +      rblueCoordOneMap.set_group(group);
   26.69 +      box4->pack_start(rblueCoordOneMap);
   26.70 +
   26.71 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
   26.72 +      box4->pack_start(*box5);
   26.73 +
   26.74 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
   26.75 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
   26.76 +
   26.77 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
   26.78 +      box5->pack_start(*box6);
   26.79 +
   26.80 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
   26.81 +      box6->pack_start(*box7);
   26.82 +
   26.83 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
   26.84 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
   26.85 +
   26.86 +      box7->pack_start(cblueCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
   26.87 +
   26.88 +
   26.89 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
   26.90 +      box3->pack_start(*box8);
   26.91 +
   26.92 +      rblueCoordTwoMaps.set_label("Two Maps");
   26.93 +      rblueCoordTwoMaps.set_group(group);
   26.94 +      box8->pack_start(rblueCoordTwoMaps);
   26.95 +
   26.96 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
   26.97 +      box8->pack_start(*box9);
   26.98 +
   26.99 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
  26.100 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
  26.101 +
  26.102 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
  26.103 +      box9->pack_start(*box10);
  26.104 +
  26.105 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
  26.106 +      box10->pack_start(*box11);
  26.107 +
  26.108 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
  26.109 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
  26.110 +
  26.111 +      box11->pack_start(cblueCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
  26.112 +
  26.113 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
  26.114 +      box10->pack_start(*box12);
  26.115 +
  26.116 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
  26.117 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
  26.118 +
  26.119 +      box12->pack_start(cblueCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
  26.120 +
  26.121 +      cblueCoordOneMap.signal_changed().connect(
  26.122 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged));
  26.123 +      cblueCoordTwoMaps1.signal_changed().connect(
  26.124 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed));
  26.125 +      cblueCoordTwoMaps2.signal_changed().connect(
  26.126 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed));
  26.127 +    }
  26.128 +
  26.129 +    {
  26.130 +      Gtk::Label* label1 =
  26.131 +        Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>"));
  26.132 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  26.133 +      label1->set_use_markup();
  26.134 +      box1->pack_start(*label1);
  26.135 +
  26.136 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  26.137 +      box1->pack_start(*box2);
  26.138 +
  26.139 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  26.140 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  26.141 +
  26.142 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
  26.143 +      box2->pack_start(*box3);
  26.144 +
  26.145 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
  26.146 +      box3->pack_start(*box13);
  26.147 +
  26.148 +      rbArrowCoordNone.set_label("None");
  26.149 +      Gtk::RadioButtonGroup group = rbArrowCoordNone.get_group();
  26.150 +      box13->pack_start(rbArrowCoordNone);
  26.151 +
  26.152 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
  26.153 +      box3->pack_start(*box4);
  26.154 +
  26.155 +      rbArrowCoordOneMap.set_label("One Map");
  26.156 +      rbArrowCoordOneMap.set_group(group);
  26.157 +      box4->pack_start(rbArrowCoordOneMap);
  26.158 +
  26.159 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
  26.160 +      box4->pack_start(*box5);
  26.161 +
  26.162 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
  26.163 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
  26.164 +
  26.165 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
  26.166 +      box5->pack_start(*box6);
  26.167 +
  26.168 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
  26.169 +      box6->pack_start(*box7);
  26.170 +
  26.171 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
  26.172 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
  26.173 +
  26.174 +      box7->pack_start(cbArrowCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
  26.175 +
  26.176 +
  26.177 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
  26.178 +      box3->pack_start(*box8);
  26.179 +
  26.180 +      rbArrowCoordTwoMaps.set_label("Two Maps");
  26.181 +      rbArrowCoordTwoMaps.set_group(group);
  26.182 +      box8->pack_start(rbArrowCoordTwoMaps);
  26.183 +
  26.184 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
  26.185 +      box8->pack_start(*box9);
  26.186 +
  26.187 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
  26.188 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
  26.189 +
  26.190 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
  26.191 +      box9->pack_start(*box10);
  26.192 +
  26.193 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
  26.194 +      box10->pack_start(*box11);
  26.195 +
  26.196 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
  26.197 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
  26.198 +
  26.199 +      box11->pack_start(cbArrowCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
  26.200 +
  26.201 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
  26.202 +      box10->pack_start(*box12);
  26.203 +
  26.204 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
  26.205 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
  26.206 +
  26.207 +      box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
  26.208 +
  26.209 +      cbArrowCoordOneMap.signal_changed().connect(
  26.210 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged));
  26.211 +      cbArrowCoordTwoMaps1.signal_changed().connect(
  26.212 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed));
  26.213 +      cbArrowCoordTwoMaps2.signal_changed().connect(
  26.214 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed));
  26.215 +    }
  26.216 +  }
  26.217 +
  26.218 +  // child widgets of vblueMaps
  26.219 +  {
  26.220 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  26.221 +    vblueMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  26.222 +
  26.223 +    Gtk::Label* label1 =
  26.224 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
  26.225 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  26.226 +    label1->set_use_markup();
  26.227 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  26.228 +
  26.229 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  26.230 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  26.231 +
  26.232 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  26.233 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  26.234 +
  26.235 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  26.236 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  26.237 +
  26.238 +    Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow);
  26.239 +    frame->add(*swNodeMaps);
  26.240 +
  26.241 +    swNodeMaps->add(twNodeMaps);
  26.242 +
  26.243 +    refNodeMapStore = Gtk::ListStore::create(NodeMapColumns);
  26.244 +
  26.245 +    for (std::vector<std::string>::const_iterator it =
  26.246 +        p_data->node_map_names.begin(); it != p_data->node_map_names.end();
  26.247 +        ++it)
  26.248 +    {
  26.249 +      node_tree_view_records.push_back(
  26.250 +          tree_view_record(*it, false, false, true));
  26.251 +    }
  26.252 +
  26.253 +    twNodeMaps.set_model(refNodeMapStore);
  26.254 +    twNodeMaps.append_column("Name", NodeMapColumns.colName);
  26.255 +    {
  26.256 +      int col = twNodeMaps.append_column_editable("Numeric",
  26.257 +          NodeMapColumns.colReadAsNumeric);
  26.258 +      Gtk::CellRendererToggle* pRenderer =
  26.259 +        static_cast<Gtk::CellRendererToggle*>(
  26.260 +            twNodeMaps.get_column_cell_renderer(col-1));
  26.261 +      pRenderer->signal_toggled().connect(
  26.262 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapNumericToggled));
  26.263 +    }
  26.264 +    {
  26.265 +      int col = twNodeMaps.append_column_editable("String",
  26.266 +          NodeMapColumns.colReadAsString);
  26.267 +      Gtk::CellRendererToggle* pRenderer =
  26.268 +        static_cast<Gtk::CellRendererToggle*>(
  26.269 +            twNodeMaps.get_column_cell_renderer(col-1));
  26.270 +      pRenderer->signal_toggled().connect(
  26.271 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapStringToggled));
  26.272 +    }
  26.273 +
  26.274 +    swNodeMaps->set_size_request(-1, 200);
  26.275 +    swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  26.276 +  }
  26.277 +
  26.278 +  // child widgets of vbArcMaps
  26.279 +  {
  26.280 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  26.281 +    vbArcMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  26.282 +
  26.283 +    Gtk::Label* label1 =
  26.284 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
  26.285 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  26.286 +    label1->set_use_markup();
  26.287 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  26.288 +
  26.289 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  26.290 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  26.291 +
  26.292 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  26.293 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  26.294 +
  26.295 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  26.296 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  26.297 +
  26.298 +    Gtk::ScrolledWindow* swArcMaps = Gtk::manage(new Gtk::ScrolledWindow);
  26.299 +    frame->add(*swArcMaps);
  26.300 +
  26.301 +    swArcMaps->add(twArcMaps);
  26.302 +
  26.303 +    refArcMapStore = Gtk::ListStore::create(ArcMapColumns);
  26.304 +
  26.305 +    for (std::vector<std::string>::const_iterator it =
  26.306 +        p_data->arc_map_names.begin(); it != p_data->arc_map_names.end();
  26.307 +        ++it)
  26.308 +    {
  26.309 +      arc_tree_view_records.push_back(
  26.310 +          tree_view_record(*it, false, false, true));
  26.311 +    }
  26.312 +
  26.313 +    twArcMaps.set_model(refArcMapStore);
  26.314 +    twArcMaps.append_column("Name", ArcMapColumns.colName);
  26.315 +    {
  26.316 +      int col = twArcMaps.append_column_editable("Numeric",
  26.317 +          ArcMapColumns.colReadAsNumeric);
  26.318 +      Gtk::CellRendererToggle* pRenderer =
  26.319 +        static_cast<Gtk::CellRendererToggle*>(
  26.320 +            twArcMaps.get_column_cell_renderer(col-1));
  26.321 +      pRenderer->signal_toggled().connect(
  26.322 +          sigc::mem_fun(*this, &FileImportDialog::onArcMapNumericToggled));
  26.323 +    }
  26.324 +    {
  26.325 +      int col = twArcMaps.append_column_editable("String",
  26.326 +          ArcMapColumns.colReadAsString);
  26.327 +      Gtk::CellRendererToggle* pRenderer =
  26.328 +        static_cast<Gtk::CellRendererToggle*>(
  26.329 +            twArcMaps.get_column_cell_renderer(col-1));
  26.330 +      pRenderer->signal_toggled().connect(
  26.331 +          sigc::mem_fun(*this, &FileImportDialog::onArcMapStringToggled));
  26.332 +    }
  26.333 +
  26.334 +    swArcMaps->set_size_request(-1, 200);
  26.335 +    swArcMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  26.336 +  }
  26.337 +
  26.338 +  // fill in the ComboBoxes
  26.339 +  typedef std::vector<std::string> StrVec;
  26.340 +  for (StrVec::const_iterator it = p_data->node_map_names.begin();
  26.341 +      it != p_data->node_map_names.end(); ++it)
  26.342 +  {
  26.343 +    cblueCoordTwoMaps1.append_text(*it);
  26.344 +    cblueCoordTwoMaps2.append_text(*it);
  26.345 +  }
  26.346 +  for (StrVec::const_iterator it = p_data->arc_map_names.begin();
  26.347 +      it != p_data->arc_map_names.end(); ++it)
  26.348 +  {
  26.349 +    cbArrowCoordTwoMaps1.append_text(*it);
  26.350 +    cbArrowCoordTwoMaps2.append_text(*it);
  26.351 +  }
  26.352 +  for (StrVec::const_iterator it = p_data->xy_node_map_names.begin();
  26.353 +      it != p_data->xy_node_map_names.end(); ++it)
  26.354 +  {
  26.355 +    cblueCoordOneMap.append_text(*it);
  26.356 +  }
  26.357 +  for (StrVec::const_iterator it = p_data->xy_arc_map_names.begin();
  26.358 +      it != p_data->xy_arc_map_names.end(); ++it)
  26.359 +  {
  26.360 +    cbArrowCoordOneMap.append_text(*it);
  26.361 +  }
  26.362 +
  26.363 +  if (p_data->isXYNodeMap("coord"))
  26.364 +  {
  26.365 +    cblueCoordOneMap.set_active_text("coord");
  26.366 +  }
  26.367 +  else if (p_data->isXYNodeMap("coords"))
  26.368 +  {
  26.369 +    cblueCoordOneMap.set_active_text("coords");
  26.370 +  }
  26.371 +  else if (p_data->isNodeMap("coord_x") &&
  26.372 +           p_data->isNodeMap("coord_y"))
  26.373 +  {
  26.374 +    cblueCoordTwoMaps1.set_active_text("coord_x");
  26.375 +    cblueCoordTwoMaps2.set_active_text("coord_y");
  26.376 +  }
  26.377 +  else if (p_data->isNodeMap("coords_x") &&
  26.378 +           p_data->isNodeMap("coords_y"))
  26.379 +  {
  26.380 +    cblueCoordTwoMaps1.set_active_text("coords_x");
  26.381 +    cblueCoordTwoMaps2.set_active_text("coords_y");
  26.382 +  }
  26.383 +  else if (p_data->isNodeMap("x") &&
  26.384 +           p_data->isNodeMap("y"))
  26.385 +  {
  26.386 +    cblueCoordTwoMaps1.set_active_text("x");
  26.387 +    cblueCoordTwoMaps2.set_active_text("y");
  26.388 +  }
  26.389 +
  26.390 +  if (p_data->isXYArcMap("arrow"))
  26.391 +  {
  26.392 +    cbArrowCoordOneMap.set_active_text("arrow");
  26.393 +  }
  26.394 +  else if (p_data->isXYArcMap("arrows"))
  26.395 +  {
  26.396 +    cbArrowCoordOneMap.set_active_text("arrows");
  26.397 +  }
  26.398 +  else if (p_data->isXYArcMap("midpoint"))
  26.399 +  {
  26.400 +    cbArrowCoordOneMap.set_active_text("midpoint");
  26.401 +  }
  26.402 +  else if (p_data->isXYArcMap("midpoints"))
  26.403 +  {
  26.404 +    cbArrowCoordOneMap.set_active_text("midpoints");
  26.405 +  }
  26.406 +  else if (p_data->isXYArcMap("mid"))
  26.407 +  {
  26.408 +    cbArrowCoordOneMap.set_active_text("mid");
  26.409 +  }
  26.410 +  else if (p_data->isXYArcMap("mids"))
  26.411 +  {
  26.412 +    cbArrowCoordOneMap.set_active_text("mids");
  26.413 +  }
  26.414 +  else if (p_data->isArcMap("arrow_x") &&
  26.415 +           p_data->isArcMap("arrow_y"))
  26.416 +  {
  26.417 +    cbArrowCoordTwoMaps1.set_active_text("arrow_x");
  26.418 +    cbArrowCoordTwoMaps2.set_active_text("arrow_y");
  26.419 +  }
  26.420 +  else if (p_data->isArcMap("arrows_x") &&
  26.421 +           p_data->isArcMap("arrows_y"))
  26.422 +  {
  26.423 +    cbArrowCoordTwoMaps1.set_active_text("arrows_x");
  26.424 +    cbArrowCoordTwoMaps2.set_active_text("arrows_y");
  26.425 +  }
  26.426 +  else if (p_data->isArcMap("midpoint_x") &&
  26.427 +           p_data->isArcMap("midpoint_y"))
  26.428 +  {
  26.429 +    cbArrowCoordTwoMaps1.set_active_text("midpoint_x");
  26.430 +    cbArrowCoordTwoMaps2.set_active_text("midpoint_y");
  26.431 +  }
  26.432 +  else if (p_data->isArcMap("midpoints_x") &&
  26.433 +           p_data->isArcMap("midpoints_y"))
  26.434 +  {
  26.435 +    cbArrowCoordTwoMaps1.set_active_text("midpoints_x");
  26.436 +    cbArrowCoordTwoMaps2.set_active_text("midpoints_y");
  26.437 +  }
  26.438 +  else if (p_data->isArcMap("mid_x") &&
  26.439 +           p_data->isArcMap("mid_y"))
  26.440 +  {
  26.441 +    cbArrowCoordTwoMaps1.set_active_text("mid_x");
  26.442 +    cbArrowCoordTwoMaps2.set_active_text("mid_y");
  26.443 +  }
  26.444 +  else if (p_data->isArcMap("mids_x") &&
  26.445 +           p_data->isArcMap("mids_y"))
  26.446 +  {
  26.447 +    cbArrowCoordTwoMaps1.set_active_text("mids_x");
  26.448 +    cbArrowCoordTwoMaps2.set_active_text("mids_y");
  26.449 +  }
  26.450 +
  26.451 +  {
  26.452 +    if (cblueCoordOneMap.get_active_text() != "")
  26.453 +      rblueCoordOneMap.set_active();
  26.454 +    else if (cblueCoordTwoMaps1.get_active_text() != "")
  26.455 +      rblueCoordTwoMaps.set_active();
  26.456 +    else
  26.457 +      rblueCoordNone.set_active();
  26.458 +
  26.459 +    if (cbArrowCoordOneMap.get_active_text() != "")
  26.460 +      rbArrowCoordOneMap.set_active();
  26.461 +    else if (cbArrowCoordTwoMaps1.get_active_text() != "")
  26.462 +      rbArrowCoordTwoMaps.set_active();
  26.463 +    else
  26.464 +      rbArrowCoordNone.set_active();
  26.465 +
  26.466 +    onNodeCoordMapNumToggled();
  26.467 +    onArrowCoordMapNumToggled();
  26.468 +
  26.469 +    rblueCoordOneMap.signal_toggled().connect(
  26.470 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
  26.471 +    rblueCoordTwoMaps.signal_toggled().connect(
  26.472 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
  26.473 +    rbArrowCoordOneMap.signal_toggled().connect(
  26.474 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
  26.475 +    rbArrowCoordTwoMaps.signal_toggled().connect(
  26.476 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
  26.477 +  }
  26.478 +
  26.479 +  signal_response().connect(
  26.480 +      sigc::mem_fun(*this, &FileImportDialog::onResponse));
  26.481 +
  26.482 +  update_node_tree_view();
  26.483 +  update_arc_tree_view();
  26.484 +
  26.485 +  show_all_children();
  26.486 +}
  26.487 +
  26.488 +void FileImportDialog::onNodeCoordMapNumToggled()
  26.489 +{
  26.490 +  if (rblueCoordOneMap.get_active())
  26.491 +  {
  26.492 +    cblueCoordOneMap.get_parent()->set_sensitive(true);
  26.493 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(false);
  26.494 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(false);
  26.495 +
  26.496 +    p_data->node_coord_load_from = ImportData::ONE_MAP;
  26.497 +  }
  26.498 +  else if (rblueCoordTwoMaps.get_active())
  26.499 +  {
  26.500 +    cblueCoordOneMap.get_parent()->set_sensitive(false);
  26.501 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(true);
  26.502 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(true);
  26.503 +
  26.504 +    p_data->node_coord_load_from = ImportData::TWO_MAPS;
  26.505 +  }
  26.506 +  else if (rblueCoordNone.get_active())
  26.507 +  {
  26.508 +    cblueCoordOneMap.get_parent()->set_sensitive(false);
  26.509 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(false);
  26.510 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(false);
  26.511 +
  26.512 +    p_data->node_coord_load_from = ImportData::DONT_READ;
  26.513 +  }
  26.514 +  update_node_tree_view();
  26.515 +}
  26.516 +
  26.517 +void FileImportDialog::onArrowCoordMapNumToggled()
  26.518 +{
  26.519 +  if (rbArrowCoordOneMap.get_active())
  26.520 +  {
  26.521 +    cbArrowCoordOneMap.get_parent()->set_sensitive(true);
  26.522 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
  26.523 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
  26.524 +
  26.525 +    p_data->arrow_coord_load_from = ImportData::ONE_MAP;
  26.526 +  }
  26.527 +  else if (rbArrowCoordTwoMaps.get_active())
  26.528 +  {
  26.529 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
  26.530 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(true);
  26.531 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true);
  26.532 +
  26.533 +    p_data->arrow_coord_load_from = ImportData::TWO_MAPS;
  26.534 +  }
  26.535 +  else if (rbArrowCoordNone.get_active())
  26.536 +  {
  26.537 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
  26.538 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
  26.539 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
  26.540 +
  26.541 +    p_data->arrow_coord_load_from = ImportData::DONT_READ;
  26.542 +  }
  26.543 +  update_arc_tree_view();
  26.544 +}
  26.545 +
  26.546 +FileImportDialog::~FileImportDialog()
  26.547 +{
  26.548 +}
  26.549 +
  26.550 +void FileImportDialog::onResponse(int id)
  26.551 +{
  26.552 +  if (id == Gtk::RESPONSE_OK)
  26.553 +  {
  26.554 +    if ((rblueCoordOneMap.get_active() &&
  26.555 +          cblueCoordOneMap.get_active_text() == "") ||
  26.556 +        (rblueCoordTwoMaps.get_active() &&
  26.557 +         (cblueCoordTwoMaps1.get_active_text() == "" ||
  26.558 +          cblueCoordTwoMaps2.get_active_text() == "")))
  26.559 +    {
  26.560 +      Gtk::MessageDialog mdialog("No node map selected.",
  26.561 +          false, Gtk::MESSAGE_ERROR);
  26.562 +      mdialog.run();
  26.563 +      return;
  26.564 +    }
  26.565 +    else if (rblueCoordTwoMaps.get_active() &&
  26.566 +             cblueCoordTwoMaps1.get_active_text() == 
  26.567 +             cblueCoordTwoMaps2.get_active_text())
  26.568 +    {
  26.569 +      Gtk::MessageDialog mdialog(
  26.570 +          "Same node map selected for both coordinates.",
  26.571 +          false, Gtk::MESSAGE_ERROR);
  26.572 +      mdialog.run();
  26.573 +      return;
  26.574 +    }
  26.575 +    if ((rbArrowCoordOneMap.get_active() &&
  26.576 +          cbArrowCoordOneMap.get_active_text() == "") ||
  26.577 +        (rbArrowCoordTwoMaps.get_active() &&
  26.578 +         (cbArrowCoordTwoMaps1.get_active_text() == "" ||
  26.579 +          cbArrowCoordTwoMaps2.get_active_text() == "")))
  26.580 +    {
  26.581 +      Gtk::MessageDialog mdialog("No arc map selected.",
  26.582 +          false, Gtk::MESSAGE_ERROR);
  26.583 +      mdialog.run();
  26.584 +      return;
  26.585 +    }
  26.586 +    else if (rbArrowCoordTwoMaps.get_active() &&
  26.587 +             cbArrowCoordTwoMaps1.get_active_text() == 
  26.588 +             cbArrowCoordTwoMaps2.get_active_text())
  26.589 +    {
  26.590 +      Gtk::MessageDialog mdialog(
  26.591 +          "Same arc map selected for both coordinates.",
  26.592 +          false, Gtk::MESSAGE_ERROR);
  26.593 +      mdialog.run();
  26.594 +      return;
  26.595 +    }
  26.596 +
  26.597 +    for (std::vector<tree_view_record>::const_iterator it =
  26.598 +        node_tree_view_records.begin(); it != node_tree_view_records.end();
  26.599 +        ++it)
  26.600 +    {
  26.601 +      if (it->visible)
  26.602 +      {
  26.603 +        if (it->numeric)
  26.604 +          p_data->numeric_node_map_names.push_back(it->name);
  26.605 +        if (it->string)
  26.606 +          p_data->string_node_map_names.push_back(it->name);
  26.607 +      }
  26.608 +    }
  26.609 +
  26.610 +    for (std::vector<tree_view_record>::const_iterator it =
  26.611 +        arc_tree_view_records.begin(); it != arc_tree_view_records.end();
  26.612 +        ++it)
  26.613 +    {
  26.614 +      if (it->visible)
  26.615 +      {
  26.616 +        if (it->numeric)
  26.617 +          p_data->numeric_arc_map_names.push_back(it->name);
  26.618 +        if (it->string)
  26.619 +          p_data->string_arc_map_names.push_back(it->name);
  26.620 +      }
  26.621 +    }
  26.622 +  }
  26.623 +}
  26.624 +
  26.625 +FileImportDialog::ImportData::ImportData(
  26.626 +    const std::vector<std::string>& _node_map_names,
  26.627 +    const std::vector<std::string>& _arc_map_names) :
  26.628 +  node_map_names(_node_map_names),
  26.629 +  arc_map_names(_arc_map_names)
  26.630 +{
  26.631 +  typedef std::vector<std::string> StrVec;
  26.632 +  {
  26.633 +    StrVec xMaps;
  26.634 +    StrVec yMaps;
  26.635 +    // collect map names ending with ":x" and ":y"
  26.636 +    for (StrVec::const_iterator it = node_map_names.begin();
  26.637 +        it != node_map_names.end(); ++it)
  26.638 +    {
  26.639 +      if ((it->length() >= 3) &&
  26.640 +          (it->substr(it->length()-2, it->length())  == ":x"))
  26.641 +      {
  26.642 +        xMaps.push_back(it->substr(0, it->length()-2));
  26.643 +      }
  26.644 +      if ((it->length() >= 3) &&
  26.645 +          (it->substr(it->length()-2, it->length())  == ":y"))
  26.646 +      {
  26.647 +        yMaps.push_back(it->substr(0, it->length()-2));
  26.648 +      }
  26.649 +    }
  26.650 +
  26.651 +    for (StrVec::const_iterator it1 = xMaps.begin();
  26.652 +        it1 != xMaps.end(); ++it1)
  26.653 +    {
  26.654 +      for (StrVec::const_iterator it2 = yMaps.begin();
  26.655 +          it2 != yMaps.end(); ++it2)
  26.656 +      {
  26.657 +        if (*it1 == *it2) xy_node_map_names.push_back(*it1);
  26.658 +      }
  26.659 +    }
  26.660 +  }
  26.661 +  {
  26.662 +    StrVec xMaps;
  26.663 +    StrVec yMaps;
  26.664 +    // collect map names ending with ":x" and ":y"
  26.665 +    for (StrVec::const_iterator it = arc_map_names.begin();
  26.666 +        it != arc_map_names.end(); ++it)
  26.667 +    {
  26.668 +      if ((it->length() >= 3) &&
  26.669 +          (it->substr(it->length()-2, it->length())  == ":x"))
  26.670 +      {
  26.671 +        xMaps.push_back(it->substr(0, it->length()-2));
  26.672 +      }
  26.673 +      if ((it->length() >= 3) &&
  26.674 +          (it->substr(it->length()-2, it->length())  == ":y"))
  26.675 +      {
  26.676 +        yMaps.push_back(it->substr(0, it->length()-2));
  26.677 +      }
  26.678 +    }
  26.679 +
  26.680 +    for (StrVec::const_iterator it1 = xMaps.begin();
  26.681 +        it1 != xMaps.end(); ++it1)
  26.682 +    {
  26.683 +      for (StrVec::const_iterator it2 = yMaps.begin();
  26.684 +          it2 != yMaps.end(); ++it2)
  26.685 +      {
  26.686 +        if (*it1 == *it2) xy_arc_map_names.push_back(*it1);
  26.687 +      }
  26.688 +    }
  26.689 +  }
  26.690 +}
  26.691 +
  26.692 +FileImportDialog::ImportData::~ImportData()
  26.693 +{
  26.694 +}
  26.695 +
  26.696 +bool FileImportDialog::ImportData::isXYNodeMap(const std::string& name)
  26.697 +{
  26.698 +  if (isNodeMap(name + ":x") && isNodeMap(name + ":y")) return true;
  26.699 +  return false;
  26.700 +}
  26.701 +
  26.702 +bool FileImportDialog::ImportData::isXYArcMap(const std::string& name)
  26.703 +{
  26.704 +  if (isArcMap(name + ":x") && isArcMap(name + ":y")) return true;
  26.705 +  return false;
  26.706 +}
  26.707 +
  26.708 +bool FileImportDialog::ImportData::isNodeMap(const std::string& name)
  26.709 +{
  26.710 +  if (contains(node_map_names, name)) return true;
  26.711 +  return false;
  26.712 +}
  26.713 +
  26.714 +bool FileImportDialog::ImportData::isArcMap(const std::string& name)
  26.715 +{
  26.716 +  if (contains(arc_map_names, name)) return true;
  26.717 +  return false;
  26.718 +}
  26.719 +
  26.720 +bool FileImportDialog::ImportData::contains(const std::vector<std::string>& vec,
  26.721 +    const std::string& str)
  26.722 +{
  26.723 +  for (std::vector<std::string>::const_iterator it = vec.begin();
  26.724 +      it != vec.end(); ++it)
  26.725 +  {
  26.726 +    if (*it == str) return true;
  26.727 +  }
  26.728 +  return false;
  26.729 +}
  26.730 +
  26.731 +void FileImportDialog::onNodeCoordOneMapChanged()
  26.732 +{
  26.733 +  p_data->node_coord_one_map_name = cblueCoordOneMap.get_active_text();
  26.734 +  update_node_tree_view();
  26.735 +}
  26.736 +
  26.737 +void FileImportDialog::onNodeCoordTwoMaps1Changed()
  26.738 +{
  26.739 +  p_data->node_coord_two_maps_1_name = cblueCoordTwoMaps1.get_active_text();
  26.740 +  update_node_tree_view();
  26.741 +}
  26.742 +
  26.743 +void FileImportDialog::onNodeCoordTwoMaps2Changed()
  26.744 +{
  26.745 +  p_data->node_coord_two_maps_2_name = cblueCoordTwoMaps2.get_active_text();
  26.746 +  update_node_tree_view();
  26.747 +}
  26.748 +
  26.749 +void FileImportDialog::onArrowCoordOneMapChanged()
  26.750 +{
  26.751 +  p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text();
  26.752 +  update_arc_tree_view();
  26.753 +}
  26.754 +
  26.755 +void FileImportDialog::onArrowCoordTwoMaps1Changed()
  26.756 +{
  26.757 +  p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text();
  26.758 +  update_arc_tree_view();
  26.759 +}
  26.760 +
  26.761 +void FileImportDialog::onArrowCoordTwoMaps2Changed()
  26.762 +{
  26.763 +  p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text();
  26.764 +  update_arc_tree_view();
  26.765 +}
  26.766 +
  26.767 +void FileImportDialog::onNodeMapNumericToggled(const Glib::ustring& path)
  26.768 +{
  26.769 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
  26.770 +      Gtk::TreeModel::Path(path));
  26.771 +  Gtk::TreeModel::Row row = *iter;
  26.772 +  std::vector<tree_view_record>::iterator it;
  26.773 +  for (it = node_tree_view_records.begin();
  26.774 +      it != node_tree_view_records.end(); ++it)
  26.775 +  {
  26.776 +    if (it->name == row[NodeMapColumns.colName]) break;
  26.777 +  }
  26.778 +  if (row[NodeMapColumns.colReadAsNumeric])
  26.779 +  {
  26.780 +    row[NodeMapColumns.colReadAsString] = false;
  26.781 +    it->string = false;
  26.782 +    it->numeric = true;
  26.783 +  }
  26.784 +}
  26.785 +
  26.786 +void FileImportDialog::onNodeMapStringToggled(const Glib::ustring& path)
  26.787 +{
  26.788 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
  26.789 +      Gtk::TreeModel::Path(path));
  26.790 +  Gtk::TreeModel::Row row = *iter;
  26.791 +  std::vector<tree_view_record>::iterator it;
  26.792 +  for (it = node_tree_view_records.begin();
  26.793 +      it != node_tree_view_records.end(); ++it)
  26.794 +  {
  26.795 +    if (it->name == row[NodeMapColumns.colName]) break;
  26.796 +  }
  26.797 +  if (row[NodeMapColumns.colReadAsString])
  26.798 +  {
  26.799 +    row[NodeMapColumns.colReadAsNumeric] = false;
  26.800 +    it->string = true;
  26.801 +    it->numeric = false;
  26.802 +  }
  26.803 +}
  26.804 +
  26.805 +void FileImportDialog::update_node_tree_view()
  26.806 +{
  26.807 +  for (std::vector<tree_view_record>::iterator it =
  26.808 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
  26.809 +  {
  26.810 +    it->visible = true;
  26.811 +  }
  26.812 +  switch (p_data->node_coord_load_from)
  26.813 +  {
  26.814 +    case ImportData::ONE_MAP:
  26.815 +      for (std::vector<tree_view_record>::iterator it =
  26.816 +          node_tree_view_records.begin(); it !=
  26.817 +          node_tree_view_records.end(); ++it)
  26.818 +      {
  26.819 +        if (it->name == p_data->node_coord_one_map_name)
  26.820 +          it->visible = false;
  26.821 +      }
  26.822 +      break;
  26.823 +    case ImportData::TWO_MAPS:
  26.824 +      for (std::vector<tree_view_record>::iterator it =
  26.825 +          node_tree_view_records.begin(); it !=
  26.826 +          node_tree_view_records.end(); ++it)
  26.827 +      {
  26.828 +        if ((it->name == p_data->node_coord_two_maps_1_name) ||
  26.829 +            (it->name == p_data->node_coord_two_maps_2_name))
  26.830 +          it->visible = false;
  26.831 +      }
  26.832 +      break;
  26.833 +    case ImportData::DONT_READ:
  26.834 +      break;
  26.835 +  }
  26.836 +  refNodeMapStore->clear();
  26.837 +  for (std::vector<tree_view_record>::iterator it =
  26.838 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
  26.839 +  {
  26.840 +    if (it->visible)
  26.841 +    {
  26.842 +      Gtk::TreeModel::Row row = *(refNodeMapStore->append());
  26.843 +      row[NodeMapColumns.colName] = it->name;
  26.844 +      row[NodeMapColumns.colReadAsNumeric] = it->numeric;
  26.845 +      row[NodeMapColumns.colReadAsString] = it->string;
  26.846 +    }
  26.847 +  }
  26.848 +}
  26.849 +
  26.850 +void FileImportDialog::onArcMapNumericToggled(const Glib::ustring& path)
  26.851 +{
  26.852 +  Gtk::TreeModel::iterator iter = refArcMapStore->get_iter(
  26.853 +      Gtk::TreeModel::Path(path));
  26.854 +  Gtk::TreeModel::Row row = *iter;
  26.855 +  std::vector<tree_view_record>::iterator it;
  26.856 +  for (it = arc_tree_view_records.begin();
  26.857 +      it != arc_tree_view_records.end(); ++it)
  26.858 +  {
  26.859 +    if (it->name == row[ArcMapColumns.colName]) break;
  26.860 +  }
  26.861 +  if (row[ArcMapColumns.colReadAsNumeric])
  26.862 +  {
  26.863 +    row[ArcMapColumns.colReadAsString] = false;
  26.864 +    it->string = false;
  26.865 +    it->numeric = true;
  26.866 +  }
  26.867 +}
  26.868 +
  26.869 +void FileImportDialog::onArcMapStringToggled(const Glib::ustring& path)
  26.870 +{
  26.871 +  Gtk::TreeModel::iterator iter = refArcMapStore->get_iter(
  26.872 +      Gtk::TreeModel::Path(path));
  26.873 +  Gtk::TreeModel::Row row = *iter;
  26.874 +  std::vector<tree_view_record>::iterator it;
  26.875 +  for (it = arc_tree_view_records.begin();
  26.876 +      it != arc_tree_view_records.end(); ++it)
  26.877 +  {
  26.878 +    if (it->name == row[ArcMapColumns.colName]) break;
  26.879 +  }
  26.880 +  if (row[ArcMapColumns.colReadAsString])
  26.881 +  {
  26.882 +    row[ArcMapColumns.colReadAsNumeric] = false;
  26.883 +    it->string = true;
  26.884 +    it->numeric = false;
  26.885 +  }
  26.886 +}
  26.887 +
  26.888 +void FileImportDialog::update_arc_tree_view()
  26.889 +{
  26.890 +  for (std::vector<tree_view_record>::iterator it =
  26.891 +      arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it)
  26.892 +  {
  26.893 +    it->visible = true;
  26.894 +  }
  26.895 +  switch (p_data->arrow_coord_load_from)
  26.896 +  {
  26.897 +    case ImportData::ONE_MAP:
  26.898 +      for (std::vector<tree_view_record>::iterator it =
  26.899 +          arc_tree_view_records.begin(); it !=
  26.900 +          arc_tree_view_records.end(); ++it)
  26.901 +      {
  26.902 +        if (it->name == p_data->arrow_coord_one_map_name)
  26.903 +          it->visible = false;
  26.904 +      }
  26.905 +      break;
  26.906 +    case ImportData::TWO_MAPS:
  26.907 +      for (std::vector<tree_view_record>::iterator it =
  26.908 +          arc_tree_view_records.begin(); it !=
  26.909 +          arc_tree_view_records.end(); ++it)
  26.910 +      {
  26.911 +        if ((it->name == p_data->arrow_coord_two_maps_1_name) ||
  26.912 +            (it->name == p_data->arrow_coord_two_maps_2_name))
  26.913 +          it->visible = false;
  26.914 +      }
  26.915 +      break;
  26.916 +    case ImportData::DONT_READ:
  26.917 +      break;
  26.918 +  }
  26.919 +  refArcMapStore->clear();
  26.920 +  for (std::vector<tree_view_record>::iterator it =
  26.921 +      arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it)
  26.922 +  {
  26.923 +    if (it->visible)
  26.924 +    {
  26.925 +      Gtk::TreeModel::Row row = *(refArcMapStore->append());
  26.926 +      row[ArcMapColumns.colName] = it->name;
  26.927 +      row[ArcMapColumns.colReadAsNumeric] = it->numeric;
  26.928 +      row[ArcMapColumns.colReadAsString] = it->string;
  26.929 +    }
  26.930 +  }
  26.931 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/file_import_dialog.h	Mon Jul 07 08:10:39 2008 -0500
    27.3 @@ -0,0 +1,137 @@
    27.4 +#ifndef FILE_IMPORT_DIALOG
    27.5 +#define FILE_IMPORT_DIALOG
    27.6 +
    27.7 +#include <gtkmm/dialog.h>
    27.8 +#include <gtkmm/radiobutton.h>
    27.9 +#include <gtkmm/comboboxtext.h>
   27.10 +#include <gtkmm/sizegroup.h>
   27.11 +#include <gtkmm/treemodel.h>
   27.12 +#include <gtkmm/liststore.h>
   27.13 +#include <gtkmm/treeview.h>
   27.14 +#include <gtkmm/scrolledwindow.h>
   27.15 +
   27.16 +class FileImportDialog : public Gtk::Dialog
   27.17 +{
   27.18 +  public:
   27.19 +    struct ImportData
   27.20 +    {
   27.21 +        ImportData(
   27.22 +            const std::vector<std::string>& _node_map_names,
   27.23 +            const std::vector<std::string>& _arc_map_names);
   27.24 +
   27.25 +        ~ImportData();
   27.26 +
   27.27 +        std::vector<std::string> node_map_names;
   27.28 +        std::vector<std::string> arc_map_names;
   27.29 +
   27.30 +        std::vector<std::string> xy_node_map_names;
   27.31 +        std::vector<std::string> xy_arc_map_names;
   27.32 +
   27.33 +        bool contains(
   27.34 +            const std::vector<std::string>& vec,
   27.35 +            const std::string& str);
   27.36 +
   27.37 +        std::string node_coord_one_map_name;
   27.38 +        std::string node_coord_two_maps_1_name;
   27.39 +        std::string node_coord_two_maps_2_name;
   27.40 +        std::string arrow_coord_one_map_name;
   27.41 +        std::string arrow_coord_two_maps_1_name;
   27.42 +        std::string arrow_coord_two_maps_2_name;
   27.43 +
   27.44 +        enum ReadOpts { ONE_MAP, TWO_MAPS, DONT_READ };
   27.45 +        ReadOpts node_coord_load_from;
   27.46 +        ReadOpts arrow_coord_load_from;
   27.47 +
   27.48 +        bool isXYNodeMap(const std::string& name);
   27.49 +        bool isXYArcMap(const std::string& name);
   27.50 +        bool isNodeMap(const std::string& name);
   27.51 +        bool isArcMap(const std::string& name);
   27.52 +
   27.53 +        std::vector<std::string> numeric_node_map_names;
   27.54 +        std::vector<std::string> string_node_map_names;
   27.55 +        std::vector<std::string> numeric_arc_map_names;
   27.56 +        std::vector<std::string> string_arc_map_names;
   27.57 +    };
   27.58 +
   27.59 +    ImportData* p_data;
   27.60 +
   27.61 +    Gtk::RadioButton rblueCoordNone;
   27.62 +    Gtk::RadioButton rblueCoordOneMap;
   27.63 +    Gtk::RadioButton rblueCoordTwoMaps;
   27.64 +
   27.65 +    Gtk::RadioButton rbArrowCoordNone;
   27.66 +    Gtk::RadioButton rbArrowCoordOneMap;
   27.67 +    Gtk::RadioButton rbArrowCoordTwoMaps;
   27.68 +
   27.69 +    Gtk::ComboBoxText cblueCoordOneMap;
   27.70 +    Gtk::ComboBoxText cblueCoordTwoMaps1;
   27.71 +    Gtk::ComboBoxText cblueCoordTwoMaps2;
   27.72 +
   27.73 +    Gtk::ComboBoxText cbArrowCoordOneMap;
   27.74 +    Gtk::ComboBoxText cbArrowCoordTwoMaps1;
   27.75 +    Gtk::ComboBoxText cbArrowCoordTwoMaps2;
   27.76 +
   27.77 +    void onNodeCoordMapNumToggled();
   27.78 +    void onArrowCoordMapNumToggled();
   27.79 +
   27.80 +    void onResponse(int id);
   27.81 +
   27.82 +    void onNodeCoordOneMapChanged();
   27.83 +    void onNodeCoordTwoMaps1Changed();
   27.84 +    void onNodeCoordTwoMaps2Changed();
   27.85 +
   27.86 +    void onArrowCoordOneMapChanged();
   27.87 +    void onArrowCoordTwoMaps1Changed();
   27.88 +    void onArrowCoordTwoMaps2Changed();
   27.89 +
   27.90 +    struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
   27.91 +    {
   27.92 +      MapModelColumns()
   27.93 +      {
   27.94 +        add(colName);
   27.95 +        add(colReadAsNumeric);
   27.96 +        add(colReadAsString);
   27.97 +      }
   27.98 +      Gtk::TreeModelColumn<Glib::ustring> colName;
   27.99 +      Gtk::TreeModelColumn<bool> colReadAsNumeric;
  27.100 +      Gtk::TreeModelColumn<bool> colReadAsString;
  27.101 +    };
  27.102 +
  27.103 +    Gtk::TreeView twNodeMaps;
  27.104 +    MapModelColumns NodeMapColumns;
  27.105 +    Glib::RefPtr<Gtk::ListStore> refNodeMapStore;
  27.106 +    void onNodeMapNumericToggled(const Glib::ustring& path);
  27.107 +    void onNodeMapStringToggled(const Glib::ustring& path);
  27.108 +
  27.109 +    Gtk::TreeView twArcMaps;
  27.110 +    MapModelColumns ArcMapColumns;
  27.111 +    Glib::RefPtr<Gtk::ListStore> refArcMapStore;
  27.112 +    void onArcMapNumericToggled(const Glib::ustring& path);
  27.113 +    void onArcMapStringToggled(const Glib::ustring& path);
  27.114 +
  27.115 +    struct tree_view_record
  27.116 +    {
  27.117 +      tree_view_record(const std::string& _name, bool _numeric, bool _string,
  27.118 +          bool _visible) :
  27.119 +        name(_name),
  27.120 +        numeric(_numeric),
  27.121 +        string(_string),
  27.122 +        visible(_visible) {}
  27.123 +      std::string name;
  27.124 +      bool numeric;
  27.125 +      bool string;
  27.126 +      bool visible;
  27.127 +    };
  27.128 +
  27.129 +    std::vector<tree_view_record> node_tree_view_records;
  27.130 +    void update_node_tree_view();
  27.131 +
  27.132 +    std::vector<tree_view_record> arc_tree_view_records;
  27.133 +    void update_arc_tree_view();
  27.134 +
  27.135 +  public:
  27.136 +    FileImportDialog(ImportData* d);
  27.137 +    ~FileImportDialog();
  27.138 +};
  27.139 +
  27.140 +#endif
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/gdc-broken_edge.cc	Mon Jul 07 08:10:39 2008 -0500
    28.3 @@ -0,0 +1,260 @@
    28.4 +/* -*- C++ -*-
    28.5 + *
    28.6 + * This file is a part of LEMON, a generic C++ optimization library
    28.7 + *
    28.8 + * Copyright (C) 2003-2006
    28.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   28.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   28.11 + *
   28.12 + * Permission to use, modify and distribute this software is granted
   28.13 + * provided that this copyright notice appears in all copies. For
   28.14 + * precise terms see the accompanying LICENSE file.
   28.15 + *
   28.16 + * This software is provided "AS IS" with no warranty of any kind,
   28.17 + * express or implied, and with no claim as to its suitability for any
   28.18 + * purpose.
   28.19 + *
   28.20 + */
   28.21 +
   28.22 +#include <graph_displayer_canvas.h>
   28.23 +#include <mapstorage.h>
   28.24 +#include <nbtab.h>
   28.25 +#include <cmath>
   28.26 +
   28.27 +DigraphDisplayerCanvas::ArcBase::ArcBase(Gnome::Canvas::Group& _group, Arc _arc, DigraphDisplayerCanvas& _canvas) : 
   28.28 +  Gnome::Canvas::Group(_group), arc(_arc), canvas(_canvas), arrow(*this)
   28.29 +{
   28.30 +  arrow.property_fill_color().set_value("red");
   28.31 +  arrow.lower_to_bottom();
   28.32 +  lower_to_bottom();
   28.33 +}
   28.34 +
   28.35 +DigraphDisplayerCanvas::ArcBase::~ArcBase()
   28.36 +{
   28.37 +}
   28.38 +
   28.39 +void DigraphDisplayerCanvas::ArcBase::drawArrow(XY unit_vector_in_dir)
   28.40 +{
   28.41 +  MapStorage& ms = *canvas.mytab.mapstorage;
   28.42 +  XY center(ms.getArrowCoords(arc));
   28.43 +  XY unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
   28.44 +
   28.45 +  //       /\       // top
   28.46 +  //      /  \      //
   28.47 +  //      -  -      // c(enter)l(eft), ccl, ccr, cr
   28.48 +  //       ||       //
   28.49 +  //       ||       // b(ottom)l, br
   28.50 +
   28.51 +  double size=3;
   28.52 +
   28.53 +  XY bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
   28.54 +  XY br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
   28.55 +  XY ccl(center + unit_vector_in_dir *  size + unit_norm_vector * size );
   28.56 +  XY ccr(center + unit_vector_in_dir *  size - unit_norm_vector * size );
   28.57 +  XY cl (center + unit_vector_in_dir *  size + unit_norm_vector * 2 * size );
   28.58 +  XY cr (center + unit_vector_in_dir *  size - unit_norm_vector * 2 * size );
   28.59 +  XY top(center + unit_vector_in_dir * 3 * size);
   28.60 +
   28.61 +  Gnome::Canvas::Points arrow_points;
   28.62 +  arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y  ) );
   28.63 +  arrow_points.push_back(Gnome::Art::Point( br.x , br.y  ) );
   28.64 +  arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
   28.65 +  arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y  ) );
   28.66 +  arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
   28.67 +  arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y  ) );
   28.68 +  arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
   28.69 +
   28.70 +  arrow.property_points().set_value(arrow_points);
   28.71 +}
   28.72 +
   28.73 +DigraphDisplayerCanvas::BrokenArc::BrokenArc(Gnome::Canvas::Group & g,
   28.74 +    Arc _arc, DigraphDisplayerCanvas & gc) : ArcBase(g, _arc, gc),
   28.75 +  isbutton(false), line(*this)
   28.76 +{
   28.77 +  arrow.signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::BrokenArc::arcFormerEventHandler));
   28.78 +
   28.79 +  line.property_fill_color().set_value("green");
   28.80 +  line.property_width_units().set_value(10);    
   28.81 +  line.lower_to_bottom();
   28.82 +
   28.83 +  draw();
   28.84 +}
   28.85 +
   28.86 +DigraphDisplayerCanvas::BrokenArc::~BrokenArc()
   28.87 +{
   28.88 +}
   28.89 +
   28.90 +void DigraphDisplayerCanvas::BrokenArc::draw()
   28.91 +{
   28.92 +  MapStorage& ms = *canvas.mytab.mapstorage;
   28.93 +
   28.94 +  //calculating coordinates of the direction indicator arrow
   28.95 +  XY head(ms.getNodeCoords(ms.digraph.target(arc)));
   28.96 +  XY center(ms.getArrowCoords(arc));
   28.97 +
   28.98 +  XY unit_vector_in_dir(head-center);
   28.99 +  double length=sqrt( unit_vector_in_dir.normSquare() );
  28.100 +
  28.101 +  if(length!=0)
  28.102 +    {
  28.103 +      unit_vector_in_dir/=length;
  28.104 +    }
  28.105 +
  28.106 +  // update the arrow
  28.107 +  drawArrow(unit_vector_in_dir);
  28.108 +
  28.109 +  // update the arc
  28.110 +  Gnome::Canvas::Points points;
  28.111 +  Node source = ms.digraph.source(arc);
  28.112 +  Node target = ms.digraph.target(arc);
  28.113 +  points.push_back(Gnome::Art::Point(ms.getNodeCoords(source).x,
  28.114 +        ms.getNodeCoords(source).y));
  28.115 +  points.push_back(Gnome::Art::Point(ms.getArrowCoords(arc).x,
  28.116 +        ms.getArrowCoords(arc).y));
  28.117 +  points.push_back(Gnome::Art::Point(ms.getNodeCoords(target).x,
  28.118 +        ms.getNodeCoords(target).y));
  28.119 +  line.property_points().set_value(points);
  28.120 +}
  28.121 +
  28.122 +bool DigraphDisplayerCanvas::BrokenArc::arcFormerEventHandler(GdkEvent* e)
  28.123 +{
  28.124 +  switch(e->type)
  28.125 +  {
  28.126 +    case GDK_BUTTON_PRESS:
  28.127 +      //we mark the location of the event to be able to calculate parameters
  28.128 +      //of dragging
  28.129 +      if(canvas.getActualTool()!=CREATE_NODE)
  28.130 +      {
  28.131 +        canvas.toggleArcActivity(this, true);
  28.132 +        clicked_x=e->button.x;
  28.133 +        clicked_y=e->button.y;
  28.134 +        isbutton=true;
  28.135 +      }
  28.136 +      break;
  28.137 +    case GDK_BUTTON_RELEASE:
  28.138 +      if(canvas.getActualTool()!=CREATE_NODE)
  28.139 +      {
  28.140 +        canvas.toggleArcActivity(this, false);
  28.141 +        isbutton=false;
  28.142 +      }
  28.143 +      break;
  28.144 +    case GDK_MOTION_NOTIFY:
  28.145 +      //we only have to do sg. if the mouse button is pressed
  28.146 +      if(isbutton)
  28.147 +      {
  28.148 +        //new coordinates will be the old values,
  28.149 +        //because the item will be moved to the
  28.150 +        //new coordinate therefore the new movement
  28.151 +        //has to be calculated from here
  28.152 +
  28.153 +        double dx=e->motion.x-clicked_x;
  28.154 +        double dy=e->motion.y-clicked_y;
  28.155 +
  28.156 +        Gnome::Canvas::Points points_new;
  28.157 +
  28.158 +        canvas.mytab.mapstorage->setArrowCoords(arc, canvas.mytab.mapstorage->getArrowCoords(arc) + XY(dx, dy));
  28.159 +
  28.160 +        draw();
  28.161 +        canvas.textReposition(canvas.mytab.mapstorage->getArrowCoords(arc));
  28.162 +
  28.163 +        clicked_x=e->motion.x;
  28.164 +        clicked_y=e->motion.y;
  28.165 +
  28.166 +      }
  28.167 +    default: break;
  28.168 +  }
  28.169 +
  28.170 +  return true;
  28.171 +}
  28.172 +
  28.173 +void DigraphDisplayerCanvas::BrokenArc::setLineWidth(int w)
  28.174 +{
  28.175 +  line.property_width_units().set_value(w);
  28.176 +}
  28.177 +
  28.178 +void DigraphDisplayerCanvas::BrokenArc::setFillColor(Gdk::Color c)
  28.179 +{
  28.180 +  line.property_fill_color_gdk().set_value(c);
  28.181 +}
  28.182 +
  28.183 +DigraphDisplayerCanvas::LoopArc::LoopArc(Gnome::Canvas::Group& _group,
  28.184 +    Arc _arc, DigraphDisplayerCanvas& _canvas) :
  28.185 +  ArcBase(_group, _arc, _canvas), line(*this), isbutton(false)
  28.186 +{
  28.187 +  arrow.signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::LoopArc::arcFormerEventHandler));
  28.188 +
  28.189 +  line.property_outline_color().set_value("green");
  28.190 +  line.property_width_units().set_value(10);
  28.191 +  line.lower_to_bottom();
  28.192 +
  28.193 +  draw();
  28.194 +}
  28.195 +
  28.196 +DigraphDisplayerCanvas::LoopArc::~LoopArc()
  28.197 +{
  28.198 +}
  28.199 +
  28.200 +void DigraphDisplayerCanvas::LoopArc::draw()
  28.201 +{
  28.202 +  MapStorage& ms = *canvas.mytab.mapstorage;
  28.203 +
  28.204 +  Node node = ms.digraph.source(arc);
  28.205 +  XY center = (ms.getNodeCoords(node) + ms.getArrowCoords(arc)) / 2.0;
  28.206 +
  28.207 +  XY unit_vector_in_dir(rot90(center - ms.getArrowCoords(arc)));
  28.208 +  double length = sqrt(unit_vector_in_dir.normSquare());
  28.209 +  unit_vector_in_dir /= length;
  28.210 +
  28.211 +  drawArrow(unit_vector_in_dir);
  28.212 +
  28.213 +  double radius =
  28.214 +    sqrt((ms.getArrowCoords(arc) - ms.getNodeCoords(node)).normSquare()) / 2.0;
  28.215 +
  28.216 +  XY p1 = center + XY(-radius,  radius);
  28.217 +  XY p2 = center + XY( radius, -radius);
  28.218 +  line.property_x1().set_value(p1.x);
  28.219 +  line.property_y1().set_value(p1.y);
  28.220 +  line.property_x2().set_value(p2.x);
  28.221 +  line.property_y2().set_value(p2.y);
  28.222 +}
  28.223 +
  28.224 +void DigraphDisplayerCanvas::LoopArc::setLineWidth(int w)
  28.225 +{
  28.226 +  line.property_width_units().set_value(w);
  28.227 +}
  28.228 +
  28.229 +void DigraphDisplayerCanvas::LoopArc::setFillColor(Gdk::Color c)
  28.230 +{
  28.231 +  line.property_outline_color_gdk().set_value(c);
  28.232 +}
  28.233 +
  28.234 +bool DigraphDisplayerCanvas::LoopArc::arcFormerEventHandler(GdkEvent* e)
  28.235 +{
  28.236 +  switch(e->type)
  28.237 +  {
  28.238 +    case GDK_BUTTON_PRESS:
  28.239 +      if(canvas.getActualTool()!=CREATE_NODE)
  28.240 +      {
  28.241 +        canvas.toggleArcActivity(this, true);
  28.242 +        isbutton=true;
  28.243 +      }
  28.244 +      break;
  28.245 +    case GDK_BUTTON_RELEASE:
  28.246 +      if(canvas.getActualTool()!=CREATE_NODE)
  28.247 +      {
  28.248 +        canvas.toggleArcActivity(this, false);
  28.249 +        isbutton=false;
  28.250 +      }
  28.251 +      break;
  28.252 +    case GDK_MOTION_NOTIFY:
  28.253 +      if(isbutton)
  28.254 +      {
  28.255 +        canvas.mytab.mapstorage->setArrowCoords(arc, XY(e->motion.x, e->motion.y));
  28.256 +
  28.257 +        draw();
  28.258 +        canvas.textReposition(canvas.mytab.mapstorage->getArrowCoords(arc));
  28.259 +      }
  28.260 +    default: break;
  28.261 +  }
  28.262 +  return true;
  28.263 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/gettext.h	Mon Jul 07 08:10:39 2008 -0500
    29.3 @@ -0,0 +1,79 @@
    29.4 +/* Convenience header for conditional use of GNU <libintl.h>.
    29.5 +   Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc.
    29.6 +
    29.7 +   This program is free software; you can redistribute it and/or modify it
    29.8 +   under the terms of the GNU Library General Public License as published
    29.9 +   by the Free Software Foundation; either version 2, or (at your option)
   29.10 +   any later version.
   29.11 +
   29.12 +   This program is distributed in the hope that it will be useful,
   29.13 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.14 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.15 +   Library General Public License for more details.
   29.16 +
   29.17 +   You should have received a copy of the GNU Library General Public
   29.18 +   License along with this program; if not, write to the Free Software
   29.19 +   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
   29.20 +   USA.  */
   29.21 +
   29.22 +#ifndef _LIBGETTEXT_H
   29.23 +#define _LIBGETTEXT_H 1
   29.24 +
   29.25 +/* NLS can be disabled through the configure --disable-nls option.  */
   29.26 +#if ENABLE_NLS
   29.27 +
   29.28 +/* Get declarations of GNU message catalog functions.  */
   29.29 +# include <libintl.h>
   29.30 +
   29.31 +#else
   29.32 +
   29.33 +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
   29.34 +   chokes if dcgettext is defined as a macro.  So include it now, to make
   29.35 +   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
   29.36 +   as well because people using "gettext.h" will not include <libintl.h>,
   29.37 +   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
   29.38 +   is OK.  */
   29.39 +#if defined(__sun)
   29.40 +# include <locale.h>
   29.41 +#endif
   29.42 +
   29.43 +/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
   29.44 +   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
   29.45 +   it now, to make later inclusions of <libintl.h> a NOP.  */
   29.46 +#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
   29.47 +# include <cstdlib>
   29.48 +# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
   29.49 +#  include <libintl.h>
   29.50 +# endif
   29.51 +#endif
   29.52 +
   29.53 +/* Disabled NLS.
   29.54 +   The casts to 'const char *' serve the purpose of producing warnings
   29.55 +   for invalid uses of the value returned from these functions.
   29.56 +   On pre-ANSI systems without 'const', the config.h file is supposed to
   29.57 +   contain "#define const".  */
   29.58 +# define gettext(Msgid) ((const char *) (Msgid))
   29.59 +# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
   29.60 +# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
   29.61 +# define ngettext(Msgid1, Msgid2, N) \
   29.62 +    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
   29.63 +# define dngettext(Domainname, Msgid1, Msgid2, N) \
   29.64 +    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
   29.65 +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
   29.66 +    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
   29.67 +# define textdomain(Domainname) ((const char *) (Domainname))
   29.68 +# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
   29.69 +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
   29.70 +
   29.71 +#endif
   29.72 +
   29.73 +/* A pseudo function call that serves as a marker for the automated
   29.74 +   extraction of messages, but does not call gettext().  The run-time
   29.75 +   translation is done at a different place in the code.
   29.76 +   The argument, String, should be a literal string.  Concatenated strings
   29.77 +   and other string expressions won't work.
   29.78 +   The macro's expansion is not parenthesized, so that it is suitable as
   29.79 +   initializer for static 'char[]' or 'const char[]' variables.  */
   29.80 +#define gettext_noop(String) String
   29.81 +
   29.82 +#endif /* _LIBGETTEXT_H */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/glemon.spec.in	Mon Jul 07 08:10:39 2008 -0500
    30.3 @@ -0,0 +1,42 @@
    30.4 +Summary: A graph editor for the LEMON Graph Format
    30.5 +Name: @PACKAGE_TARNAME@
    30.6 +Version: @PACKAGE_VERSION@
    30.7 +Release: 1
    30.8 +License: Boost
    30.9 +URL: http://lemon.cs.elte.hu
   30.10 +Source0: %{name}-%{version}.tar.gz
   30.11 +Group: Development/Libraries
   30.12 +BuildRoot: %{_tmppath}/%{name}-root
   30.13 +Requires: lemon
   30.14 +Requires: gtkmm24 >= 2.6
   30.15 +Requires: libgnomecanvasmm >= 2.6.0
   30.16 +BuildRequires: lemon-devel
   30.17 +BuildRequires: gtkmm24-devel >= 2.6
   30.18 +BuildRequires: libgnomecanvasmm-devel >= 2.6.0
   30.19 +
   30.20 +%description
   30.21 +glemon is a graphical editor for the LEMON Graph Format (.lgf)
   30.22 +
   30.23 +%prep
   30.24 +%setup -q
   30.25 +
   30.26 +%build
   30.27 +%configure
   30.28 +make
   30.29 +
   30.30 +%install
   30.31 +rm -rf $RPM_BUILD_ROOT
   30.32 +make DESTDIR=$RPM_BUILD_ROOT install
   30.33 +
   30.34 +%clean
   30.35 +rm -rf $RPM_BUILD_ROOT
   30.36 +
   30.37 +%post -p /sbin/ldconfig
   30.38 +
   30.39 +%postun -p /sbin/ldconfig
   30.40 +
   30.41 +%files
   30.42 +%defattr(-,root,root)
   30.43 +%{_bindir}/glemon
   30.44 +%{_datadir}/locale
   30.45 +%doc AUTHORS COPYING LICENSE NEWS README
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/graph-displayer.cc	Mon Jul 07 08:10:39 2008 -0500
    31.3 @@ -0,0 +1,115 @@
    31.4 +/* -*- C++ -*-
    31.5 + *
    31.6 + * This file is a part of LEMON, a generic C++ optimization library
    31.7 + *
    31.8 + * Copyright (C) 2003-2006
    31.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   31.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   31.11 + *
   31.12 + * Permission to use, modify and distribute this software is granted
   31.13 + * provided that this copyright notice appears in all copies. For
   31.14 + * precise terms see the accompanying LICENSE file.
   31.15 + *
   31.16 + * This software is provided "AS IS" with no warranty of any kind,
   31.17 + * express or implied, and with no claim as to its suitability for any
   31.18 + * purpose.
   31.19 + *
   31.20 + */
   31.21 +
   31.22 +#ifdef HAVE_CONFIG_H
   31.23 +#include <config.h>
   31.24 +#endif
   31.25 +
   31.26 +#include "all_include.h"
   31.27 +#include "main_win.h"
   31.28 +#include <libgnomecanvasmm.h>
   31.29 +#include <libgnomecanvasmm/polygon.h>
   31.30 +
   31.31 +#include <locale.h>
   31.32 +
   31.33 +#define MAIN_PART
   31.34 +
   31.35 +std::vector <std::string> arc_property_strings;
   31.36 +std::vector <double> arc_property_defaults;
   31.37 +std::vector <std::string> node_property_strings;
   31.38 +std::vector <double> node_property_defaults;
   31.39 +int longest_property_string_length;
   31.40 +
   31.41 +int main(int argc, char *argv[])
   31.42 +{
   31.43 +  setlocale(LC_ALL, "");
   31.44 +  bindtextdomain(PACKAGE, LOCALEDIR);
   31.45 +  bind_textdomain_codeset(PACKAGE, "UTF-8");
   31.46 +  textdomain(PACKAGE);
   31.47 +
   31.48 +  //initializing
   31.49 +
   31.50 +  arc_property_strings.resize(EDGE_PROPERTY_NUM);
   31.51 +  arc_property_strings[E_WIDTH]="Arc Width";
   31.52 +  arc_property_strings[E_COLOR]="Arc Color";
   31.53 +  arc_property_strings[E_TEXT]="Arc Text";
   31.54 +
   31.55 +  arc_property_defaults.resize(EDGE_PROPERTY_NUM);
   31.56 +  arc_property_defaults[E_WIDTH]=10.0;
   31.57 +  arc_property_defaults[E_COLOR]=100;
   31.58 +  arc_property_defaults[E_TEXT]=0;
   31.59 +
   31.60 +  node_property_strings.resize(NODE_PROPERTY_NUM);
   31.61 +  node_property_strings[N_RADIUS]="Node Radius";
   31.62 +  node_property_strings[N_COLOR]="Node Color";
   31.63 +  node_property_strings[N_TEXT]="Node Text";
   31.64 +
   31.65 +  node_property_defaults.resize(NODE_PROPERTY_NUM);
   31.66 +  node_property_defaults[N_RADIUS]=20.0;
   31.67 +  node_property_defaults[N_COLOR]=100;
   31.68 +  node_property_defaults[N_TEXT]=0;
   31.69 +
   31.70 +  longest_property_string_length=0;
   31.71 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   31.72 +    {
   31.73 +      int j=arc_property_strings[i].size();
   31.74 +      if(j>longest_property_string_length)
   31.75 +	{
   31.76 +	  longest_property_string_length=j;
   31.77 +	}
   31.78 +    }
   31.79 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
   31.80 +    {
   31.81 +      int j=node_property_strings[i].size();
   31.82 +      if(j>longest_property_string_length)
   31.83 +	{
   31.84 +	  longest_property_string_length=j;
   31.85 +	}
   31.86 +    }
   31.87 +
   31.88 +
   31.89 +  //initializing GUI
   31.90 +
   31.91 +  Gnome::Canvas::init();
   31.92 +  Gtk::Main app(argc, argv);
   31.93 +
   31.94 +  MainWin mytab;
   31.95 +
   31.96 +//   if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR)))
   31.97 +//     {
   31.98 +//       mytab.readFile(argv[1]);
   31.99 +//     }
  31.100 +  if(argc>=2)
  31.101 +  {
  31.102 +    for(int i=1;i<argc;i++)
  31.103 +    {
  31.104 +      if(Glib::file_test(argv[i], Glib::FILE_TEST_IS_REGULAR))
  31.105 +      {
  31.106 +        mytab.readFile(argv[i]);
  31.107 +      }
  31.108 +    }
  31.109 +  }
  31.110 +  else
  31.111 +    {
  31.112 +      mytab.newTab();
  31.113 +    }
  31.114 +  
  31.115 +  app.run(mytab);
  31.116 +
  31.117 +  return 0;
  31.118 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/graph_displayer_canvas-edge.cc	Mon Jul 07 08:10:39 2008 -0500
    32.3 @@ -0,0 +1,302 @@
    32.4 +/* -*- C++ -*-
    32.5 + *
    32.6 + * This file is a part of LEMON, a generic C++ optimization library
    32.7 + *
    32.8 + * Copyright (C) 2003-2006
    32.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   32.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   32.11 + *
   32.12 + * Permission to use, modify and distribute this software is granted
   32.13 + * provided that this copyright notice appears in all copies. For
   32.14 + * precise terms see the accompanying LICENSE file.
   32.15 + *
   32.16 + * This software is provided "AS IS" with no warranty of any kind,
   32.17 + * express or implied, and with no claim as to its suitability for any
   32.18 + * purpose.
   32.19 + *
   32.20 + */
   32.21 +
   32.22 +#include <graph_displayer_canvas.h>
   32.23 +#include <mapstorage.h>
   32.24 +#include <nbtab.h>
   32.25 +#include <cmath>
   32.26 +
   32.27 +const int minimum_arc_width=0;
   32.28 +
   32.29 +int DigraphDisplayerCanvas::resetArcWidth (Arc arc)
   32.30 +{
   32.31 +  MapStorage& ms = *mytab.mapstorage;
   32.32 +  double min, max;
   32.33 +
   32.34 +  min=arc_property_defaults[E_WIDTH];
   32.35 +  max=arc_property_defaults[E_WIDTH];
   32.36 +  Digraph::ArcMap<double> actual_map(ms.digraph,arc_property_defaults[E_WIDTH]);
   32.37 +
   32.38 +  if(arc==INVALID)
   32.39 +  {
   32.40 +    for (ArcIt i(ms.digraph); i!=INVALID; ++i)
   32.41 +    {
   32.42 +      double v=fabs(actual_map[i]);
   32.43 +      int w;
   32.44 +      if(min==max)
   32.45 +      {
   32.46 +        w=(int)(arc_property_defaults[E_WIDTH]);
   32.47 +      }
   32.48 +      else
   32.49 +      {
   32.50 +        w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
   32.51 +      }
   32.52 +      if(zoomtrack)
   32.53 +      {
   32.54 +        double actual_ppu=get_pixels_per_unit();
   32.55 +        w=(int)(w/actual_ppu*fixed_zoom_factor);
   32.56 +      }
   32.57 +      arcsmap[i]->setLineWidth(w);
   32.58 +    }
   32.59 +  }
   32.60 +  else
   32.61 +  {
   32.62 +    int w=(int)actual_map[arc];
   32.63 +    if(w>=0)
   32.64 +    {
   32.65 +      arcsmap[arc]->setLineWidth(w);
   32.66 +    }
   32.67 +  }
   32.68 +  return 0;
   32.69 +}
   32.70 +
   32.71 +
   32.72 +int DigraphDisplayerCanvas::changeArcWidth (std::string mapname, Arc arc)
   32.73 +{
   32.74 +  MapStorage& ms = *mytab.mapstorage;
   32.75 +  double min, max;
   32.76 +
   32.77 +  {
   32.78 +    ArcIt e(ms.digraph);
   32.79 +    min = max = ms.get(mapname, e);
   32.80 +    for (; e != INVALID; ++e)
   32.81 +    {
   32.82 +      if (static_cast<double>(ms.get(mapname, e)) > max)
   32.83 +        max = ms.get(mapname, e);
   32.84 +      if (static_cast<double>(ms.get(mapname, e)) < min)
   32.85 +        min = ms.get(mapname, e);
   32.86 +    }
   32.87 +  }
   32.88 +
   32.89 +  if(arc==INVALID)
   32.90 +  {
   32.91 +    for (ArcIt i(ms.digraph); i!=INVALID; ++i)
   32.92 +    {
   32.93 +      double v=ms.get(mapname, i);
   32.94 +      int w;
   32.95 +      if(autoscale)
   32.96 +      {
   32.97 +        if(min==max)
   32.98 +        {
   32.99 +          w=(int)(arc_property_defaults[E_WIDTH]);
  32.100 +        }
  32.101 +        else
  32.102 +        {
  32.103 +          w=(int)(minimum_arc_width+(v-min)/(max-min)*(arc_width-minimum_arc_width));
  32.104 +        }
  32.105 +      }
  32.106 +      else
  32.107 +      {
  32.108 +        w=(int)(v*arc_width);
  32.109 +      }
  32.110 +      if(w<0)
  32.111 +      {
  32.112 +        arcsmap[i]->hide();
  32.113 +      }
  32.114 +      else
  32.115 +      {
  32.116 +        arcsmap[i]->show();
  32.117 +        if(w<minimum_arc_width)
  32.118 +        {
  32.119 +          w=minimum_arc_width;
  32.120 +        }
  32.121 +        if(zoomtrack)
  32.122 +        {
  32.123 +          double actual_ppu=get_pixels_per_unit();
  32.124 +          w=(int)(w/actual_ppu*fixed_zoom_factor);
  32.125 +        }
  32.126 +        arcsmap[i]->setLineWidth(w);
  32.127 +      }
  32.128 +    }
  32.129 +  }
  32.130 +  else
  32.131 +  {
  32.132 +    int w=(int)ms.get(mapname, arc);
  32.133 +    if(w>=0)
  32.134 +    {
  32.135 +      arcsmap[arc]->setLineWidth(w);
  32.136 +    }
  32.137 +  }
  32.138 +  return 0;
  32.139 +};
  32.140 +
  32.141 +int DigraphDisplayerCanvas::changeArcColor (std::string mapname, Arc arc)
  32.142 +{  
  32.143 +  MapStorage& ms = *mytab.mapstorage;
  32.144 +
  32.145 +  //function maps the range of the maximum and
  32.146 +  //the minimum of the nodemap to the range of
  32.147 +  //green in RGB
  32.148 +
  32.149 +  double max, min;
  32.150 +
  32.151 +  {
  32.152 +    ArcIt e(ms.digraph);
  32.153 +    min = max = ms.get(mapname, e);
  32.154 +    for (; e != INVALID; ++e)
  32.155 +    {
  32.156 +      if (static_cast<double>(ms.get(mapname, e)) > max)
  32.157 +        max = ms.get(mapname, e);
  32.158 +      if (static_cast<double>(ms.get(mapname, e)) < min)
  32.159 +        min = ms.get(mapname, e);
  32.160 +    }
  32.161 +  }
  32.162 +
  32.163 +  if(arc==INVALID)
  32.164 +    {
  32.165 +      for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  32.166 +	{
  32.167 +	  double w=ms.get(mapname, i);
  32.168 +
  32.169 +	  Gdk::Color color;
  32.170 +	  if(max!=min)
  32.171 +	    {
  32.172 +	      color=rainbowColorCounter(min, max, w);
  32.173 +	    }
  32.174 +	  else
  32.175 +	    {
  32.176 +	      color.set_rgb_p (0, 1, 0);
  32.177 +	    }
  32.178 +	  arcsmap[i]->setFillColor(color);
  32.179 +	}
  32.180 +    }
  32.181 +  else
  32.182 +    {
  32.183 +      Gdk::Color color;
  32.184 +
  32.185 +      double w=ms.get(mapname, arc);
  32.186 +
  32.187 +      if(max!=min)
  32.188 +	{
  32.189 +	  color=rainbowColorCounter(min, max, w);
  32.190 +	}
  32.191 +      else
  32.192 +	{
  32.193 +	  color.set_rgb_p (0, 1, 0);
  32.194 +	}
  32.195 +
  32.196 +      arcsmap[arc]->setFillColor(color);
  32.197 +    }
  32.198 +  return 0;
  32.199 +};
  32.200 +
  32.201 +int DigraphDisplayerCanvas::resetArcColor (Arc arc)
  32.202 +{  
  32.203 +  MapStorage& ms = *mytab.mapstorage;
  32.204 +
  32.205 +  //function maps the range of the maximum and
  32.206 +  //the minimum of the nodemap to the range of
  32.207 +  //green in RGB
  32.208 +  Digraph::ArcMap<double> actual_map(ms.digraph,arc_property_defaults[E_COLOR]);
  32.209 +
  32.210 +  double max, min;
  32.211 +
  32.212 +  max=arc_property_defaults[E_COLOR];
  32.213 +  min=arc_property_defaults[E_COLOR];
  32.214 +
  32.215 +  if(arc==INVALID)
  32.216 +  {
  32.217 +    for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  32.218 +    {
  32.219 +      double w=actual_map[i];
  32.220 +
  32.221 +      Gdk::Color color;
  32.222 +      if(max!=min)
  32.223 +      {
  32.224 +        color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  32.225 +      }
  32.226 +      else
  32.227 +      {
  32.228 +        color.set_rgb_p (0, 100, 0);
  32.229 +      }
  32.230 +      arcsmap[i]->setFillColor(color);
  32.231 +    }
  32.232 +  }
  32.233 +  else
  32.234 +  {
  32.235 +    Gdk::Color color;
  32.236 +
  32.237 +    double w=actual_map[arc];
  32.238 +
  32.239 +    if(max!=min)
  32.240 +    {
  32.241 +      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  32.242 +    }
  32.243 +    else
  32.244 +    {
  32.245 +      color.set_rgb_p (0, 100, 0);
  32.246 +    }
  32.247 +
  32.248 +    arcsmap[arc]->setFillColor(color);
  32.249 +  }
  32.250 +  return 0;
  32.251 +};
  32.252 +
  32.253 +int DigraphDisplayerCanvas::changeArcText (std::string mapname, Arc arc)
  32.254 +{
  32.255 +  MapStorage& ms = *mytab.mapstorage;
  32.256 +
  32.257 +  //the number in the map will be written on the arc
  32.258 +  //EXCEPT when the name of the map is Default, because
  32.259 +  //in that case empty string will be written, because
  32.260 +  //that is the deleter map
  32.261 +
  32.262 +  if(arc==INVALID)
  32.263 +  {
  32.264 +    for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  32.265 +    {
  32.266 +      arcmap_to_edit=mapname;
  32.267 +
  32.268 +      arctextmap[i]->property_text().set_value(
  32.269 +          static_cast<std::string>(ms.get(mapname, i)));
  32.270 +    }
  32.271 +
  32.272 +  }
  32.273 +  else
  32.274 +  {
  32.275 +    arctextmap[arc]->property_text().set_value(
  32.276 +        static_cast<std::string>(ms.get(mapname, arc)));
  32.277 +  }
  32.278 +
  32.279 +  return 0;
  32.280 +};
  32.281 +
  32.282 +int DigraphDisplayerCanvas::resetArcText (Arc arc)
  32.283 +{
  32.284 +  MapStorage& ms = *mytab.mapstorage;
  32.285 +
  32.286 +  //the number in the map will be written on the arc
  32.287 +  //EXCEPT when the name of the map is Default, because
  32.288 +  //in that case empty string will be written, because
  32.289 +  //that is the deleter map
  32.290 +
  32.291 +  if(arc==INVALID)
  32.292 +  {
  32.293 +    for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  32.294 +    {
  32.295 +      arcmap_to_edit="";
  32.296 +      arctextmap[i]->property_text().set_value("");
  32.297 +    }
  32.298 +  }
  32.299 +  else
  32.300 +  {
  32.301 +    arctextmap[arc]->property_text().set_value("");
  32.302 +  }
  32.303 +
  32.304 +  return 0;
  32.305 +};
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/graph_displayer_canvas-event.cc	Mon Jul 07 08:10:39 2008 -0500
    33.3 @@ -0,0 +1,967 @@
    33.4 +/* -*- C++ -*-
    33.5 + *
    33.6 + * This file is a part of LEMON, a generic C++ optimization library
    33.7 + *
    33.8 + * Copyright (C) 2003-2006
    33.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   33.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   33.11 + *
   33.12 + * Permission to use, modify and distribute this software is granted
   33.13 + * provided that this copyright notice appears in all copies. For
   33.14 + * precise terms see the accompanying LICENSE file.
   33.15 + *
   33.16 + * This software is provided "AS IS" with no warranty of any kind,
   33.17 + * express or implied, and with no claim as to its suitability for any
   33.18 + * purpose.
   33.19 + *
   33.20 + */
   33.21 +
   33.22 +#include <graph_displayer_canvas.h>
   33.23 +#include <mapstorage.h>
   33.24 +#include <nbtab.h>
   33.25 +#include <cmath>
   33.26 +#include <set>
   33.27 +
   33.28 +bool DigraphDisplayerCanvas::on_expose_event(GdkEventExpose *event)
   33.29 +{
   33.30 +  Gnome::Canvas::CanvasAA::on_expose_event(event);
   33.31 +  //usleep(10000);
   33.32 +  //rezoom();
   33.33 +  return true;
   33.34 +}
   33.35 +
   33.36 +void DigraphDisplayerCanvas::changeEditorialTool(int newtool)
   33.37 +{
   33.38 +  if(actual_tool!=newtool)
   33.39 +  {
   33.40 +
   33.41 +    actual_handler.disconnect();
   33.42 +
   33.43 +    switch(actual_tool)
   33.44 +    {
   33.45 +      case CREATE_EDGE:
   33.46 +        {
   33.47 +          GdkEvent * generated=new GdkEvent();
   33.48 +          generated->type=GDK_BUTTON_RELEASE;
   33.49 +          generated->button.button=3;
   33.50 +          createArcEventHandler(generated);      
   33.51 +          break;
   33.52 +        }
   33.53 +      case MAP_EDIT:
   33.54 +        {
   33.55 +          break;
   33.56 +        }
   33.57 +      default:
   33.58 +        break;
   33.59 +    }
   33.60 +
   33.61 +    active_item=NULL; 
   33.62 +    target_item=NULL; 
   33.63 +    active_arc=INVALID;	
   33.64 +    active_node=INVALID;	
   33.65 +
   33.66 +
   33.67 +    actual_tool=newtool;
   33.68 +
   33.69 +    switch(newtool)
   33.70 +    {
   33.71 +      case MOVE:
   33.72 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::moveEventHandler), false);
   33.73 +        break;
   33.74 +
   33.75 +      case CREATE_NODE:
   33.76 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::createNodeEventHandler), false);
   33.77 +        break;
   33.78 +
   33.79 +      case CREATE_EDGE:
   33.80 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::createArcEventHandler), false);
   33.81 +        break;
   33.82 +
   33.83 +      case ERASER:
   33.84 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::eraserEventHandler), false);
   33.85 +        break;
   33.86 +
   33.87 +      case MAP_EDIT:
   33.88 +        grab_focus();
   33.89 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::mapEditEventHandler), false);
   33.90 +        break;
   33.91 +
   33.92 +      default:
   33.93 +        break;
   33.94 +    }
   33.95 +  }
   33.96 +}
   33.97 +
   33.98 +int DigraphDisplayerCanvas::getActualTool()
   33.99 +{
  33.100 +  return actual_tool;
  33.101 +}
  33.102 +
  33.103 +bool DigraphDisplayerCanvas::scrollEventHandler(GdkEvent* e)
  33.104 +{
  33.105 +  bool handled=false;
  33.106 +  if(e->type==GDK_SCROLL)
  33.107 +    {
  33.108 +
  33.109 +      //pointer shows this win point before zoom
  33.110 +      XY win_coord(((GdkEventScroll*)e)->x, ((GdkEventScroll*)e)->y);
  33.111 +
  33.112 +      //the original scroll settings
  33.113 +      int scroll_offset_x, scroll_offset_y;
  33.114 +      get_scroll_offsets(scroll_offset_x, scroll_offset_y);
  33.115 +
  33.116 +      //pointer shows this canvas point before zoom
  33.117 +      XY canvas_coord;
  33.118 +      window_to_world(win_coord.x, win_coord.y, canvas_coord.x, canvas_coord.y);
  33.119 +
  33.120 +      if(((GdkEventScroll*)e)->direction) //IN
  33.121 +	{
  33.122 +	  zoomIn();
  33.123 +	}
  33.124 +      else
  33.125 +	{
  33.126 +	  zoomOut();
  33.127 +	}
  33.128 +
  33.129 +      //pointer shows this window point after zoom
  33.130 +      XY post_win_coord;
  33.131 +      world_to_window(canvas_coord.x, canvas_coord.y, post_win_coord.x, post_win_coord.y);
  33.132 +
  33.133 +      //we have to add the difference between new and old window point to original scroll offset
  33.134 +      scroll_to(scroll_offset_x+(int)(post_win_coord.x-win_coord.x),scroll_offset_y+(int)(post_win_coord.y-win_coord.y));
  33.135 +      
  33.136 +      //no other eventhandler is needed
  33.137 +      handled=true;
  33.138 +    }
  33.139 +  return handled;
  33.140 +}
  33.141 +
  33.142 +bool DigraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
  33.143 +{
  33.144 +  MapStorage& ms = *mytab.mapstorage;
  33.145 +
  33.146 +  static Gnome::Canvas::Text *coord_text = 0;
  33.147 +  switch(e->type)
  33.148 +  {
  33.149 +    case GDK_BUTTON_PRESS:
  33.150 +      //we mark the location of the event to be able to calculate parameters of dragging
  33.151 +      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.152 +
  33.153 +      active_item=(get_item_at(clicked_x, clicked_y));
  33.154 +      active_node=INVALID;
  33.155 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.156 +      {
  33.157 +        if(nodesmap[i]==active_item)
  33.158 +        {
  33.159 +          active_node=i;
  33.160 +        }
  33.161 +      }
  33.162 +      isbutton=e->button.button;
  33.163 +      break;
  33.164 +    case GDK_BUTTON_RELEASE:
  33.165 +      if (coord_text)
  33.166 +      {
  33.167 +        delete coord_text;
  33.168 +        coord_text = 0;
  33.169 +      }
  33.170 +      isbutton=0;
  33.171 +      active_item=NULL;
  33.172 +      active_node=INVALID;
  33.173 +      break;
  33.174 +    case GDK_MOTION_NOTIFY:
  33.175 +      //we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes
  33.176 +      if(active_node!=INVALID)
  33.177 +      {
  33.178 +        ms.setModified();
  33.179 +
  33.180 +        //new coordinates will be the old values,
  33.181 +        //because the item will be moved to the
  33.182 +        //new coordinate therefore the new movement
  33.183 +        //has to be calculated from here
  33.184 +
  33.185 +        double new_x, new_y;
  33.186 +
  33.187 +        window_to_world (e->motion.x, e->motion.y, new_x, new_y);
  33.188 +
  33.189 +        double dx=new_x-clicked_x;
  33.190 +        double dy=new_y-clicked_y;
  33.191 +
  33.192 +        moveNode(dx, dy);
  33.193 +
  33.194 +        clicked_x=new_x;
  33.195 +        clicked_y=new_y;
  33.196 +
  33.197 +        // reposition the coordinates text
  33.198 +        std::ostringstream ostr;
  33.199 +        ostr << "(" <<
  33.200 +          ms.getNodeCoords(active_node).x << ", " <<
  33.201 +          ms.getNodeCoords(active_node).y << ")";
  33.202 +        double radius =
  33.203 +          (nodesmap[active_node]->property_x2().get_value() -
  33.204 +           nodesmap[active_node]->property_x1().get_value()) / 2.0;
  33.205 +        if (coord_text)
  33.206 +        {
  33.207 +          coord_text->property_text().set_value(ostr.str());
  33.208 +          coord_text->property_x().set_value(
  33.209 +              ms.getNodeCoords(active_node).x + radius);
  33.210 +          coord_text->property_y().set_value(
  33.211 +              ms.getNodeCoords(active_node).y - radius);
  33.212 +        }
  33.213 +        else
  33.214 +        {
  33.215 +          coord_text = new Gnome::Canvas::Text(
  33.216 +              displayed_graph,
  33.217 +              ms.getNodeCoords(active_node).x + radius,
  33.218 +              ms.getNodeCoords(active_node).y - radius,
  33.219 +              ostr.str());
  33.220 +          coord_text->property_fill_color().set_value("black");
  33.221 +          coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
  33.222 +        }
  33.223 +
  33.224 +
  33.225 +      }
  33.226 +    default: break;
  33.227 +  }
  33.228 +
  33.229 +  return false;
  33.230 +}
  33.231 +
  33.232 +XY DigraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, int move_code)
  33.233 +{
  33.234 +  switch(move_code)
  33.235 +  {
  33.236 +    case 1:
  33.237 +      return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0);
  33.238 +      break;
  33.239 +    case 2:
  33.240 +      return old_arrow_pos;
  33.241 +      break;
  33.242 +    case 3:
  33.243 +      {
  33.244 +        //////////////////////////////////////////////////////////////////////////////////////////////////////
  33.245 +        /////////// keeps shape-with scalar multiplication - version 2.
  33.246 +        //////////////////////////////////////////////////////////////////////////////////////////////////////
  33.247 +
  33.248 +        //old vector from one to the other node - a
  33.249 +        XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
  33.250 +        //new vector from one to the other node - b
  33.251 +        XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
  33.252 +
  33.253 +        double absa=sqrt(a_v.normSquare());
  33.254 +        double absb=sqrt(b_v.normSquare());
  33.255 +
  33.256 +        if ((absa == 0.0) || (absb == 0.0))
  33.257 +        {
  33.258 +          return old_arrow_pos;
  33.259 +        }
  33.260 +        else
  33.261 +        {
  33.262 +          //old vector from one node to the breakpoint - c
  33.263 +          XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
  33.264 +
  33.265 +          //unit vector with the same direction to a_v
  33.266 +          XY a_v_u(a_v.x/absa,a_v.y/absa);
  33.267 +
  33.268 +          //normal vector of unit vector with the same direction to a_v
  33.269 +          XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
  33.270 +
  33.271 +          //unit vector with the same direction to b_v
  33.272 +          XY b_v_u(b_v.x/absb,b_v.y/absb);
  33.273 +
  33.274 +          //normal vector of unit vector with the same direction to b_v
  33.275 +          XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
  33.276 +
  33.277 +          //vector c in a_v_u and a_v_u_n co-ordinate system
  33.278 +          XY c_a(c_v*a_v_u,c_v*a_v_u_n);
  33.279 +
  33.280 +          //new vector from one node to the breakpoint - d - we have to calculate this one
  33.281 +          XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
  33.282 +
  33.283 +          return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
  33.284 +        }
  33.285 +        break;
  33.286 +      }
  33.287 +    default:
  33.288 +      break;
  33.289 +  }
  33.290 +}
  33.291 +
  33.292 +
  33.293 +bool DigraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e)
  33.294 +{
  33.295 +  MapStorage& ms = *mytab.mapstorage;
  33.296 +
  33.297 +  switch(e->type)
  33.298 +  {
  33.299 +    //move the new node
  33.300 +    case GDK_MOTION_NOTIFY:
  33.301 +      {
  33.302 +        GdkEvent * generated=new GdkEvent();
  33.303 +        generated->motion.x=e->motion.x;
  33.304 +        generated->motion.y=e->motion.y;
  33.305 +        generated->type=GDK_MOTION_NOTIFY;
  33.306 +        moveEventHandler(generated);      
  33.307 +        break;
  33.308 +      }
  33.309 +
  33.310 +    case GDK_BUTTON_RELEASE:
  33.311 +      ms.setModified();
  33.312 +
  33.313 +      is_drawn=true;
  33.314 +
  33.315 +      isbutton=1;
  33.316 +
  33.317 +      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.318 +
  33.319 +      active_node = ms.addNode(XY(clicked_x, clicked_y));
  33.320 +
  33.321 +      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
  33.322 +          clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
  33.323 +      active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
  33.324 +      *(nodesmap[active_node]) <<
  33.325 +        Gnome::Canvas::Properties::fill_color("blue");
  33.326 +      *(nodesmap[active_node]) <<
  33.327 +        Gnome::Canvas::Properties::outline_color("black");
  33.328 +      active_item->raise_to_top();
  33.329 +
  33.330 +      (nodesmap[active_node])->show();
  33.331 +
  33.332 +      nodetextmap[active_node]=new Gnome::Canvas::Text(displayed_graph,
  33.333 +          clicked_x+node_property_defaults[N_RADIUS]+5,
  33.334 +          clicked_y+node_property_defaults[N_RADIUS]+5, "");
  33.335 +      nodetextmap[active_node]->property_fill_color().set_value("darkblue");
  33.336 +      nodetextmap[active_node]->raise_to_top();
  33.337 +
  33.338 +      //       mapwin.updateNode(active_node);
  33.339 +      propertyUpdate(active_node);
  33.340 +
  33.341 +      isbutton=0;
  33.342 +      target_item=NULL;
  33.343 +      active_item=NULL;
  33.344 +      active_node=INVALID;
  33.345 +      break;
  33.346 +    default:
  33.347 +      break;
  33.348 +  }
  33.349 +  return false;
  33.350 +}
  33.351 +
  33.352 +bool DigraphDisplayerCanvas::createArcEventHandler(GdkEvent* e)
  33.353 +{
  33.354 +  MapStorage& ms = *mytab.mapstorage;
  33.355 +
  33.356 +  switch(e->type)
  33.357 +  {
  33.358 +    case GDK_BUTTON_PRESS:
  33.359 +      //in arc creation right button has special meaning
  33.360 +      if(e->button.button!=3)
  33.361 +      {
  33.362 +        //there is not yet selected node
  33.363 +        if(active_node==INVALID)
  33.364 +        {
  33.365 +          //we mark the location of the event to be able to calculate parameters of dragging
  33.366 +
  33.367 +          window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.368 +
  33.369 +          active_item=(get_item_at(clicked_x, clicked_y));
  33.370 +          active_node=INVALID;
  33.371 +          for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.372 +          {
  33.373 +            if(nodesmap[i]==active_item)
  33.374 +            {
  33.375 +              active_node=i;
  33.376 +            }
  33.377 +          }
  33.378 +          //the clicked item is really a node
  33.379 +          if(active_node!=INVALID)
  33.380 +          {
  33.381 +            *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
  33.382 +            isbutton=1;
  33.383 +          }
  33.384 +          //clicked item was not a node. It could be e.g. arc.
  33.385 +          else
  33.386 +          {
  33.387 +            active_item=NULL;
  33.388 +          }
  33.389 +        }
  33.390 +        //we only have to do sg. if the mouse button
  33.391 +        // is pressed already once AND the click was
  33.392 +        // on a node that was found in the set of 
  33.393 +        //nodes, and now we only search for the second 
  33.394 +        //node
  33.395 +        else
  33.396 +        {
  33.397 +          window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.398 +          target_item=(get_item_at(clicked_x, clicked_y));
  33.399 +          Node target_node=INVALID;
  33.400 +          for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.401 +          {
  33.402 +            if(nodesmap[i]==target_item)
  33.403 +            {
  33.404 +              target_node=i;
  33.405 +            }
  33.406 +          }
  33.407 +          //the clicked item is a node, the arc can be drawn
  33.408 +          if(target_node!=INVALID)
  33.409 +          {
  33.410 +            ms.setModified();
  33.411 +
  33.412 +            *(nodesmap[target_node]) <<
  33.413 +              Gnome::Canvas::Properties::fill_color("red");
  33.414 +
  33.415 +            active_arc = ms.addArc(active_node, target_node);
  33.416 +
  33.417 +            if(target_node!=active_node)		
  33.418 +            {
  33.419 +              arcsmap[active_arc]=new BrokenArc(displayed_graph, active_arc, *this);
  33.420 +            }
  33.421 +            else
  33.422 +            {
  33.423 +              arcsmap[active_arc]=new LoopArc(displayed_graph, active_arc, *this);
  33.424 +            }
  33.425 +
  33.426 +            //initializing arc-text as well, to empty string
  33.427 +            XY text_pos=ms.getArrowCoords(active_arc);
  33.428 +            text_pos+=(XY(10,10));
  33.429 +
  33.430 +            arctextmap[active_arc]=new Gnome::Canvas::Text(displayed_graph,
  33.431 +                text_pos.x, text_pos.y, "");
  33.432 +            arctextmap[active_arc]->property_fill_color().set_value(
  33.433 +                "darkgreen");
  33.434 +            arctextmap[active_arc]->raise_to_top();
  33.435 +
  33.436 +            propertyUpdate(active_arc);
  33.437 +          }
  33.438 +          //clicked item was not a node. it could be an e.g. arc. we do not
  33.439 +          //deal with it furthermore.
  33.440 +          else
  33.441 +          {
  33.442 +            target_item=NULL;
  33.443 +          }
  33.444 +        }
  33.445 +      }
  33.446 +      break;
  33.447 +    case GDK_BUTTON_RELEASE:
  33.448 +      isbutton=0;
  33.449 +      //we clear settings in two cases
  33.450 +      //1: the arc is ready (target_item has valid value)
  33.451 +      //2: the arc creation is cancelled with right button
  33.452 +      if((target_item)||(e->button.button==3))
  33.453 +      {
  33.454 +        if(active_item)
  33.455 +        {
  33.456 +          propertyUpdate(active_node,N_COLOR);
  33.457 +          active_item=NULL;
  33.458 +        }
  33.459 +        if(target_item)
  33.460 +        {
  33.461 +          propertyUpdate(ms.digraph.target(active_arc),N_COLOR);
  33.462 +          target_item=NULL;
  33.463 +        }
  33.464 +        active_node=INVALID;
  33.465 +        active_arc=INVALID;
  33.466 +      }
  33.467 +      break;
  33.468 +    default:
  33.469 +      break;
  33.470 +  }
  33.471 +  return false;
  33.472 +}
  33.473 +
  33.474 +bool DigraphDisplayerCanvas::eraserEventHandler(GdkEvent* e)
  33.475 +{
  33.476 +  MapStorage& ms = *mytab.mapstorage;
  33.477 +
  33.478 +  switch(e->type)
  33.479 +  {
  33.480 +    case GDK_BUTTON_PRESS:
  33.481 +      //finding the clicked items
  33.482 +      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.483 +      active_item=(get_item_at(clicked_x, clicked_y));
  33.484 +      active_node=INVALID;
  33.485 +      active_arc=INVALID;
  33.486 +      //was it a node?
  33.487 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.488 +      {
  33.489 +        if(nodesmap[i]==active_item)
  33.490 +        {
  33.491 +          active_node=i;
  33.492 +        }
  33.493 +      }
  33.494 +      //or was it an arc?
  33.495 +      if(active_node==INVALID)
  33.496 +      {
  33.497 +        for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  33.498 +        {
  33.499 +          if(arcsmap[i]->getLine()==active_item)
  33.500 +          {
  33.501 +            active_arc=i;
  33.502 +          }
  33.503 +        }
  33.504 +      }
  33.505 +
  33.506 +      // return if the clicked object is neither an arc nor a node
  33.507 +      if (active_arc == INVALID) return false;
  33.508 +
  33.509 +      //recolor activated item
  33.510 +      if(active_item)
  33.511 +      {
  33.512 +        *active_item << Gnome::Canvas::Properties::fill_color("red");
  33.513 +      }
  33.514 +      break;
  33.515 +
  33.516 +    case GDK_BUTTON_RELEASE:
  33.517 +      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.518 +      if(active_item)
  33.519 +      {
  33.520 +        //the cursor was not moved since pressing it
  33.521 +        if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
  33.522 +        {
  33.523 +          //a node was found
  33.524 +          if(active_node!=INVALID)
  33.525 +          {
  33.526 +            ms.setModified();
  33.527 +
  33.528 +            std::set<Digraph::Arc> arcs_to_delete;
  33.529 +
  33.530 +            for(OutArcIt e(ms.digraph,active_node);e!=INVALID;++e)
  33.531 +            {
  33.532 +              arcs_to_delete.insert(e);
  33.533 +            }
  33.534 +
  33.535 +            for(InArcIt e(ms.digraph,active_node);e!=INVALID;++e)
  33.536 +            {
  33.537 +              arcs_to_delete.insert(e);
  33.538 +            }
  33.539 +
  33.540 +            //deleting collected arcs
  33.541 +            for(std::set<Digraph::Arc>::iterator
  33.542 +                arc_set_it=arcs_to_delete.begin();
  33.543 +                arc_set_it!=arcs_to_delete.end();
  33.544 +                ++arc_set_it)
  33.545 +            {
  33.546 +              deleteItem(*arc_set_it);
  33.547 +            }
  33.548 +            deleteItem(active_node);
  33.549 +          }
  33.550 +          //a simple arc was chosen
  33.551 +          else if (active_arc != INVALID)
  33.552 +          {
  33.553 +            deleteItem(active_arc);
  33.554 +          }
  33.555 +        }
  33.556 +        //pointer was moved, deletion is cancelled
  33.557 +        else
  33.558 +        {
  33.559 +          if(active_node!=INVALID)
  33.560 +          {
  33.561 +            *active_item << Gnome::Canvas::Properties::fill_color("blue");
  33.562 +          }
  33.563 +          else if (active_arc != INVALID)
  33.564 +          {
  33.565 +            *active_item << Gnome::Canvas::Properties::fill_color("green");
  33.566 +          }
  33.567 +        }
  33.568 +      }
  33.569 +      //reseting datas
  33.570 +      active_item=NULL;
  33.571 +      active_arc=INVALID;
  33.572 +      active_node=INVALID;
  33.573 +      break;
  33.574 +
  33.575 +    case GDK_MOTION_NOTIFY:
  33.576 +      break;
  33.577 +
  33.578 +    default:
  33.579 +      break;
  33.580 +  }
  33.581 +  return false;
  33.582 +}
  33.583 +
  33.584 +bool DigraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e)
  33.585 +{
  33.586 +  MapStorage& ms = *mytab.mapstorage;
  33.587 +
  33.588 +  if(actual_tool==MAP_EDIT)
  33.589 +  {
  33.590 +    switch(e->type)
  33.591 +    {
  33.592 +      case GDK_BUTTON_PRESS:
  33.593 +        {
  33.594 +          //for determine, whether it was an arc
  33.595 +          Arc clicked_arc=INVALID;
  33.596 +          //for determine, whether it was a node
  33.597 +          Node clicked_node=INVALID;
  33.598 +
  33.599 +          window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  33.600 +          active_item=(get_item_at(clicked_x, clicked_y));
  33.601 +
  33.602 +          //find the activated item between text of nodes
  33.603 +          for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.604 +          {
  33.605 +            //at the same time only one can be active
  33.606 +            if(nodetextmap[i]==active_item)
  33.607 +            {
  33.608 +              clicked_node=i;
  33.609 +            }
  33.610 +          }
  33.611 +
  33.612 +          //if there was not, search for it between nodes
  33.613 +          if(clicked_node==INVALID)
  33.614 +          {
  33.615 +            for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  33.616 +            {
  33.617 +              //at the same time only one can be active
  33.618 +              if(nodesmap[i]==active_item)
  33.619 +              {
  33.620 +                clicked_node=i;
  33.621 +              }
  33.622 +            }
  33.623 +          }
  33.624 +
  33.625 +          if(clicked_node==INVALID)
  33.626 +          {
  33.627 +            //find the activated item between texts
  33.628 +            for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  33.629 +            {
  33.630 +              //at the same time only one can be active
  33.631 +              if(arctextmap[i]==active_item)
  33.632 +              {
  33.633 +                clicked_arc=i;
  33.634 +              }
  33.635 +            }
  33.636 +
  33.637 +            //if it was not between texts, search for it between arcs
  33.638 +            if(clicked_arc==INVALID)
  33.639 +            {
  33.640 +              for (ArcIt i(ms.digraph); i!=INVALID; ++i)
  33.641 +              {
  33.642 +                //at the same time only one can be active
  33.643 +                if((arcsmap[i]->getLine())==active_item)
  33.644 +                {
  33.645 +                  clicked_arc=i;
  33.646 +                }
  33.647 +              }
  33.648 +            }
  33.649 +          }
  33.650 +
  33.651 +          //if it was really a node...
  33.652 +          if(clicked_node!=INVALID)
  33.653 +          {
  33.654 +            // the id map is not editable
  33.655 +            if (nodemap_to_edit == "label") return 0;
  33.656 +
  33.657 +            //and there is activated map
  33.658 +            if(nodetextmap[clicked_node]->property_text().get_value()!="")
  33.659 +            {
  33.660 +              //activate the general variable for it
  33.661 +              active_node=clicked_node;
  33.662 +
  33.663 +              //create a dialog
  33.664 +              Gtk::Dialog dialog("Edit value", true);
  33.665 +              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  33.666 +              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  33.667 +              Gtk::VBox* vbox = dialog.get_vbox();
  33.668 +
  33.669 +              /*
  33.670 +              Gtk::SpinButton spin(0.0, 4);
  33.671 +              spin.set_increments(1.0, 10.0);
  33.672 +              spin.set_range(-1000000.0, 1000000.0);
  33.673 +              spin.set_numeric(true);
  33.674 +              spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
  33.675 +              vbox->add(spin);
  33.676 +              spin.show();
  33.677 +              */
  33.678 +              Gtk::Entry entry;
  33.679 +              entry.set_text(nodetextmap[active_node]->property_text().get_value());
  33.680 +              vbox->add(entry);
  33.681 +              entry.show();
  33.682 +
  33.683 +              switch (dialog.run())
  33.684 +              {
  33.685 +                case Gtk::RESPONSE_NONE:
  33.686 +                case Gtk::RESPONSE_CANCEL:
  33.687 +                  break;
  33.688 +                case Gtk::RESPONSE_ACCEPT:
  33.689 +                  switch (ms.getNodeMapElementType(nodemap_to_edit))
  33.690 +                  {
  33.691 +                    case MapValue::NUMERIC:
  33.692 +                      ms.set(nodemap_to_edit, active_node,
  33.693 +                          atof(entry.get_text().c_str()));
  33.694 +                      break;
  33.695 +                    case MapValue::STRING:
  33.696 +                      ms.set(nodemap_to_edit, active_node,
  33.697 +                          static_cast<std::string>(entry.get_text()));
  33.698 +                      break;
  33.699 +                  }
  33.700 +                  nodetextmap[active_node]->property_text().set_value(
  33.701 +                      static_cast<std::string>(ms.get(nodemap_to_edit, active_node)));
  33.702 +
  33.703 +                  //mapwin.updateNode(active_node);
  33.704 +                  //mapwin.updateNode(Node(INVALID));
  33.705 +                  propertyUpdate(Node(INVALID));
  33.706 +              }
  33.707 +            }
  33.708 +          }
  33.709 +          else
  33.710 +            //if it was really an arc...
  33.711 +            if(clicked_arc!=INVALID)
  33.712 +            {
  33.713 +              // the id map is not editable
  33.714 +              if (arcmap_to_edit == "label") return 0;
  33.715 +
  33.716 +              //and there is activated map
  33.717 +              if(arctextmap[clicked_arc]->property_text().get_value()!="")
  33.718 +              {
  33.719 +                //activate the general variable for it
  33.720 +                active_arc=clicked_arc;
  33.721 +
  33.722 +                //create a dialog
  33.723 +                Gtk::Dialog dialog("Edit value", true);
  33.724 +                dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  33.725 +                dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  33.726 +                Gtk::VBox* vbox = dialog.get_vbox();
  33.727 +
  33.728 +                /*
  33.729 +                Gtk::SpinButton spin(0.0, 4);
  33.730 +                spin.set_increments(1.0, 10.0);
  33.731 +                spin.set_range(-1000000.0, 1000000.0);
  33.732 +                spin.set_numeric(true);
  33.733 +                spin.set_value(atof(arctextmap[active_arc]->property_text().get_value().c_str()));
  33.734 +                vbox->add(spin);
  33.735 +                spin.show();
  33.736 +                */
  33.737 +                Gtk::Entry entry;
  33.738 +                entry.set_text(arctextmap[active_arc]->property_text().get_value());
  33.739 +                vbox->add(entry);
  33.740 +                entry.show();
  33.741 +
  33.742 +                std::cout << arcmap_to_edit << std::endl;
  33.743 +                switch (dialog.run())
  33.744 +                {
  33.745 +                  case Gtk::RESPONSE_NONE:
  33.746 +                  case Gtk::RESPONSE_CANCEL:
  33.747 +                    break;
  33.748 +                  case Gtk::RESPONSE_ACCEPT:
  33.749 +                    switch (ms.getArcMapElementType(arcmap_to_edit))
  33.750 +                    {
  33.751 +                      case MapValue::NUMERIC:
  33.752 +                        ms.set(arcmap_to_edit, active_arc,
  33.753 +                            atof(entry.get_text().c_str()));
  33.754 +                        break;
  33.755 +                      case MapValue::STRING:
  33.756 +                        ms.set(arcmap_to_edit, active_arc,
  33.757 +                            static_cast<std::string>(entry.get_text()));
  33.758 +                        break;
  33.759 +                    }
  33.760 +                    arctextmap[active_arc]->property_text().set_value(
  33.761 +                        static_cast<std::string>(ms.get(arcmap_to_edit, active_arc)));
  33.762 +
  33.763 +                    //mapwin.updateArc(active_arc);
  33.764 +                    //                   mapwin.updateArc(Arc(INVALID));
  33.765 +                    propertyUpdate(Arc(INVALID));
  33.766 +                }
  33.767 +              }
  33.768 +            }
  33.769 +          break;
  33.770 +        }
  33.771 +      default:
  33.772 +        break;
  33.773 +    }
  33.774 +  }
  33.775 +  return false;  
  33.776 +}
  33.777 +
  33.778 +void DigraphDisplayerCanvas::deleteItem(Node node_to_delete)
  33.779 +{
  33.780 +  delete(nodetextmap[node_to_delete]);
  33.781 +  delete(nodesmap[node_to_delete]);
  33.782 +  mytab.mapstorage->digraph.erase(node_to_delete);
  33.783 +}
  33.784 +
  33.785 +void DigraphDisplayerCanvas::deleteItem(Arc arc_to_delete)
  33.786 +{
  33.787 +  delete(arctextmap[arc_to_delete]);
  33.788 +  delete(arcsmap[arc_to_delete]);
  33.789 +  mytab.mapstorage->digraph.erase(arc_to_delete);
  33.790 +}
  33.791 +
  33.792 +void DigraphDisplayerCanvas::textReposition(XY new_place)
  33.793 +{
  33.794 +  new_place+=(XY(10,10));
  33.795 +  arctextmap[forming_arc]->property_x().set_value(new_place.x);
  33.796 +  arctextmap[forming_arc]->property_y().set_value(new_place.y);
  33.797 +}
  33.798 +
  33.799 +void DigraphDisplayerCanvas::toggleArcActivity(ArcBase* active_bre, bool on)
  33.800 +{
  33.801 +  if(on)
  33.802 +  {
  33.803 +    if(forming_arc!=INVALID)
  33.804 +    {
  33.805 +      std::cerr << "ERROR!!!! Valid arc found!" << std::endl;
  33.806 +    }
  33.807 +    else
  33.808 +    {
  33.809 +      for (ArcIt i(mytab.mapstorage->digraph); i!=INVALID; ++i)
  33.810 +      {
  33.811 +        if(arcsmap[i]==active_bre)
  33.812 +        {
  33.813 +          forming_arc=i;
  33.814 +        }
  33.815 +      }
  33.816 +    }
  33.817 +  }
  33.818 +  else
  33.819 +  {
  33.820 +    if(forming_arc!=INVALID)
  33.821 +    {
  33.822 +      forming_arc=INVALID;
  33.823 +    }
  33.824 +    else
  33.825 +    {
  33.826 +      std::cerr << "ERROR!!!! Invalid arc found!" << std::endl;
  33.827 +    }
  33.828 +  }
  33.829 +}
  33.830 +
  33.831 +void DigraphDisplayerCanvas::moveNode(double dx, double dy, Gnome::Canvas::Item * item, Node node)
  33.832 +{
  33.833 +  MapStorage& ms = *mytab.mapstorage;
  33.834 +
  33.835 +  Gnome::Canvas::Item * moved_item=item;
  33.836 +  Node moved_node=node;
  33.837 +
  33.838 +  if(item==NULL && node==INVALID)
  33.839 +  {
  33.840 +    moved_item=active_item;
  33.841 +    moved_node=active_node;
  33.842 +  }
  33.843 +  else
  33.844 +  {
  33.845 +    isbutton=1;
  33.846 +  }
  33.847 +
  33.848 +  //repositioning node and its text
  33.849 +  moved_item->move(dx, dy);
  33.850 +  nodetextmap[moved_node]->move(dx, dy);
  33.851 +
  33.852 +  // the new coordinates of the centre of the node 
  33.853 +  double coord_x = dx + ms.getNodeCoords(moved_node).x;
  33.854 +  double coord_y = dy + ms.getNodeCoords(moved_node).y;
  33.855 +
  33.856 +  // write back the new coordinates to the coords map
  33.857 +  ms.setNodeCoords(moved_node, XY(coord_x, coord_y));
  33.858 +
  33.859 +  //all the arcs connected to the moved point has to be redrawn
  33.860 +  for(OutArcIt ei(ms.digraph,moved_node);ei!=INVALID;++ei)
  33.861 +  {
  33.862 +    XY arrow_pos;
  33.863 +
  33.864 +    if (ms.digraph.source(ei) == ms.digraph.target(ei))
  33.865 +    {
  33.866 +      arrow_pos = ms.getArrowCoords(ei) + XY(dx, dy);
  33.867 +    }
  33.868 +    else
  33.869 +    {
  33.870 +      XY moved_node_1(coord_x - dx, coord_y - dy);
  33.871 +      XY moved_node_2(coord_x, coord_y);
  33.872 +      Node target = ms.digraph.target(ei);
  33.873 +      XY fix_node = ms.getNodeCoords(target);
  33.874 +      XY old_arrow_pos(ms.getArrowCoords(ei));
  33.875 +
  33.876 +      arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
  33.877 +    }
  33.878 +
  33.879 +    ms.setArrowCoords(ei, arrow_pos);
  33.880 +    arcsmap[ei]->draw();
  33.881 +
  33.882 +    //reposition of arctext
  33.883 +    XY text_pos=ms.getArrowCoords(ei);
  33.884 +    text_pos+=(XY(10,10));
  33.885 +    arctextmap[ei]->property_x().set_value(text_pos.x);
  33.886 +    arctextmap[ei]->property_y().set_value(text_pos.y);
  33.887 +  }
  33.888 +
  33.889 +  for(InArcIt ei(ms.digraph,moved_node);ei!=INVALID;++ei)
  33.890 +  {
  33.891 +    if (ms.digraph.source(ei) != ms.digraph.target(ei))
  33.892 +    {
  33.893 +      XY moved_node_1(coord_x - dx, coord_y - dy);
  33.894 +      XY moved_node_2(coord_x, coord_y);
  33.895 +      Node source = ms.digraph.source(ei);
  33.896 +      XY fix_node = ms.getNodeCoords(source);
  33.897 +      XY old_arrow_pos(ms.getArrowCoords(ei));
  33.898 +
  33.899 +      XY arrow_pos;
  33.900 +      arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
  33.901 +
  33.902 +      ms.setArrowCoords(ei, arrow_pos);
  33.903 +      arcsmap[ei]->draw();
  33.904 +
  33.905 +      //reposition of arctext
  33.906 +      XY text_pos=ms.getArrowCoords(ei);
  33.907 +      text_pos+=(XY(10,10));
  33.908 +      arctextmap[ei]->property_x().set_value(text_pos.x);
  33.909 +      arctextmap[ei]->property_y().set_value(text_pos.y);
  33.910 +    }
  33.911 +  }
  33.912 +}
  33.913 +
  33.914 +Gdk::Color DigraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
  33.915 +{
  33.916 +  Gdk::Color color;
  33.917 +
  33.918 +  double pos=(w-min)/(max-min);
  33.919 +  int phase=0;
  33.920 +
  33.921 +  //rainbow transitions contain 6 phase
  33.922 +  //in each phase only one color is changed
  33.923 +  //first we determine the phase, in which
  33.924 +  //the actual value belongs to
  33.925 +  for (int i=0;i<=5;i++)
  33.926 +  {
  33.927 +    if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
  33.928 +    {
  33.929 +      phase=i;
  33.930 +    }
  33.931 +  }
  33.932 +  if(phase<6)
  33.933 +  {
  33.934 +    //within its 1/6 long phase the relativ position
  33.935 +    //determines the power of the color changed in
  33.936 +    //that phase
  33.937 +    //we normalize that to one, to be able to give percentage
  33.938 +    //value for the function
  33.939 +    double rel_pos=(pos-(phase/6.0))*6.0;
  33.940 +
  33.941 +    switch(phase)
  33.942 +    {
  33.943 +      case 0:
  33.944 +        color.set_rgb_p (1, 0, 1-rel_pos);
  33.945 +        break;
  33.946 +      case 1:
  33.947 +        color.set_rgb_p (1, rel_pos, 0);
  33.948 +        break;
  33.949 +      case 2:
  33.950 +        color.set_rgb_p (1-rel_pos, 1, 0);
  33.951 +        break;
  33.952 +      case 3:
  33.953 +        color.set_rgb_p (0, 1, rel_pos);
  33.954 +        break;
  33.955 +      case 4:
  33.956 +        color.set_rgb_p (0, 1-rel_pos, 1);
  33.957 +        break;
  33.958 +      case 5:
  33.959 +        color.set_rgb_p ((rel_pos/3.0), 0, 1);
  33.960 +        break;
  33.961 +      default:
  33.962 +        std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
  33.963 +    }
  33.964 +  }
  33.965 +  else
  33.966 +  {
  33.967 +    std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
  33.968 +  }
  33.969 +  return color;
  33.970 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/graph_displayer_canvas-node.cc	Mon Jul 07 08:10:39 2008 -0500
    34.3 @@ -0,0 +1,344 @@
    34.4 +/* -*- C++ -*-
    34.5 + *
    34.6 + * This file is a part of LEMON, a generic C++ optimization library
    34.7 + *
    34.8 + * Copyright (C) 2003-2006
    34.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   34.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   34.11 + *
   34.12 + * Permission to use, modify and distribute this software is granted
   34.13 + * provided that this copyright notice appears in all copies. For
   34.14 + * precise terms see the accompanying LICENSE file.
   34.15 + *
   34.16 + * This software is provided "AS IS" with no warranty of any kind,
   34.17 + * express or implied, and with no claim as to its suitability for any
   34.18 + * purpose.
   34.19 + *
   34.20 + */
   34.21 +
   34.22 +#include <graph_displayer_canvas.h>
   34.23 +#include <mapstorage.h>
   34.24 +#include <nbtab.h>
   34.25 +#include <cmath>
   34.26 +
   34.27 +const int minimum_node_radius=5;
   34.28 +
   34.29 +int DigraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
   34.30 +{
   34.31 +  MapStorage& ms = *mytab.mapstorage;
   34.32 +
   34.33 +  double min, max;
   34.34 +
   34.35 +  {
   34.36 +    NodeIt n(ms.digraph);
   34.37 +    min = max = ms.get(mapname, n);
   34.38 +    for (; n != INVALID; ++n)
   34.39 +    {
   34.40 +      if (static_cast<double>(ms.get(mapname, n)) > max)
   34.41 +        max = ms.get(mapname, n);
   34.42 +      if (static_cast<double>(ms.get(mapname, n)) < min)
   34.43 +        min = ms.get(mapname, n);
   34.44 +    }
   34.45 +  }
   34.46 +
   34.47 +  if(node==INVALID)
   34.48 +    {
   34.49 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
   34.50 +	{
   34.51 +	  double v=fabs(ms.get(mapname,i));
   34.52 +	  int w;
   34.53 +	  if(autoscale)
   34.54 +	    {
   34.55 +	      if(min==max)
   34.56 +		{
   34.57 +		  w=(int)(node_property_defaults[N_RADIUS]);
   34.58 +		}
   34.59 +	      else
   34.60 +		{
   34.61 +		  w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_size-minimum_node_radius));
   34.62 +		}
   34.63 +	    }
   34.64 +	  else
   34.65 +	    {
   34.66 +	      w=(int)(v*radius_size);
   34.67 +	    }
   34.68 +
   34.69 +	  if(w<minimum_node_radius)
   34.70 +	    {
   34.71 +	      w=minimum_node_radius;
   34.72 +	    }
   34.73 +
   34.74 +	  if(zoomtrack)
   34.75 +	    {
   34.76 +	      double actual_ppu=get_pixels_per_unit();
   34.77 +	      w=(int)(w/actual_ppu*fixed_zoom_factor);
   34.78 +	    }
   34.79 +
   34.80 +	  if(w>=0)
   34.81 +	    {
   34.82 +	      double x1, y1, x2, y2;
   34.83 +	      x1=nodesmap[i]->property_x1().get_value();
   34.84 +	      x2=nodesmap[i]->property_x2().get_value();
   34.85 +	      y1=nodesmap[i]->property_y1().get_value();
   34.86 +	      y2=nodesmap[i]->property_y2().get_value();
   34.87 +	      nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
   34.88 +	      nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
   34.89 +	      nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
   34.90 +	      nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
   34.91 +	    }
   34.92 +	}
   34.93 +    }
   34.94 +  else
   34.95 +    {
   34.96 +      //I think only new nodes use this case
   34.97 +      //that has no own value, only the default one
   34.98 +      //int w=(int)(*actual_map)[node];
   34.99 +      int w=(int)(node_property_defaults[N_RADIUS]);
  34.100 +      if(w>=0)
  34.101 +	{
  34.102 +	  double x1, y1, x2, y2;
  34.103 +	  x1=nodesmap[node]->property_x1().get_value();
  34.104 +	  x2=nodesmap[node]->property_x2().get_value();
  34.105 +	  y1=nodesmap[node]->property_y1().get_value();
  34.106 +	  y2=nodesmap[node]->property_y2().get_value();
  34.107 +	  nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
  34.108 +	  nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
  34.109 +	  nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
  34.110 +	  nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
  34.111 +	}
  34.112 +    }
  34.113 +  return 0;
  34.114 +};
  34.115 +
  34.116 +int DigraphDisplayerCanvas::resetNodeRadius (Node node)
  34.117 +{
  34.118 +  MapStorage& ms = *mytab.mapstorage;
  34.119 +
  34.120 +  double min, max;
  34.121 +  min=node_property_defaults[N_RADIUS];
  34.122 +  max=node_property_defaults[N_RADIUS];
  34.123 +  Digraph::NodeMap<double> actual_map(ms.digraph,node_property_defaults[N_RADIUS]);
  34.124 +  
  34.125 +  if(node==INVALID)
  34.126 +    {
  34.127 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  34.128 +	{
  34.129 +	  double v=fabs(actual_map[i]);
  34.130 +	  int w;
  34.131 +	  if(min==max)
  34.132 +	    {
  34.133 +	      w=(int)(node_property_defaults[N_RADIUS]);
  34.134 +	    }
  34.135 +	  else
  34.136 +	    {
  34.137 +	      w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
  34.138 +	    }
  34.139 +	  if(zoomtrack)
  34.140 +	    {
  34.141 +	      double actual_ppu=get_pixels_per_unit();
  34.142 +	      w=(int)(w/actual_ppu*fixed_zoom_factor);
  34.143 +	    }
  34.144 +	  if(w>=0)
  34.145 +	    {
  34.146 +	      double x1, y1, x2, y2;
  34.147 +	      x1=nodesmap[i]->property_x1().get_value();
  34.148 +	      x2=nodesmap[i]->property_x2().get_value();
  34.149 +	      y1=nodesmap[i]->property_y1().get_value();
  34.150 +	      y2=nodesmap[i]->property_y2().get_value();
  34.151 +	      nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
  34.152 +	      nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
  34.153 +	      nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
  34.154 +	      nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
  34.155 +	    }
  34.156 +	}
  34.157 +    }
  34.158 +  else
  34.159 +    {
  34.160 +      //I think only new nodes use this case
  34.161 +//       int w=(int)actual_map[node];
  34.162 +      int w=(int)(node_property_defaults[N_RADIUS]);
  34.163 +      if(w>=0)
  34.164 +	{
  34.165 +	  double x1, y1, x2, y2;
  34.166 +	  x1=nodesmap[node]->property_x1().get_value();
  34.167 +	  x2=nodesmap[node]->property_x2().get_value();
  34.168 +	  y1=nodesmap[node]->property_y1().get_value();
  34.169 +	  y2=nodesmap[node]->property_y2().get_value();
  34.170 +	  nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
  34.171 +	  nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
  34.172 +	  nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
  34.173 +	  nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
  34.174 +	}
  34.175 +    }
  34.176 +  return 0;
  34.177 +};
  34.178 +
  34.179 +int DigraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
  34.180 +{  
  34.181 +  MapStorage& ms = *mytab.mapstorage;
  34.182 +
  34.183 +  //function maps the range of the maximum and
  34.184 +  //the minimum of the nodemap to the range of
  34.185 +  //green in RGB
  34.186 +
  34.187 +  double max, min;
  34.188 +
  34.189 +  {
  34.190 +    NodeIt n(ms.digraph);
  34.191 +    min = max = ms.get(mapname, n);
  34.192 +    for (; n != INVALID; ++n)
  34.193 +    {
  34.194 +      if (static_cast<double>(ms.get(mapname, n)) > max)
  34.195 +        max = ms.get(mapname, n);
  34.196 +      if (static_cast<double>(ms.get(mapname, n)) < min)
  34.197 +        min = ms.get(mapname, n);
  34.198 +    }
  34.199 +  }
  34.200 +
  34.201 +  if(node==INVALID)
  34.202 +    {
  34.203 +
  34.204 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  34.205 +	{
  34.206 +	  Gdk::Color color;
  34.207 +
  34.208 +	  double w=ms.get(mapname, i);
  34.209 +
  34.210 +	  if(max!=min)
  34.211 +	    {
  34.212 +	      color=rainbowColorCounter(min, max, w);
  34.213 +	    }
  34.214 +	  else
  34.215 +	    {
  34.216 +	      color.set_rgb_p (0, 0, 1);
  34.217 +	    }
  34.218 +
  34.219 +	  nodesmap[i]->property_fill_color_gdk().set_value(color);
  34.220 +	}
  34.221 +    }
  34.222 +  else
  34.223 +    {
  34.224 +      Gdk::Color color;
  34.225 +
  34.226 +      double w=ms.get(mapname, node);
  34.227 +
  34.228 +      if(max!=min)
  34.229 +	{
  34.230 +	  color=rainbowColorCounter(min, max, w);
  34.231 +	}
  34.232 +      else
  34.233 +	{
  34.234 +	  color.set_rgb_p (0, 0, 1);
  34.235 +	}
  34.236 +
  34.237 +      nodesmap[node]->property_fill_color_gdk().set_value(color);
  34.238 +    }
  34.239 +  return 0;
  34.240 +};
  34.241 +
  34.242 +int DigraphDisplayerCanvas::resetNodeColor (Node node)
  34.243 +{  
  34.244 +  MapStorage& ms = *mytab.mapstorage;
  34.245 +
  34.246 +  //function maps the range of the maximum and
  34.247 +  //the minimum of the nodemap to the range of
  34.248 +  //green in RGB
  34.249 +
  34.250 +  Digraph::NodeMap<double> actual_map(ms.digraph,node_property_defaults[N_COLOR]);
  34.251 +
  34.252 +  double max, min;
  34.253 +
  34.254 +  max=node_property_defaults[N_COLOR];
  34.255 +  min=node_property_defaults[N_COLOR];
  34.256 +
  34.257 +  if(node==INVALID)
  34.258 +    {
  34.259 +
  34.260 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  34.261 +	{
  34.262 +	  Gdk::Color color;
  34.263 +
  34.264 +	  double w=actual_map[i];
  34.265 +
  34.266 +	  if(max!=min)
  34.267 +	    {
  34.268 +	      color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
  34.269 +	    }
  34.270 +	  else
  34.271 +	    {
  34.272 +	      color.set_rgb_p (0, 0, 100);
  34.273 +	    }
  34.274 +
  34.275 +	  nodesmap[i]->property_fill_color_gdk().set_value(color);
  34.276 +	}
  34.277 +    }
  34.278 +  else
  34.279 +    {
  34.280 +      Gdk::Color color;
  34.281 +
  34.282 +      double w=actual_map[node];
  34.283 +
  34.284 +      if(max!=min)
  34.285 +	{
  34.286 +	  color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
  34.287 +	}
  34.288 +      else
  34.289 +	{
  34.290 +	  color.set_rgb_p (0, 0, 100);
  34.291 +	}
  34.292 +
  34.293 +      nodesmap[node]->property_fill_color_gdk().set_value(color);
  34.294 +    }
  34.295 +  return 0;
  34.296 +};
  34.297 +
  34.298 +int DigraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
  34.299 +{
  34.300 +  MapStorage& ms = *mytab.mapstorage;
  34.301 +
  34.302 +  //the number in the map will be written on the node
  34.303 +  //EXCEPT when the name of the map is Text, because
  34.304 +  //in that case empty string will be written, because
  34.305 +  //that is the deleter map
  34.306 +
  34.307 +  if(node==INVALID)
  34.308 +    {
  34.309 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  34.310 +	{
  34.311 +	  nodemap_to_edit=mapname;
  34.312 +
  34.313 +	  nodetextmap[i]->property_text().set_value(
  34.314 +              static_cast<std::string>(ms.get(mapname, i)));
  34.315 +	}
  34.316 +    }
  34.317 +  else
  34.318 +    {
  34.319 +      nodetextmap[node]->property_text().set_value(
  34.320 +          static_cast<std::string>(ms.get(mapname, node)));
  34.321 +    }
  34.322 +  return 0;
  34.323 +};
  34.324 +
  34.325 +int DigraphDisplayerCanvas::resetNodeText (Node node)
  34.326 +{
  34.327 +  MapStorage& ms = *mytab.mapstorage;
  34.328 +
  34.329 +  //the number in the map will be written on the node
  34.330 +  //EXCEPT when the name of the map is Text, because
  34.331 +  //in that case empty string will be written, because
  34.332 +  //that is the deleter map
  34.333 +
  34.334 +  if(node==INVALID)
  34.335 +    {
  34.336 +      for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  34.337 +	{
  34.338 +	  nodemap_to_edit="";
  34.339 +	  nodetextmap[i]->property_text().set_value("");
  34.340 +	}
  34.341 +    }
  34.342 +  else
  34.343 +    {
  34.344 +      nodetextmap[node]->property_text().set_value("");
  34.345 +    }
  34.346 +  return 0;
  34.347 +};
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/graph_displayer_canvas-zoom.cc	Mon Jul 07 08:10:39 2008 -0500
    35.3 @@ -0,0 +1,90 @@
    35.4 +/* -*- C++ -*-
    35.5 + *
    35.6 + * This file is a part of LEMON, a generic C++ optimization library
    35.7 + *
    35.8 + * Copyright (C) 2003-2006
    35.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   35.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   35.11 + *
   35.12 + * Permission to use, modify and distribute this software is granted
   35.13 + * provided that this copyright notice appears in all copies. For
   35.14 + * precise terms see the accompanying LICENSE file.
   35.15 + *
   35.16 + * This software is provided "AS IS" with no warranty of any kind,
   35.17 + * express or implied, and with no claim as to its suitability for any
   35.18 + * purpose.
   35.19 + *
   35.20 + */
   35.21 +
   35.22 +#include <graph_displayer_canvas.h>
   35.23 +#include <cmath>
   35.24 +
   35.25 +void DigraphDisplayerCanvas::zoomIn()
   35.26 +{
   35.27 +  set_pixels_per_unit(
   35.28 +      (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
   35.29 +  if(zoomtrack)
   35.30 +    {
   35.31 +      propertyChange(false, N_RADIUS);
   35.32 +      propertyChange(true, E_WIDTH);
   35.33 +    }
   35.34 +}
   35.35 +
   35.36 +void DigraphDisplayerCanvas::zoomOut()
   35.37 +{
   35.38 +  set_pixels_per_unit(
   35.39 +      (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
   35.40 +  if(zoomtrack)
   35.41 +    {
   35.42 +      propertyChange(true, E_WIDTH);
   35.43 +      propertyChange(false, N_RADIUS);
   35.44 +    }
   35.45 +}
   35.46 +
   35.47 +void DigraphDisplayerCanvas::zoomFit()
   35.48 +{
   35.49 +  updateScrollRegion();
   35.50 +
   35.51 +  // get the height and width of the canvas
   35.52 +  Gtk::Allocation a = get_allocation();
   35.53 +  int aw = a.get_width();
   35.54 +  int ah = a.get_height();
   35.55 +
   35.56 +  // get the bounding box of the digraph
   35.57 +  update_now();
   35.58 +  double x1, y1, x2, y2;
   35.59 +  root()->get_bounds(x1, y1, x2, y2);
   35.60 +
   35.61 +  // fit the digraph to the window
   35.62 +  double ppu1 = (double) aw / fabs(x2 - x1);
   35.63 +  double ppu2 = (double) ah / fabs(y2 - y1);
   35.64 +  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
   35.65 +
   35.66 +  if(zoomtrack)
   35.67 +    {
   35.68 +      propertyChange(true, E_WIDTH);
   35.69 +      propertyChange(false, N_RADIUS);
   35.70 +    }
   35.71 +}
   35.72 +
   35.73 +void DigraphDisplayerCanvas::zoom100()
   35.74 +{
   35.75 +  updateScrollRegion();
   35.76 +  set_pixels_per_unit(1.0);
   35.77 +
   35.78 +  if(zoomtrack)
   35.79 +    {
   35.80 +      propertyChange(true, E_WIDTH);
   35.81 +      propertyChange(false, N_RADIUS);
   35.82 +    }
   35.83 +}
   35.84 +
   35.85 +void DigraphDisplayerCanvas::updateScrollRegion()
   35.86 +{
   35.87 +  // get_bounds() yields something sane only when no updates are pending
   35.88 +  // and it returns a sufficient, not an exact bounding box
   35.89 +  update_now();
   35.90 +  double x1, y1, x2, y2;
   35.91 +  root()->get_bounds(x1, y1, x2, y2);
   35.92 +  set_scroll_region(x1, y1, x2, y2);
   35.93 +}
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/graph_displayer_canvas.cc	Mon Jul 07 08:10:39 2008 -0500
    36.3 @@ -0,0 +1,461 @@
    36.4 +/* -*- C++ -*-
    36.5 + *
    36.6 + * This file is a part of LEMON, a generic C++ optimization library
    36.7 + *
    36.8 + * Copyright (C) 2003-2006
    36.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   36.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   36.11 + *
   36.12 + * Permission to use, modify and distribute this software is granted
   36.13 + * provided that this copyright notice appears in all copies. For
   36.14 + * precise terms see the accompanying LICENSE file.
   36.15 + *
   36.16 + * This software is provided "AS IS" with no warranty of any kind,
   36.17 + * express or implied, and with no claim as to its suitability for any
   36.18 + * purpose.
   36.19 + *
   36.20 + */
   36.21 +
   36.22 +#include <mapstorage.h>
   36.23 +#include <nbtab.h>
   36.24 +#include <graph_displayer_canvas.h>
   36.25 +#include <lemon/random.h>
   36.26 +#include <cmath>
   36.27 +
   36.28 +DigraphDisplayerCanvas::DigraphDisplayerCanvas(NoteBookTab & mainw) :
   36.29 +  nodesmap(mainw.mapstorage->digraph), arcsmap(mainw.mapstorage->digraph), arctextmap(mainw.mapstorage->digraph),
   36.30 +  nodetextmap(mainw.mapstorage->digraph), displayed_graph(*(root()), 0, 0),
   36.31 +  isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
   36.32 +  arcmap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), arc_width(10),
   36.33 +  was_redesigned(false), is_drawn(false), mytab(mainw),
   36.34 +  background_set(false)
   36.35 +{
   36.36 +  //add mouse scroll event handler - it won't be changed, it handles zoom
   36.37 +  signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::scrollEventHandler), false);
   36.38 +
   36.39 +  //base event handler is move tool
   36.40 +  actual_handler=signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::moveEventHandler), false);
   36.41 +  actual_tool=MOVE;
   36.42 +
   36.43 +
   36.44 +  active_node=INVALID;
   36.45 +  active_arc=INVALID;
   36.46 +  forming_arc=INVALID;
   36.47 +
   36.48 +  setBackground();
   36.49 +}
   36.50 +
   36.51 +void DigraphDisplayerCanvas::setBackground()
   36.52 +{
   36.53 +  if (background_set)
   36.54 +  {
   36.55 +    delete background;
   36.56 +  }
   36.57 +  if (mytab.mapstorage->isBackgroundSet())
   36.58 +  {
   36.59 +    background_set = true;
   36.60 +    refBackground = Gdk::Pixbuf::create_from_file(
   36.61 +      mytab.mapstorage->getBackgroundFilename());
   36.62 +    background = new Gnome::Canvas::Pixbuf(
   36.63 +        *(root()),
   36.64 +        0.0 - refBackground->get_width() / 2.0,
   36.65 +        0.0 - refBackground->get_height() / 2.0,
   36.66 +        refBackground);
   36.67 +    background->lower_to_bottom();
   36.68 +  }
   36.69 +  else
   36.70 +  {
   36.71 +    background_set = false;
   36.72 +  }
   36.73 +}
   36.74 +
   36.75 +DigraphDisplayerCanvas::~DigraphDisplayerCanvas()
   36.76 +{
   36.77 +  for (NodeIt n((mytab.mapstorage)->digraph); n != INVALID; ++n)
   36.78 +    {
   36.79 +      delete nodesmap[n];
   36.80 +      delete nodetextmap[n];
   36.81 +    }
   36.82 +  
   36.83 +  for (ArcIt e((mytab.mapstorage)->digraph); e != INVALID; ++e)
   36.84 +    {
   36.85 +      delete arcsmap[e];
   36.86 +      delete arctextmap[e];
   36.87 +    }
   36.88 +}
   36.89 +
   36.90 +void DigraphDisplayerCanvas::propertyChange(bool itisarc, int prop)
   36.91 +{
   36.92 +  if(itisarc)
   36.93 +    {
   36.94 +      propertyUpdate(Arc(INVALID), prop);
   36.95 +    }
   36.96 +  else
   36.97 +    {
   36.98 +      propertyUpdate(Node(INVALID), prop);
   36.99 +    }
  36.100 +}
  36.101 +
  36.102 +void DigraphDisplayerCanvas::propertyUpdate(Arc arc)
  36.103 +{
  36.104 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  36.105 +    {
  36.106 +      propertyUpdate(arc, i);
  36.107 +    }
  36.108 +}
  36.109 +
  36.110 +void DigraphDisplayerCanvas::propertyUpdate(Node node)
  36.111 +{
  36.112 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  36.113 +    {
  36.114 +      propertyUpdate(node, i);
  36.115 +    }
  36.116 +}
  36.117 +
  36.118 +void DigraphDisplayerCanvas::propertyUpdate(Node node, int prop)
  36.119 +{
  36.120 +  std::string mapname=mytab.getActiveNodeMap(prop);
  36.121 +
  36.122 +  if(is_drawn)
  36.123 +  {
  36.124 +    if(mapname!="")
  36.125 +    {
  36.126 +      std::vector<std::string> nodemaps = mytab.mapstorage->getNodeMapList();
  36.127 +      bool found = false;
  36.128 +      for (std::vector<std::string>::const_iterator it = nodemaps.begin();
  36.129 +          it != nodemaps.end(); ++it)
  36.130 +      {
  36.131 +        if (*it == mapname)
  36.132 +        {
  36.133 +          found = true;
  36.134 +          break;
  36.135 +        }
  36.136 +      }
  36.137 +      if (found)
  36.138 +      {
  36.139 +        switch(prop)
  36.140 +        {
  36.141 +          case N_RADIUS:
  36.142 +            changeNodeRadius(mapname, node);
  36.143 +            break;
  36.144 +          case N_COLOR:
  36.145 +            changeNodeColor(mapname, node);
  36.146 +            break;
  36.147 +          case N_TEXT:
  36.148 +            changeNodeText(mapname, node);
  36.149 +            break;
  36.150 +          default:
  36.151 +            std::cerr<<"Error\n";
  36.152 +        }
  36.153 +      }
  36.154 +    }
  36.155 +    else //mapname==""
  36.156 +    {
  36.157 +      Node node=INVALID;
  36.158 +      switch(prop)
  36.159 +      {
  36.160 +        case N_RADIUS:
  36.161 +          resetNodeRadius(node);
  36.162 +          break;
  36.163 +        case N_COLOR:
  36.164 +          resetNodeColor(node);
  36.165 +          break;
  36.166 +        case N_TEXT:
  36.167 +          resetNodeText(node);
  36.168 +          break;
  36.169 +        default:
  36.170 +          std::cerr<<"Error\n";
  36.171 +      }
  36.172 +    }
  36.173 +  }
  36.174 +}
  36.175 +
  36.176 +void DigraphDisplayerCanvas::propertyUpdate(Arc arc, int prop)
  36.177 +{
  36.178 +  std::string mapname=mytab.getActiveArcMap(prop);
  36.179 +
  36.180 +  if(is_drawn)
  36.181 +  {
  36.182 +    if(mapname!="")
  36.183 +    {
  36.184 +      std::vector<std::string> arcmaps = mytab.mapstorage->getArcMapList();
  36.185 +      bool found = false;
  36.186 +      for (std::vector<std::string>::const_iterator it = arcmaps.begin();
  36.187 +          it != arcmaps.end(); ++it)
  36.188 +      {
  36.189 +        if (*it == mapname)
  36.190 +        {
  36.191 +          found = true;
  36.192 +          break;
  36.193 +        }
  36.194 +      }
  36.195 +      if (found)
  36.196 +      {
  36.197 +        switch(prop)
  36.198 +        {
  36.199 +          case E_WIDTH:
  36.200 +            changeArcWidth(mapname, arc);
  36.201 +            break;
  36.202 +          case E_COLOR:
  36.203 +            changeArcColor(mapname, arc);
  36.204 +            break;
  36.205 +          case E_TEXT:
  36.206 +            changeArcText(mapname, arc);
  36.207 +            break;
  36.208 +          default:
  36.209 +            std::cerr<<"Error\n";
  36.210 +        }
  36.211 +      }
  36.212 +    }
  36.213 +    else //mapname==""
  36.214 +    {
  36.215 +      switch(prop)
  36.216 +      {
  36.217 +        case E_WIDTH:
  36.218 +          resetArcWidth(arc);
  36.219 +          break;
  36.220 +        case E_COLOR:
  36.221 +          resetArcColor(arc);
  36.222 +          break;
  36.223 +        case E_TEXT:
  36.224 +          resetArcText(arc);
  36.225 +          break;
  36.226 +        default:
  36.227 +          std::cerr<<"Error\n";
  36.228 +      }
  36.229 +    }
  36.230 +  }
  36.231 +}
  36.232 +
  36.233 +void DigraphDisplayerCanvas::drawDigraph()
  36.234 +{
  36.235 +  //first arcs are drawn, to hide joining with nodes later
  36.236 +
  36.237 +  for (ArcIt i((mytab.mapstorage)->digraph); i!=INVALID; ++i)
  36.238 +  {
  36.239 +    if (mytab.mapstorage->digraph.source(i) == mytab.mapstorage->digraph.target(i))
  36.240 +    {
  36.241 +      arcsmap[i]=new LoopArc(displayed_graph, i, *this);
  36.242 +    }
  36.243 +    else
  36.244 +    {
  36.245 +      arcsmap[i]=new BrokenArc(displayed_graph, i, *this);
  36.246 +    }
  36.247 +    //initializing arc-text as well, to empty string
  36.248 +
  36.249 +    XY text_pos=mytab.mapstorage->getArrowCoords(i);
  36.250 +    text_pos+=(XY(10,10));
  36.251 +
  36.252 +    arctextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
  36.253 +    arctextmap[i]->property_fill_color().set_value("darkgreen");
  36.254 +    arctextmap[i]->signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::mapEditEventHandler), false);
  36.255 +    arctextmap[i]->raise_to_top();
  36.256 +  }
  36.257 +
  36.258 +  //afterwards nodes come to be drawn
  36.259 +
  36.260 +  for (NodeIt i((mytab.mapstorage)->digraph); i!=INVALID; ++i)
  36.261 +  {
  36.262 +    //drawing bule nodes, with black line around them
  36.263 +
  36.264 +    nodesmap[i]=new Gnome::Canvas::Ellipse(
  36.265 +        displayed_graph,
  36.266 +        mytab.mapstorage->getNodeCoords(i).x-20,
  36.267 +        mytab.mapstorage->getNodeCoords(i).y-20,
  36.268 +        mytab.mapstorage->getNodeCoords(i).x+20,
  36.269 +        mytab.mapstorage->getNodeCoords(i).y+20);
  36.270 +    *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
  36.271 +    *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
  36.272 +    nodesmap[i]->raise_to_top();
  36.273 +
  36.274 +    //initializing arc-text as well, to empty string
  36.275 +
  36.276 +    XY text_pos(
  36.277 +        (mytab.mapstorage->getNodeCoords(i).x+node_property_defaults[N_RADIUS]+5),
  36.278 +        (mytab.mapstorage->getNodeCoords(i).y+node_property_defaults[N_RADIUS]+5));
  36.279 +
  36.280 +    nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
  36.281 +        text_pos.x, text_pos.y, "");
  36.282 +    nodetextmap[i]->property_fill_color().set_value("darkblue");
  36.283 +    nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &DigraphDisplayerCanvas::mapEditEventHandler), false);
  36.284 +    nodetextmap[i]->raise_to_top();
  36.285 +  }
  36.286 +
  36.287 +  is_drawn=true;
  36.288 +
  36.289 +  //upon drawing digraph
  36.290 +  //properties have to
  36.291 +  //be set in as well
  36.292 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  36.293 +    {
  36.294 +      propertyUpdate(Node(INVALID), i);
  36.295 +    }
  36.296 +
  36.297 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  36.298 +    {
  36.299 +      propertyUpdate(Arc(INVALID), i);
  36.300 +    }
  36.301 +
  36.302 +  updateScrollRegion();
  36.303 +}
  36.304 +
  36.305 +void DigraphDisplayerCanvas::clear()
  36.306 +{
  36.307 +  active_node=INVALID;
  36.308 +  active_arc=INVALID;
  36.309 +  forming_arc=INVALID;
  36.310 +
  36.311 +  for (NodeIt n((mytab.mapstorage)->digraph); n != INVALID; ++n)
  36.312 +  {
  36.313 +    delete nodesmap[n];
  36.314 +    delete nodetextmap[n];
  36.315 +  }
  36.316 +
  36.317 +  for (ArcIt e((mytab.mapstorage)->digraph); e != INVALID; ++e)
  36.318 +  {
  36.319 +    delete arcsmap[e];
  36.320 +    delete arctextmap[e];
  36.321 +  }
  36.322 +
  36.323 +  is_drawn=false;
  36.324 +}
  36.325 +
  36.326 +void DigraphDisplayerCanvas::setView(bool autoscale_p, bool zoomtrack_p, double width_p, double radius_p)
  36.327 +{
  36.328 +  autoscale=autoscale_p;
  36.329 +  arc_width=width_p;
  36.330 +  radius_size=radius_p;
  36.331 +
  36.332 +  if((!zoomtrack) && zoomtrack_p)
  36.333 +    {
  36.334 +      fixed_zoom_factor=get_pixels_per_unit();
  36.335 +    }
  36.336 +
  36.337 +  zoomtrack=zoomtrack_p;
  36.338 +
  36.339 +  propertyChange(false, N_RADIUS);
  36.340 +  propertyChange(true, E_WIDTH);
  36.341 +}
  36.342 +
  36.343 +void DigraphDisplayerCanvas::getView(bool & autoscale_p, bool & zoomtrack_p, double& width_p, double& radius_p)
  36.344 +{
  36.345 +  autoscale_p=autoscale;
  36.346 +  zoomtrack_p=zoomtrack;
  36.347 +  width_p=arc_width;
  36.348 +  radius_p=radius_size;
  36.349 +}
  36.350 +
  36.351 +void DigraphDisplayerCanvas::reDesignDigraph()
  36.352 +{
  36.353 +  MapStorage& ms = *mytab.mapstorage;
  36.354 +  NodeIt firstnode(ms.digraph);
  36.355 +  //is it not an empty digraph?
  36.356 +  if(firstnode!=INVALID)
  36.357 +    {
  36.358 +      double max_coord=50000;
  36.359 +      double min_dist=20;
  36.360 +      double init_vector_length=25;
  36.361 +
  36.362 +      if(!was_redesigned)
  36.363 +	{
  36.364 +	  NodeIt i(ms.digraph);
  36.365 +
  36.366 +	  dim2::Point<double> init(init_vector_length*rnd(),
  36.367 +				   init_vector_length*rnd());
  36.368 +	  moveNode(init.x, init.y, nodesmap[i], i);
  36.369 +	  was_redesigned=true;
  36.370 +	}
  36.371 +
  36.372 +      double attraction;
  36.373 +      double propulsation;
  36.374 +      int iterations;
  36.375 +
  36.376 +      ms.get_design_data(attraction, propulsation, iterations);
  36.377 +
  36.378 +      //iteration counter
  36.379 +      for(int l=0;l<iterations;l++)
  36.380 +	{
  36.381 +	  Digraph::NodeMap<double> x(ms.digraph);
  36.382 +	  Digraph::NodeMap<double> y(ms.digraph);
  36.383 +	  XYMap<Digraph::NodeMap<double> > actual_forces;
  36.384 +	  actual_forces.setXMap(x);
  36.385 +	  actual_forces.setYMap(y);
  36.386 +
  36.387 +	  //count actual force for each nodes
  36.388 +	  for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  36.389 +	    {
  36.390 +	      //propulsation of nodes
  36.391 +	      for (NodeIt j(ms.digraph); j!=INVALID; ++j)
  36.392 +		{
  36.393 +		  if(i!=j)
  36.394 +		    {
  36.395 +		      lemon::dim2::Point<double> delta =
  36.396 +			(ms.getNodeCoords(i)-
  36.397 +			 ms.getNodeCoords(j));
  36.398 +
  36.399 +		      const double length_sqr=std::max(delta.normSquare(),min_dist);
  36.400 +
  36.401 +		      //normalize vector
  36.402 +		      delta/=sqrt(length_sqr);
  36.403 +
  36.404 +		      //calculating propulsation strength
  36.405 +		      //greater distance menas smaller propulsation strength
  36.406 +		      delta*=propulsation/length_sqr;
  36.407 +		    
  36.408 +		      actual_forces.set(i,(actual_forces[i]+delta));
  36.409 +		    }
  36.410 +		}
  36.411 +            //attraction of nodes, to which actual node is bound
  36.412 +            for(OutArcIt ei(ms.digraph,i);ei!=INVALID;++ei)
  36.413 +              {
  36.414 +                lemon::dim2::Point<double> delta =
  36.415 +                  (ms.getNodeCoords(i)-
  36.416 +                   ms.getNodeCoords(ms.digraph.target(ei)));
  36.417 +
  36.418 +                //calculating attraction strength
  36.419 +                //greater distance means greater strength
  36.420 +                delta*=attraction;
  36.421 +
  36.422 +                actual_forces.set(i,actual_forces[i]-delta);
  36.423 +              }
  36.424 +                    for(InArcIt ei(ms.digraph,i);ei!=INVALID;++ei)
  36.425 +              {
  36.426 +                lemon::dim2::Point<double> delta =
  36.427 +                  (ms.getNodeCoords(i)-
  36.428 +                   ms.getNodeCoords(ms.digraph.source(ei)));
  36.429 +
  36.430 +                //calculating attraction strength
  36.431 +                //greater distance means greater strength
  36.432 +                delta*=attraction;
  36.433 +
  36.434 +                actual_forces.set(i,actual_forces[i]-delta);
  36.435 +              }
  36.436 +	    }
  36.437 +	  for (NodeIt i(ms.digraph); i!=INVALID; ++i)
  36.438 +	    {
  36.439 +	      if((ms.getNodeCoords(i).x)+actual_forces[i].x>max_coord)
  36.440 +		{
  36.441 +		  actual_forces[i].x=max_coord-(ms.getNodeCoords(i).x);
  36.442 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
  36.443 +		}
  36.444 +	      else if((ms.getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
  36.445 +		{
  36.446 +		  actual_forces[i].x=0-max_coord-(ms.getNodeCoords(i).x);
  36.447 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
  36.448 +		}
  36.449 +	      if((ms.getNodeCoords(i).y)+actual_forces[i].y>max_coord)
  36.450 +		{
  36.451 +		  actual_forces[i].y=max_coord-(ms.getNodeCoords(i).y);
  36.452 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
  36.453 +		}
  36.454 +	      else if((ms.getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
  36.455 +		{
  36.456 +		  actual_forces[i].y=0-max_coord-(ms.getNodeCoords(i).y);
  36.457 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
  36.458 +		}
  36.459 +	      moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
  36.460 +	    }
  36.461 +	}
  36.462 +    }
  36.463 +}
  36.464 +
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/graph_displayer_canvas.h	Mon Jul 07 08:10:39 2008 -0500
    37.3 @@ -0,0 +1,452 @@
    37.4 +/* -*- C++ -*-
    37.5 + *
    37.6 + * This file is a part of LEMON, a generic C++ optimization library
    37.7 + *
    37.8 + * Copyright (C) 2003-2006
    37.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   37.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   37.11 + *
   37.12 + * Permission to use, modify and distribute this software is granted
   37.13 + * provided that this copyright notice appears in all copies. For
   37.14 + * precise terms see the accompanying LICENSE file.
   37.15 + *
   37.16 + * This software is provided "AS IS" with no warranty of any kind,
   37.17 + * express or implied, and with no claim as to its suitability for any
   37.18 + * purpose.
   37.19 + *
   37.20 + */
   37.21 +
   37.22 +#ifndef GRAPH_DISPLAYER_CANVAS_H
   37.23 +#define GRAPH_DISPLAYER_CANVAS_H
   37.24 +
   37.25 +class NoteBookTab;
   37.26 +
   37.27 +#include "all_include.h"
   37.28 +#include <libgnomecanvasmm.h>
   37.29 +#include <libgnomecanvasmm/polygon.h>
   37.30 +
   37.31 +///This class is the canvas, on which the digraph can be drawn.
   37.32 +class DigraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
   37.33 +{
   37.34 +  friend class BrokenArc;
   37.35 +  friend class LoopArc;
   37.36 +
   37.37 +  class ArcBase : public Gnome::Canvas::Group
   37.38 +  {
   37.39 +    protected:
   37.40 +      ///Reference to the canvas, on which the digraph is drawn.
   37.41 +
   37.42 +      ///It is needed, because some datas needed from
   37.43 +      ///digraph can be accessed by this or should be sent
   37.44 +      ///as parameter, but it would be complicated
   37.45 +      DigraphDisplayerCanvas& canvas;
   37.46 +
   37.47 +      ///The arc that the class displays.
   37.48 +
   37.49 +      ///It is needed, because some datas needed from
   37.50 +      ///digraph can be accessed by this or should be sent
   37.51 +      ///as parameter, but it would be complicated
   37.52 +      Arc arc;
   37.53 +
   37.54 +      Gnome::Canvas::Polygon arrow;
   37.55 +
   37.56 +      void drawArrow(XY);
   37.57 +    public:
   37.58 +      ArcBase(Gnome::Canvas::Group&, Arc, DigraphDisplayerCanvas&);
   37.59 +      virtual ~ArcBase();
   37.60 +      virtual void draw() = 0;
   37.61 +      virtual void setLineWidth(int) = 0;
   37.62 +      virtual void setFillColor(Gdk::Color) = 0;
   37.63 +      virtual Gnome::Canvas::Item * getLine() = 0;
   37.64 +  };
   37.65 +
   37.66 +  ///Arc displayer class
   37.67 +
   37.68 +  ///This class is responsible for displaying arcs in digraph.
   37.69 +  ///The displayed arc is broken in the middle. The
   37.70 +  ///aim of this is to be able to indicate direction of arcs
   37.71 +  ///and to be able to display more then one arcs between the
   37.72 +  ///same source and target
   37.73 +  class BrokenArc : public ArcBase
   37.74 +  {
   37.75 +    private:
   37.76 +      Gnome::Canvas::Line line;
   37.77 +
   37.78 +      ///Indicates whether the button of mouse is pressed or not at the moment.
   37.79 +      bool isbutton;
   37.80 +
   37.81 +      ///At this location was the mousebutton pressed. Horizontal component.
   37.82 +
   37.83 +      ///It helps to calculate the
   37.84 +      ///distance of dragging.
   37.85 +      double clicked_x;
   37.86 +
   37.87 +      ///At this location was the mousebutton pressed. Vertical component.
   37.88 +
   37.89 +      ///It helps to calculate the
   37.90 +      ///distance of dragging.
   37.91 +      double clicked_y;
   37.92 +
   37.93 +      ///event handler for forming broken arcs
   37.94 +
   37.95 +      ///\param event the
   37.96 +      ///event to handle
   37.97 +      bool arcFormerEventHandler(GdkEvent* event);
   37.98 +
   37.99 +    public:
  37.100 +      ///Constructor of broken arc class.
  37.101 +
  37.102 +      ///\param g the group to which the arc belongs
  37.103 +      ///\param _arc the represented arc
  37.104 +      ///\param gc the canvas
  37.105 +      BrokenArc(Gnome::Canvas::Group&, Arc, DigraphDisplayerCanvas&);
  37.106 +
  37.107 +      ///Destructor of broken arc class
  37.108 +
  37.109 +      ///Frees up
  37.110 +      ///reserved memory
  37.111 +      ~BrokenArc();
  37.112 +
  37.113 +      ///The function that draws the arc based on collected data
  37.114 +      void draw();
  37.115 +
  37.116 +      void setLineWidth(int);
  37.117 +      void setFillColor(Gdk::Color);
  37.118 +
  37.119 +      Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
  37.120 +  };
  37.121 +
  37.122 +  class LoopArc : public ArcBase
  37.123 +  {
  37.124 +    private:
  37.125 +      Gnome::Canvas::Ellipse line;
  37.126 +      bool arcFormerEventHandler(GdkEvent* e);
  37.127 +      bool isbutton;
  37.128 +    public:
  37.129 +      LoopArc(Gnome::Canvas::Group&, Arc, DigraphDisplayerCanvas&);
  37.130 +      ~LoopArc();
  37.131 +      void draw();
  37.132 +      void setLineWidth(int);
  37.133 +      void setFillColor(Gdk::Color);
  37.134 +      Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
  37.135 +  };
  37.136 +
  37.137 +  ///Type of canvas, on which the digraph is drawn
  37.138 +  typedef Gnome::Canvas::CanvasAA Parent;
  37.139 +
  37.140 +public:
  37.141 +  ///Constructor
  37.142 +
  37.143 +  ///\param nbt the tab of the window, in which the digraph is displayed
  37.144 +  DigraphDisplayerCanvas(NoteBookTab & nbt);
  37.145 +
  37.146 +  ///destructor of the class
  37.147 +  virtual ~DigraphDisplayerCanvas();
  37.148 +
  37.149 +  ///Returns a color of the rainbow based on a map value and the min and max value of the given map
  37.150 +
  37.151 +  ///min and max is purple, between them there is a linear assign
  37.152 +  Gdk::Color rainbowColorCounter(double, double, double);
  37.153 +
  37.154 +  ///Changes the width of arc(s) according to the given map.
  37.155 +
  37.156 +  ///\param mapname is the name of the map which contains the values to be set
  37.157 +  ///\param arc if it is given, only the width of the given arc will be set, instead of all of them.
  37.158 +  int changeArcWidth (std::string mapname, Arc arc=INVALID);
  37.159 +
  37.160 +  ///Resets width of arc(s) to the default value
  37.161 +
  37.162 +  ///\param arc if it is given, only the width of the
  37.163 +  ///given arc will be reset, instead of all of them.
  37.164 +  int resetArcWidth (Arc arc=INVALID);
  37.165 +
  37.166 +  ///Changes the color of arc(s) according to the given map.
  37.167 +
  37.168 +  ///\param mapname is the name of the map which contains the new values
  37.169 +  ///\param arc if it is given, only the color of the given arc will be set, instead of all of them.
  37.170 +  int changeArcColor (std::string mapname, Arc arc=INVALID);
  37.171 +
  37.172 +  ///Resets color of arc(s) to the default value
  37.173 +
  37.174 +  ///\param arc if it is given, only the color of the
  37.175 +  ///given arc will be reset, instead of all of them.
  37.176 +  int resetArcColor (Arc arc=INVALID);
  37.177 +
  37.178 +  ///Changes the label of arc(s) according to the given map.
  37.179 +
  37.180 +  ///\param mapname is the name of the map which contains the new values
  37.181 +  ///\param arc if it is given, only the label of the given arc will be set, instead of all of them.
  37.182 +  int changeArcText (std::string mapname, Arc arc=INVALID);
  37.183 +
  37.184 +  ///Resets label of arc(s) to the default value
  37.185 +
  37.186 +  ///\param arc if it is given, only the color of the
  37.187 +  ///given arc will be reset, instead of all of them.
  37.188 +  int resetArcText (Arc arc=INVALID);
  37.189 +
  37.190 +  ///Changes the radius of node(s) according to the given map.
  37.191 +
  37.192 +  ///\param mapname is the name of the map which contains the new values
  37.193 +  ///\param node if it is given, only the radius of the given node will be set, instead of all of them.
  37.194 +  int changeNodeRadius (std::string mapname, Node node=INVALID);
  37.195 +
  37.196 +  ///Resets radius of node(s) to the default value
  37.197 +
  37.198 +  ///\param node if it is given, only the radius of the
  37.199 +  ///given node will be reset, instead of all of them.
  37.200 +  int resetNodeRadius (Node node=INVALID);
  37.201 +
  37.202 +  ///Changes the color of node(s) according to the given map.
  37.203 +
  37.204 +  ///\param mapname is the name of the map which contains the new values
  37.205 +  ///\param node if it is given, only the color of the given node will be set, instead of all of them.
  37.206 +  int changeNodeColor (std::string mapname, Node node=INVALID);
  37.207 +
  37.208 +  ///Resets color of node(s) to the default value
  37.209 +
  37.210 +  ///\param node if it is given, only the color of the
  37.211 +  ///given node will be reset, instead of all of them.
  37.212 +  int resetNodeColor (Node node=INVALID);
  37.213 +
  37.214 +  ///Changes the label of node(s) according to the given map.
  37.215 +
  37.216 +  ///\param mapname is the name of the map which contains the new values
  37.217 +  ///\param node if it is given, only the label of the given node will be set, instead of all of them.
  37.218 +  int changeNodeText (std::string mapname, Node node=INVALID);
  37.219 +
  37.220 +  ///Resets label of node(s) to the default value
  37.221 +
  37.222 +  ///\param node if it is given, only the label of the
  37.223 +  ///given node will be reset, instead of all of them.
  37.224 +  int resetNodeText (Node node=INVALID);
  37.225 +
  37.226 +  ///This function is called, when any of the displayed attributes have to be updated, or changed
  37.227 +
  37.228 +  ///\param itisarc if true, arc property has to be changed, else node property
  37.229 +  ///\param prop the id of property that has to changed or updated
  37.230 +  void propertyChange(bool itisarc, int prop);
  37.231 +
  37.232 +  ///updates the given property
  37.233 +
  37.234 +  ///\param arc if it is not INVALID, only the property of the given arc will be updated, instead of all of them
  37.235 +  ///\param prop the property to update
  37.236 +  void propertyUpdate(Arc arc, int prop);
  37.237 +
  37.238 +  ///updates the given property
  37.239 +
  37.240 +  ///\param node if it is not INVALID, only the property of the given node will be updated, instead of all of them
  37.241 +  ///\param prop the property to update
  37.242 +  void propertyUpdate(Node node, int prop);
  37.243 +
  37.244 +  ///updates all the property for the given arc
  37.245 +  void propertyUpdate(Arc);
  37.246 +
  37.247 +  ///updates all the property for the given node
  37.248 +  void propertyUpdate(Node);
  37.249 +
  37.250 +  ///Callback for 'ViewZoomIn' action.
  37.251 +  virtual void zoomIn();
  37.252 +  ///Callback for 'ViewZoomOut' action.
  37.253 +  virtual void zoomOut();
  37.254 +  ///Callback for 'ViewZoomFit' action.
  37.255 +  virtual void zoomFit();
  37.256 +  ///Callback for 'ViewZoom100' action.
  37.257 +  virtual void zoom100();
  37.258 +  ///Sets the scroll region of the convas to the bounding box of the digraph.
  37.259 +  void updateScrollRegion();
  37.260 +
  37.261 +  ///This function changes the tool in the digraph-editor's hand
  37.262 +  void changeEditorialTool(int);
  37.263 +
  37.264 +protected:
  37.265 +
  37.266 +  //maximizing, minimizing, restoring window, etc.
  37.267 +  virtual bool on_expose_event(GdkEventExpose *);
  37.268 +
  37.269 +private:
  37.270 +
  37.271 +  ///This function is responsible for the correct
  37.272 +  ///reaction of any action happened in the territory
  37.273 +  ///of the canvas
  37.274 +  ///DEPRECATED!!!!
  37.275 +  bool eventHandler(GdkEvent* e, Node n);
  37.276 +
  37.277 +  ///actual event handler
  37.278 +  ///
  37.279 +  ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
  37.280 +  sigc::connection actual_handler;
  37.281 +
  37.282 +  ///event handler for the case when move-tool is active
  37.283 +  bool moveEventHandler(GdkEvent*);
  37.284 +  ///event handler for the case when create_node-tool is active
  37.285 +  bool createNodeEventHandler(GdkEvent*);
  37.286 +  ///event handler for the case when create_arc-tool is active
  37.287 +  bool createArcEventHandler(GdkEvent*);
  37.288 +  ///event handler for the case when eraser-tool is active
  37.289 +  bool eraserEventHandler(GdkEvent*);
  37.290 +  ///event handler for the case when map editor tool is active
  37.291 +  bool mapEditEventHandler(GdkEvent*);
  37.292 +  ///event handler for the case when user scrolls the mouse
  37.293 +  bool scrollEventHandler(GdkEvent*);
  37.294 +
  37.295 +private:
  37.296 +  ///moves node according to the given parameters
  37.297 +  void moveNode(double, double,  Gnome::Canvas::Item * item=NULL, Node node=INVALID);
  37.298 +
  37.299 +public:
  37.300 +  ///Moves the text to new place
  37.301 +  void textReposition(XY);
  37.302 +
  37.303 +  ///Activates an arc belonging to an ArcBase
  37.304 +
  37.305 +  ///After we have activated an arc this way,
  37.306 +  ///the GDC object will know, which arc is under forming
  37.307 +  ///therefore it can redraw the necessary elements on the canvas,
  37.308 +  ///for example the text belonging to the \ref ArcBase can be
  37.309 +  ///redrawn (\ref textReposition).
  37.310 +  void toggleArcActivity(ArcBase*, bool);
  37.311 +
  37.312 +public:
  37.313 +
  37.314 +  ///Returns the actual tool in hand
  37.315 +  int getActualTool();
  37.316 +
  37.317 +  ///Sets node representation settings
  37.318 +  void setView(bool, bool, double, double);
  37.319 +
  37.320 +  ///Gets node representation settings
  37.321 +  void getView(bool &, bool &, double&, double&);
  37.322 +
  37.323 +  ///draws the digraph
  37.324 +
  37.325 +  ///Called when opening a file.
  37.326 +  void drawDigraph();
  37.327 +
  37.328 +  ///Clears the canvas
  37.329 +
  37.330 +  ///It achieves this by deleting all data
  37.331 +  ///structure used to help handle the displayed digraph.
  37.332 +  void clear();
  37.333 +
  37.334 +  ///creates a new Nodemap
  37.335 +
  37.336 +  ///\param init initial value of the map
  37.337 +  ///\param mapname name of new map
  37.338 +  int addNewNodeMap(double init,std::string mapname);
  37.339 +  ///creates a new Arcmap
  37.340 +
  37.341 +  ///\param init initial value of the map
  37.342 +  ///\param mapname name of new map
  37.343 +  int addNewArcMap(double init,std::string mapname);
  37.344 +
  37.345 +  void reDesignDigraph();
  37.346 +
  37.347 +  ///Show whether the digraph is already drawn.
  37.348 +  bool is_drawn;
  37.349 +
  37.350 +private:
  37.351 +  ///Deletes the given element.
  37.352 +  void deleteItem(Node);
  37.353 +  ///Deletes the given element.
  37.354 +  void deleteItem(Arc);
  37.355 +
  37.356 +private:
  37.357 +
  37.358 +  ///Map of nodes of digraph
  37.359 +  Digraph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
  37.360 +
  37.361 +  ///Map of arcs of digraph
  37.362 +  Digraph::ArcMap<ArcBase*> arcsmap;
  37.363 +
  37.364 +  ///Map of texts to write on arcs
  37.365 +  Digraph::ArcMap<Gnome::Canvas::Text *> arctextmap;
  37.366 +
  37.367 +  ///Map of texts to write on nodes
  37.368 +  Digraph::NodeMap<Gnome::Canvas::Text *> nodetextmap;
  37.369 +
  37.370 +  ///Group of digraphical elements of displayed_graph
  37.371 +  Gnome::Canvas::Group displayed_graph;
  37.372 +
  37.373 +private:
  37.374 +  ///Indicates whether the button of mouse is pressed or not
  37.375 +  int isbutton;
  37.376 +
  37.377 +  ///Stores the actual tool in hand
  37.378 +  int actual_tool;
  37.379 +
  37.380 +  ///At this location was the mousebutton pressed.
  37.381 +  ///It helps to calculate the distance of dragging.
  37.382 +  double clicked_x, clicked_y;
  37.383 +
  37.384 +  ///Remembers which Gnome::Canvas::Item was pressed.
  37.385 +
  37.386 +  ///this variable is needed, to work on it after selection
  37.387 +  Gnome::Canvas::Item * active_item;
  37.388 +
  37.389 +  ///Remembers which Gnome::Canvas::Item was pressed.
  37.390 +
  37.391 +  ///this variable is used at arc creation, it will
  37.392 +  ///be the secondly selected node. No local variable
  37.393 +  ///can be used for this purpose inside the function,
  37.394 +  ///because the node selected by button press, and
  37.395 +  ///the arc is created by button release. Both of
  37.396 +  ///them is different function call.
  37.397 +  Gnome::Canvas::Item * target_item;
  37.398 +
  37.399 +  ///selected node (for any editing)
  37.400 +  Node active_node;
  37.401 +
  37.402 +  ///selected arc (for any editing)
  37.403 +  Arc active_arc;
  37.404 +
  37.405 +  ///the arc that is selected by clicking on the red arrow in the middle of it
  37.406 +
  37.407 +  ///This arc is stored only for the purpose of reshape it.
  37.408 +  ///That is why it is selected in a different manner.
  37.409 +  Arc forming_arc;
  37.410 +
  37.411 +  ///Map displayed by label can be edited.
  37.412 +  std::string nodemap_to_edit;
  37.413 +
  37.414 +  ///Map displayed by label can be edited.
  37.415 +  std::string arcmap_to_edit;
  37.416 +
  37.417 +  static const int zoom_step = 5;
  37.418 +
  37.419 +  ///Is node radius autoscaled
  37.420 +  bool autoscale;
  37.421 +  
  37.422 +  ///Should we track zoomfactor changes
  37.423 +  bool zoomtrack;
  37.424 +
  37.425 +  ///to store the zoom factor when it was "fixed"
  37.426 +  double fixed_zoom_factor;
  37.427 +  
  37.428 +  ///Node radius size
  37.429 +  double radius_size;
  37.430 +
  37.431 +  ///Arc width
  37.432 +  double arc_width;
  37.433 +
  37.434 +  ///Was redesign run on this digraph already?
  37.435 +  ///
  37.436 +  ///If not, the layout will be modified randomly
  37.437 +  ///to avoid frozen layout because of wrong
  37.438 +  ///initial state
  37.439 +  bool was_redesigned;
  37.440 +  
  37.441 +private:
  37.442 +
  37.443 +  ///reference to the container, in which the canvas is
  37.444 +  NoteBookTab & mytab;
  37.445 +
  37.446 +  XY calcArrowPos(XY, XY, XY, XY, int);
  37.447 +
  37.448 +  bool background_set;
  37.449 +  Glib::RefPtr<Gdk::Pixbuf> refBackground;
  37.450 +  Gnome::Canvas::Pixbuf *background;
  37.451 +public:
  37.452 +  void setBackground();
  37.453 +};
  37.454 +
  37.455 +#endif //GRAPH_DISPLAYER_CANVAS_H
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/graphocska.lgf	Mon Jul 07 08:10:39 2008 -0500
    38.3 @@ -0,0 +1,39 @@
    38.4 +@nodes
    38.5 +label	coordinates_x	coordinates_y data
    38.6 +1	230	-80	1.123
    38.7 +2	230	100	3.234
    38.8 +3	120	-80	5.345
    38.9 +4	120	100	7.456
   38.10 +5	20	100	9.567
   38.11 +6	20	-80	11.678
   38.12 +7	-40	10	13.789
   38.13 +8	-100	100	15.890
   38.14 +9	-100	10	17.901
   38.15 +10	-100	-80	19.012
   38.16 +11	-200	-80	21.000
   38.17 +12	-200	10	23.001
   38.18 +13	-200	100	25.003
   38.19 +14	-300	100	27.004
   38.20 +15	-300	-80	29.9999
   38.21 +
   38.22 +@arcs
   38.23 +	        label	map1	map2	map3	map4
   38.24 +15	14	1	21	111	231	3
   38.25 +14	13	2	22	112	232	6
   38.26 +13	12	3	23	113	233	9
   38.27 +13	8	4	24	114	234	12
   38.28 +12	11	5	25	115	235	15
   38.29 +12	9	6	26	116	236	18
   38.30 +11	10	7	27	117	237	21
   38.31 +10	9	8	28	118	238	24
   38.32 +10	7	9	29	119	239	27
   38.33 +9	8	10	30	120	230	30
   38.34 +7	6	11	31	121	241	33
   38.35 +6	5	12	32	122	242	36
   38.36 +6	3	13	33	123	243	39
   38.37 +5	4	14	34	124	244	42
   38.38 +4	3	15	35	125	245	45
   38.39 +3	2	16	36	126	246	48
   38.40 +2	1	17	37	127	247	51
   38.41 +
   38.42 +@end
   38.43 \ No newline at end of file
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/gui_reader.cc	Mon Jul 07 08:10:39 2008 -0500
    39.3 @@ -0,0 +1,194 @@
    39.4 +/* -*- C++ -*-
    39.5 + *
    39.6 + * This file is a part of LEMON, a generic C++ optimization library
    39.7 + *
    39.8 + * Copyright (C) 2003-2006
    39.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   39.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   39.11 + *
   39.12 + * Permission to use, modify and distribute this software is granted
   39.13 + * provided that this copyright notice appears in all copies. For
   39.14 + * precise terms see the accompanying LICENSE file.
   39.15 + *
   39.16 + * This software is provided "AS IS" with no warranty of any kind,
   39.17 + * express or implied, and with no claim as to its suitability for any
   39.18 + * purpose.
   39.19 + *
   39.20 + */
   39.21 +
   39.22 +#include <gui_reader.h>
   39.23 +#include <mapstorage.h>
   39.24 +
   39.25 +#include <xml.h>
   39.26 +#include "io_helper.h"
   39.27 +#include <lemon/dim2.h>
   39.28 +#include <vector>
   39.29 +
   39.30 +// bool GuiReader::header(const std::string& line)
   39.31 +// {
   39.32 +//   std::istringstream ls(line);
   39.33 +//   std::string head;
   39.34 +//   ls >> head;
   39.35 +//   return head == "@gui";
   39.36 +// }
   39.37 +
   39.38 +//void GuiReader::read(std::istream& is)
   39.39 +void GuiReader::operator()(std::istream& is, int& ln)
   39.40 +{
   39.41 +  using std::vector;
   39.42 +  using std::string;
   39.43 +  using std::pair;
   39.44 +  using std::make_pair;
   39.45 +  using std::string;
   39.46 +  using std::map;
   39.47 +
   39.48 +  XmlIo x(is);
   39.49 +
   39.50 +  { x("main_node_map_names", gui_data.main_node_map_names); }
   39.51 +  { x("gui_node_map_names", gui_data.gui_node_map_names); }
   39.52 +
   39.53 +  { x("node_map_types", gui_data.node_map_types); }
   39.54 +
   39.55 +  { x("main_arc_map_names", gui_data.main_arc_map_names); }
   39.56 +  { x("gui_arc_map_names", gui_data.gui_arc_map_names); }
   39.57 +
   39.58 +  { x("arc_map_types", gui_data.arc_map_types); }
   39.59 +
   39.60 +  for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin();
   39.61 +      it != gui_data.gui_node_map_names.end(); ++it)
   39.62 +  {
   39.63 +    MapValue::Type type = gui_data.node_map_types[*it];
   39.64 +    switch (type)
   39.65 +    {
   39.66 +      case MapValue::NUMERIC:
   39.67 +        {
   39.68 +          map<int, double>* p_map_data =
   39.69 +            new map<int, double>;
   39.70 +          gui_data.numeric_node_maps[*it] = p_map_data;
   39.71 +          { x(*it, *p_map_data); }
   39.72 +        }
   39.73 +        break;
   39.74 +      case MapValue::STRING:
   39.75 +        {
   39.76 +          map<int, string>* p_map_data =
   39.77 +            new map<int, string>;
   39.78 +          gui_data.string_node_maps[*it] = p_map_data;
   39.79 +          { x(*it, *p_map_data); }
   39.80 +        }
   39.81 +        break;
   39.82 +    }
   39.83 +  }
   39.84 +
   39.85 +  for (vector<string>::const_iterator it = gui_data.gui_arc_map_names.begin();
   39.86 +      it != gui_data.gui_arc_map_names.end(); ++it)
   39.87 +  {
   39.88 +    MapValue::Type type = gui_data.arc_map_types[*it];
   39.89 +    switch (type)
   39.90 +    {
   39.91 +      case MapValue::NUMERIC:
   39.92 +        {
   39.93 +          map<int, double>* p_map_data =
   39.94 +            new map<int, double>;
   39.95 +          gui_data.numeric_arc_maps[*it] = p_map_data;
   39.96 +          { x(*it, *p_map_data); }
   39.97 +        }
   39.98 +        break;
   39.99 +      case MapValue::STRING:
  39.100 +        {
  39.101 +          map<int, string>* p_map_data =
  39.102 +            new map<int, string>;
  39.103 +          gui_data.string_arc_maps[*it] = p_map_data;
  39.104 +          { x(*it, *p_map_data); }
  39.105 +        }
  39.106 +        break;
  39.107 +    }
  39.108 +  }
  39.109 +
  39.110 +  {
  39.111 +    std::string node_coords_save_dest;
  39.112 +    { x("node_coords_save_dest", node_coords_save_dest); }
  39.113 +    if (node_coords_save_dest == "gui_sect")
  39.114 +    {
  39.115 +      // read the node coorinates
  39.116 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
  39.117 +      { x("node_coord_map", gui_data.node_coord_map); }
  39.118 +    }
  39.119 +    else if (node_coords_save_dest == "nodeset_sect_1_map")
  39.120 +    {
  39.121 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  39.122 +      gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
  39.123 +      { x("map_name", gui_data.node_coords_one_map_name); }
  39.124 +    }
  39.125 +    else if (node_coords_save_dest == "nodeset_sect_2_maps")
  39.126 +    {
  39.127 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  39.128 +      gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
  39.129 +      { x("map1_name", gui_data.node_coords_two_maps_1_name); }
  39.130 +      { x("map2_name", gui_data.node_coords_two_maps_2_name); }
  39.131 +    }
  39.132 +  }
  39.133 +
  39.134 +  {
  39.135 +    std::string arrow_coords_save_dest;
  39.136 +    { x("arrow_coords_save_dest", arrow_coords_save_dest); }
  39.137 +    if (arrow_coords_save_dest == "gui_sect")
  39.138 +    {
  39.139 +      // read the arrow coorinates
  39.140 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
  39.141 +      { x("arrow_coord_map", gui_data.arrow_coord_map); }
  39.142 +    }
  39.143 +    else if (arrow_coords_save_dest == "arcset_sect_1_map")
  39.144 +    {
  39.145 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  39.146 +      gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
  39.147 +      { x("map_name", gui_data.arrow_coords_one_map_name); }
  39.148 +    }
  39.149 +    else if (arrow_coords_save_dest == "arcset_sect_2_maps")
  39.150 +    {
  39.151 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  39.152 +      gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
  39.153 +      { x("map1_name", gui_data.arrow_coords_two_maps_1_name); }
  39.154 +      { x("map2_name", gui_data.arrow_coords_two_maps_2_name); }
  39.155 +    }
  39.156 +  }
  39.157 +
  39.158 +
  39.159 +
  39.160 +  std::map<int, std::string> nm;
  39.161 +  x("active_nodemaps", nm);
  39.162 +
  39.163 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  39.164 +  {
  39.165 +    mapstorage->changeActiveMap(false, i, nm[i]);
  39.166 +  }
  39.167 +
  39.168 +  std::map<int, std::string> em;
  39.169 +  x("active_arcmaps", em);
  39.170 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  39.171 +  {
  39.172 +    mapstorage->changeActiveMap(true, i, em[i]);
  39.173 +  }
  39.174 +
  39.175 +  double attraction;
  39.176 +  double propulsation;
  39.177 +  int iteration;
  39.178 +
  39.179 +  x("redesign-attraction", attraction);
  39.180 +  x("redesign-propulsation", propulsation);
  39.181 +  x("redesign-iteration", iteration);
  39.182 +
  39.183 +  mapstorage->set_attraction(attraction);
  39.184 +  mapstorage->set_propulsation(propulsation);
  39.185 +  mapstorage->set_iteration(iteration);
  39.186 +
  39.187 +  mapstorage->redesign_data_changed();
  39.188 +}
  39.189 +
  39.190 +//GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage,
  39.191 +GuiReader::GuiReader(MapStorage* _mapstorage,
  39.192 +    MapStorage::GUISectData& _gui_data) :
  39.193 +  //Parent(reader),
  39.194 +  mapstorage(_mapstorage),
  39.195 +  gui_data(_gui_data)
  39.196 +{
  39.197 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/gui_reader.h	Mon Jul 07 08:10:39 2008 -0500
    40.3 @@ -0,0 +1,36 @@
    40.4 +/* -*- C++ -*-
    40.5 + *
    40.6 + * This file is a part of LEMON, a generic C++ optimization library
    40.7 + *
    40.8 + * Copyright (C) 2003-2006
    40.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   40.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   40.11 + *
   40.12 + * Permission to use, modify and distribute this software is granted
   40.13 + * provided that this copyright notice appears in all copies. For
   40.14 + * precise terms see the accompanying LICENSE file.
   40.15 + *
   40.16 + * This software is provided "AS IS" with no warranty of any kind,
   40.17 + * express or implied, and with no claim as to its suitability for any
   40.18 + * purpose.
   40.19 + *
   40.20 + */
   40.21 +
   40.22 +#ifndef GUI_READER_H
   40.23 +#define GUI_READER_H
   40.24 +
   40.25 +#include <iostream>
   40.26 +#include "mapstorage.h"
   40.27 +
   40.28 +class GuiReader
   40.29 +{
   40.30 +  private:
   40.31 +    MapStorage* mapstorage;
   40.32 +    MapStorage::GUISectData& gui_data;
   40.33 +
   40.34 +  public:
   40.35 +  void operator()(std::istream&, int&);
   40.36 +  GuiReader(MapStorage*, MapStorage::GUISectData&);
   40.37 +};
   40.38 +
   40.39 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/gui_writer.cc	Mon Jul 07 08:10:39 2008 -0500
    41.3 @@ -0,0 +1,281 @@
    41.4 +/* -*- C++ -*-
    41.5 + *
    41.6 + * This file is a part of LEMON, a generic C++ optimization library
    41.7 + *
    41.8 + * Copyright (C) 2003-2006
    41.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   41.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   41.11 + *
   41.12 + * Permission to use, modify and distribute this software is granted
   41.13 + * provided that this copyright notice appears in all copies. For
   41.14 + * precise terms see the accompanying LICENSE file.
   41.15 + *
   41.16 + * This software is provided "AS IS" with no warranty of any kind,
   41.17 + * express or implied, and with no claim as to its suitability for any
   41.18 + * purpose.
   41.19 + *
   41.20 + */
   41.21 +
   41.22 +#include "gui_writer.h"
   41.23 +#include "io_helper.h"
   41.24 +#include "mapstorage.h"
   41.25 +#include "xml.h"
   41.26 +#include <lemon/dim2.h>
   41.27 +#include <vector>
   41.28 +
   41.29 +#include <gui_writer.h>
   41.30 +#include <mapstorage.h>
   41.31 +
   41.32 +// std::string GuiWriter::header()
   41.33 +// {
   41.34 +//   return "@gui";
   41.35 +// }
   41.36 +
   41.37 +void GuiWriter::write(std::ostream& os)
   41.38 +{
   41.39 +  using std::vector;
   41.40 +  using std::string;
   41.41 +  using std::map;
   41.42 +  using std::string;
   41.43 +
   41.44 +  os << "@gui" << std::endl;
   41.45 +
   41.46 +  XmlIo x(os);
   41.47 +
   41.48 +  vector<string> all_node_map_names = mapstorage->getNodeMapList();
   41.49 +  // name of the maps saved to the nodeset section
   41.50 +  vector<string> main_node_map_names;
   41.51 +  // name of the maps saved to the gui section
   41.52 +  vector<string> gui_node_map_names;
   41.53 +
   41.54 +  for (vector<string>::const_iterator it = all_node_map_names.begin();
   41.55 +      it != all_node_map_names.end(); ++it)
   41.56 +  {
   41.57 +    if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::NESET_SECT)
   41.58 +      main_node_map_names.push_back(*it);
   41.59 +    else if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
   41.60 +      gui_node_map_names.push_back(*it);
   41.61 +  }
   41.62 +
   41.63 +  { x("main_node_map_names", main_node_map_names); }
   41.64 +  { x("gui_node_map_names", gui_node_map_names); }
   41.65 +
   41.66 +  map<string, MapValue::Type> node_map_types;
   41.67 +  for (vector<string>::const_iterator it = main_node_map_names.begin();
   41.68 +      it != main_node_map_names.end(); ++it)
   41.69 +  {
   41.70 +    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
   41.71 +  }
   41.72 +  for (vector<string>::const_iterator it = gui_node_map_names.begin();
   41.73 +      it != gui_node_map_names.end(); ++it)
   41.74 +  {
   41.75 +    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
   41.76 +  }
   41.77 +
   41.78 +  { x("node_map_types", node_map_types); }
   41.79 +
   41.80 +
   41.81 +  vector<string> all_arc_map_names = mapstorage->getArcMapList();
   41.82 +  // name of the maps saved to the arcset section
   41.83 +  vector<string> main_arc_map_names;
   41.84 +  // name of the maps saved to the gui section
   41.85 +  vector<string> gui_arc_map_names;
   41.86 +
   41.87 +  for (vector<string>::const_iterator it = all_arc_map_names.begin();
   41.88 +      it != all_arc_map_names.end(); ++it)
   41.89 +  {
   41.90 +    if (mapstorage->getArcMapSaveDest(*it) == MapStorage::NESET_SECT)
   41.91 +      main_arc_map_names.push_back(*it);
   41.92 +    if (mapstorage->getArcMapSaveDest(*it) == MapStorage::GUI_SECT)
   41.93 +      gui_arc_map_names.push_back(*it);
   41.94 +  }
   41.95 +
   41.96 +  { x("main_arc_map_names", main_arc_map_names); }
   41.97 +  { x("gui_arc_map_names", gui_arc_map_names); }
   41.98 +
   41.99 +  map<string, MapValue::Type> arc_map_types;
  41.100 +  for (vector<string>::const_iterator it = main_arc_map_names.begin();
  41.101 +      it != main_arc_map_names.end(); ++it)
  41.102 +  {
  41.103 +    arc_map_types[*it] = mapstorage->getArcMapElementType(*it);
  41.104 +  }
  41.105 +  for (vector<string>::const_iterator it = gui_arc_map_names.begin();
  41.106 +      it != gui_arc_map_names.end(); ++it)
  41.107 +  {
  41.108 +    arc_map_types[*it] = mapstorage->getArcMapElementType(*it);
  41.109 +  }
  41.110 +
  41.111 +  { x("arc_map_types", arc_map_types); }
  41.112 +
  41.113 +  // write the gui node maps
  41.114 +  for (vector<string>::const_iterator it = gui_node_map_names.begin();
  41.115 +      it != gui_node_map_names.end(); ++it)
  41.116 +  {
  41.117 +    MapValue::Type type = mapstorage->getNodeMapElementType(*it);
  41.118 +    const MapStorage::NodeLabelMap& labels = mapstorage->getNodeLabelMap();
  41.119 +    switch (type)
  41.120 +    {
  41.121 +      case MapValue::NUMERIC:
  41.122 +        {
  41.123 +          std::map<int, double> map_data;
  41.124 +          MapStorage::NumericNodeMap& map =
  41.125 +            mapstorage->getNumericNodeMap(*it);
  41.126 +          for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
  41.127 +          {
  41.128 +            map_data[labels[n]] = map[n];
  41.129 +          }
  41.130 +          { x(*it, map_data); }
  41.131 +        }
  41.132 +        break;
  41.133 +      case MapValue::STRING:
  41.134 +        {
  41.135 +          std::map<int, std::string> map_data;
  41.136 +          MapStorage::StringNodeMap& map =
  41.137 +            mapstorage->getStringNodeMap(*it);
  41.138 +          for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
  41.139 +          {
  41.140 +            map_data[labels[n]] = map[n];
  41.141 +          }
  41.142 +          { x(*it, map_data); }
  41.143 +        }
  41.144 +        break;
  41.145 +    }
  41.146 +  }
  41.147 +
  41.148 +  // write the gui arc maps
  41.149 +  for (vector<string>::const_iterator it = gui_arc_map_names.begin();
  41.150 +      it != gui_arc_map_names.end(); ++it)
  41.151 +  {
  41.152 +    MapValue::Type type = mapstorage->getArcMapElementType(*it);
  41.153 +    const MapStorage::ArcLabelMap& labels = mapstorage->getArcLabelMap();
  41.154 +    switch (type)
  41.155 +    {
  41.156 +      case MapValue::NUMERIC:
  41.157 +        {
  41.158 +          std::map<int, double> map_data;
  41.159 +          MapStorage::NumericArcMap& map =
  41.160 +            mapstorage->getNumericArcMap(*it);
  41.161 +          for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
  41.162 +          {
  41.163 +            map_data[labels[e]] = map[e];
  41.164 +          }
  41.165 +          { x(*it, map_data); }
  41.166 +        }
  41.167 +        break;
  41.168 +      case MapValue::STRING:
  41.169 +        {
  41.170 +          std::map<int, std::string> map_data;
  41.171 +          MapStorage::StringArcMap& map =
  41.172 +            mapstorage->getStringArcMap(*it);
  41.173 +          for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
  41.174 +          {
  41.175 +            map_data[labels[e]] = map[e];
  41.176 +          }
  41.177 +          { x(*it, map_data); }
  41.178 +        }
  41.179 +        break;
  41.180 +    }
  41.181 +  }
  41.182 +
  41.183 +  {
  41.184 +    switch (mapstorage->getNodeCoordsSaveDest())
  41.185 +    {
  41.186 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  41.187 +        { x("node_coords_save_dest", string("gui_sect")); }
  41.188 +        // write the node coorinates
  41.189 +        {
  41.190 +          const MapStorage::NodeLabelMap& labels =
  41.191 +            mapstorage->getNodeLabelMap();
  41.192 +          std::map<int, XY> node_coord_map;
  41.193 +          MapStorage::NodeCoordMap& map = mapstorage->getNodeCoordMap();
  41.194 +          for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
  41.195 +          {
  41.196 +            node_coord_map[labels[n]] = map[n];
  41.197 +          }
  41.198 +          { x("node_coord_map", node_coord_map); }
  41.199 +        }
  41.200 +        break;
  41.201 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  41.202 +        switch (mapstorage->getNodeCoordsSaveMapNum())
  41.203 +        {
  41.204 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  41.205 +            { x("node_coords_save_dest", string("nodeset_sect_1_map")); }
  41.206 +            { x("map_name", mapstorage->getNodeCoordsOneMapName()); }
  41.207 +            break;
  41.208 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.209 +            { x("node_coords_save_dest", string("nodeset_sect_2_maps")); }
  41.210 +            { x("map1_name", mapstorage->getNodeCoordsTwoMaps1Name()); }
  41.211 +            { x("map2_name", mapstorage->getNodeCoordsTwoMaps2Name()); }
  41.212 +            break;
  41.213 +        }
  41.214 +        break;
  41.215 +    }
  41.216 +  }
  41.217 +
  41.218 +  {
  41.219 +    switch (mapstorage->getArrowCoordsSaveDest())
  41.220 +    {
  41.221 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  41.222 +        { x("arrow_coords_save_dest", string("gui_sect")); }
  41.223 +        // write the arrow coorinates
  41.224 +        {
  41.225 +          const MapStorage::ArcLabelMap& labels =
  41.226 +            mapstorage->getArcLabelMap();
  41.227 +          std::map<int, XY> arrow_coord_map;
  41.228 +          MapStorage::ArrowCoordMap& map = mapstorage->getArrowCoordMap();
  41.229 +          for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
  41.230 +          {
  41.231 +            arrow_coord_map[labels[e]] = map[e];
  41.232 +          }
  41.233 +          { x("arrow_coord_map", arrow_coord_map); }
  41.234 +        }
  41.235 +        break;
  41.236 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  41.237 +        switch (mapstorage->getArrowCoordsSaveMapNum())
  41.238 +        {
  41.239 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  41.240 +            { x("arrow_coords_save_dest", string("arcset_sect_1_map")); }
  41.241 +            { x("map_name", mapstorage->getArrowCoordsOneMapName()); }
  41.242 +            break;
  41.243 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.244 +            { x("arrow_coords_save_dest", string("arcset_sect_2_maps")); }
  41.245 +            { x("map1_name", mapstorage->getArrowCoordsTwoMaps1Name()); }
  41.246 +            { x("map2_name", mapstorage->getArrowCoordsTwoMaps2Name()); }
  41.247 +            break;
  41.248 +        }
  41.249 +        break;
  41.250 +    }
  41.251 +  }
  41.252 +
  41.253 +
  41.254 +  std::map<int, std::string> nm;
  41.255 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  41.256 +    {
  41.257 +      nm[i]=mapstorage->active_nodemaps[i];
  41.258 +    }
  41.259 +  { x("active_nodemaps", nm); }
  41.260 +
  41.261 +  std::map<int, std::string> em;
  41.262 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  41.263 +    {
  41.264 +      em[i]=mapstorage->active_arcmaps[i];
  41.265 +    }
  41.266 +  { x("active_arcmaps", em); }
  41.267 +
  41.268 +  double attraction;
  41.269 +  double propulsation;
  41.270 +  int iteration;
  41.271 +
  41.272 +  mapstorage->get_design_data(attraction, propulsation, iteration);
  41.273 +
  41.274 +  { x("redesign-attraction", attraction); }
  41.275 +  { x("redesign-propulsation", propulsation); }
  41.276 +  { x("redesign-iteration", iteration); }
  41.277 +}
  41.278 +
  41.279 +//GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) :
  41.280 +GuiWriter::GuiWriter(MapStorage* ms) :
  41.281 +  //Parent(writer),
  41.282 +  mapstorage(ms)
  41.283 +{
  41.284 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/gui_writer.h	Mon Jul 07 08:10:39 2008 -0500
    42.3 @@ -0,0 +1,35 @@
    42.4 +/* -*- C++ -*-
    42.5 + *
    42.6 + * This file is a part of LEMON, a generic C++ optimization library
    42.7 + *
    42.8 + * Copyright (C) 2003-2006
    42.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   42.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   42.11 + *
   42.12 + * Permission to use, modify and distribute this software is granted
   42.13 + * provided that this copyright notice appears in all copies. For
   42.14 + * precise terms see the accompanying LICENSE file.
   42.15 + *
   42.16 + * This software is provided "AS IS" with no warranty of any kind,
   42.17 + * express or implied, and with no claim as to its suitability for any
   42.18 + * purpose.
   42.19 + *
   42.20 + */
   42.21 +
   42.22 +#ifndef GUI_WRITER_H
   42.23 +#define GUI_WRITER_H
   42.24 +
   42.25 +#include <iostream>
   42.26 +
   42.27 +class MapStorage;
   42.28 +
   42.29 +class GuiWriter
   42.30 +{
   42.31 +  private:
   42.32 +    MapStorage* mapstorage;
   42.33 +  public:
   42.34 +    virtual void write(std::ostream&);
   42.35 +    GuiWriter(MapStorage*);
   42.36 +};
   42.37 +
   42.38 +#endif
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/i18n.h	Mon Jul 07 08:10:39 2008 -0500
    43.3 @@ -0,0 +1,7 @@
    43.4 +#ifndef I18N_H
    43.5 +#define I18N_H
    43.6 +
    43.7 +#include "gettext.h"
    43.8 +#define _(string) gettext (string)
    43.9 +
   43.10 +#endif
    44.1 Binary file icons/addlink.png has changed
    45.1 Binary file icons/addnode.png has changed
    46.1 Binary file icons/delete.png has changed
    47.1 Binary file icons/editlink.png has changed
    48.1 Binary file icons/editnode.png has changed
    49.1 Binary file icons/eps.png has changed
    50.1 Binary file icons/move.png has changed
    51.1 Binary file icons/newmap.png has changed
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/io_helper.cc	Mon Jul 07 08:10:39 2008 -0500
    52.3 @@ -0,0 +1,34 @@
    52.4 +#include "io_helper.h"
    52.5 +
    52.6 +namespace lemon {
    52.7 +  void xml(XmlIo &x, MapValue::Type& v)
    52.8 +  {
    52.9 +    if(x.write()) {
   52.10 +      switch (v)
   52.11 +      {
   52.12 +        case MapValue::NUMERIC:
   52.13 +          { x("type", std::string("numeric")); }
   52.14 +          break;
   52.15 +        case MapValue::STRING:
   52.16 +          { x("type", std::string("string")); }
   52.17 +          break;
   52.18 +      }
   52.19 +    }
   52.20 +    else {
   52.21 +      std::string type;
   52.22 +      { x("type", type); }
   52.23 +      if (type == "numeric")
   52.24 +      {
   52.25 +        v = MapValue::NUMERIC;
   52.26 +      }
   52.27 +      else if (type == "string")
   52.28 +      {
   52.29 +        v = MapValue::STRING;
   52.30 +      }
   52.31 +      else
   52.32 +      {
   52.33 +        throw DataFormatError("Bad format");
   52.34 +      }
   52.35 +    }
   52.36 +  }
   52.37 +};
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/io_helper.h	Mon Jul 07 08:10:39 2008 -0500
    53.3 @@ -0,0 +1,11 @@
    53.4 +#ifndef IO_HELPER
    53.5 +#define IO_HELPER
    53.6 +
    53.7 +#include "xml.h"
    53.8 +#include "map_value.h"
    53.9 +
   53.10 +namespace lemon {
   53.11 +  void xml(XmlIo &x, MapValue::Type& v);
   53.12 +};
   53.13 +
   53.14 +#endif
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/kruskalbox.cc	Mon Jul 07 08:10:39 2008 -0500
    54.3 @@ -0,0 +1,83 @@
    54.4 +/* -*- C++ -*-
    54.5 + *
    54.6 + * This file is a part of LEMON, a generic C++ optimization library
    54.7 + *
    54.8 + * Copyright (C) 2003-2006
    54.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   54.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   54.11 + *
   54.12 + * Permission to use, modify and distribute this software is granted
   54.13 + * provided that this copyright notice appears in all copies. For
   54.14 + * precise terms see the accompanying LICENSE file.
   54.15 + *
   54.16 + * This software is provided "AS IS" with no warranty of any kind,
   54.17 + * express or implied, and with no claim as to its suitability for any
   54.18 + * purpose.
   54.19 + *
   54.20 + */
   54.21 +
   54.22 +#include <lemon/kruskal.h>
   54.23 +
   54.24 +#include <mapstorage.h>
   54.25 +#include <mapselector.h>
   54.26 +#include <algobox.h>
   54.27 +#include <kruskalbox.h>
   54.28 +
   54.29 +enum {INPUT, OUTPUT, MAP_NUM};
   54.30 +
   54.31 +KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
   54.32 +{
   54.33 +  init(t);
   54.34 +}
   54.35 +    
   54.36 +void KruskalBox::run()
   54.37 +{
   54.38 +  if(
   54.39 +      tabcbt.get_active_text()!="" &&
   54.40 +      (arcmapcbts[INPUT])->get_active_text()!="" &&
   54.41 +      (arcmapcbts[OUTPUT])->get_active_text()!=""
   54.42 +    )
   54.43 +  {
   54.44 +
   54.45 +    const Digraph &g=mapstorage->getDigraph();
   54.46 +    std::string input_map_name = arcmapcbts[INPUT]->get_active_text();
   54.47 +    Digraph::ArcMap<bool> outputmap(g);
   54.48 +    const MapStorage::NumericArcMap& inputmap=
   54.49 +      mapstorage->getNumericArcMap(input_map_name);
   54.50 +    double res=kruskal(g, inputmap, outputmap);
   54.51 +
   54.52 +    for (ArcIt i(g); i!=INVALID; ++i)
   54.53 +    {
   54.54 +      if(outputmap[i])
   54.55 +      {
   54.56 +        mapstorage->set(arcmapcbts[OUTPUT]->get_active_text(), i, 1.0);
   54.57 +      }
   54.58 +      else
   54.59 +      {
   54.60 +        mapstorage->set(arcmapcbts[OUTPUT]->get_active_text(), i, 0.0);
   54.61 +      }
   54.62 +    }
   54.63 +
   54.64 +    std::ostringstream o;
   54.65 +    o << "Result: " << res;
   54.66 +    resultlabel.set_text(o.str());
   54.67 +
   54.68 +    mapstorage->mapChanged(true, (arcmapcbts[OUTPUT])->get_active_text());
   54.69 +    //   mapstorage->changeActiveMap(true, E_COLOR,
   54.70 +    // 			      (arcmapcbts[OUTPUT])->get_active_text());
   54.71 +    //   mapstorage->changeActiveMap(true, E_TEXT,
   54.72 +    // 			      (arcmapcbts[INPUT])->get_active_text());
   54.73 +
   54.74 +  }
   54.75 +}
   54.76 +    
   54.77 +void KruskalBox::build_box()
   54.78 +{
   54.79 +  std::vector<std::string> empty_vector;
   54.80 +
   54.81 +  addMapSelector("Arccosts: ", true, NUM);
   54.82 +  addMapSelector("Arcs of tree here: ", true, NUM);
   54.83 +
   54.84 +  resultlabel.set_text("Result: algorithm is not run yet.");
   54.85 +  pack_start(resultlabel);
   54.86 +}
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/kruskalbox.h	Mon Jul 07 08:10:39 2008 -0500
    55.3 @@ -0,0 +1,58 @@
    55.4 +/* -*- C++ -*-
    55.5 + *
    55.6 + * This file is a part of LEMON, a generic C++ optimization library
    55.7 + *
    55.8 + * Copyright (C) 2003-2006
    55.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   55.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   55.11 + *
   55.12 + * Permission to use, modify and distribute this software is granted
   55.13 + * provided that this copyright notice appears in all copies. For
   55.14 + * precise terms see the accompanying LICENSE file.
   55.15 + *
   55.16 + * This software is provided "AS IS" with no warranty of any kind,
   55.17 + * express or implied, and with no claim as to its suitability for any
   55.18 + * purpose.
   55.19 + *
   55.20 + */
   55.21 +
   55.22 +#ifndef KRUSKALBOX_H
   55.23 +#define KRUSKALBOX_H
   55.24 +
   55.25 +class AlgoBox;
   55.26 +
   55.27 +#include <all_include.h>
   55.28 +#include <libgnomecanvasmm.h>
   55.29 +#include <libgnomecanvasmm/polygon.h>
   55.30 +
   55.31 +///Digraphical interface to run Kruskal algorithm.
   55.32 +
   55.33 +///Child of \ref AlgoBox,
   55.34 +///therefore the only task to do at implementation was to
   55.35 +///
   55.36 +///-call init function with correct parameters from correctly parametrized constructor
   55.37 +///
   55.38 +///-implement \ref build_box function
   55.39 +///
   55.40 +///-implement \ref run function
   55.41 +class KruskalBox : public AlgoBox
   55.42 +{
   55.43 +  ///Shows result of Kruskal algorithm
   55.44 +  Gtk::Label resultlabel;
   55.45 +
   55.46 +public:
   55.47 +  ///Calls \ref AlgoBox::init function to initialize class properly, automatically.
   55.48 +  KruskalBox(std::vector<std::string> t);
   55.49 +
   55.50 +  ///Prepare, run and postprocess Kruskal algorithm.
   55.51 +
   55.52 +  ///\ref glemon works only with maps filled with double values
   55.53 +  ///at the moment. While Kruskal nedds a bool map as output.
   55.54 +  ///As postprocess this bool map should be transformed to
   55.55 +  ///double map.
   55.56 +  void run();
   55.57 +
   55.58 +  ///Builds the digraphical design of the interface.
   55.59 +  void build_box();
   55.60 +};
   55.61 +#endif //KRUSKALBOX_H
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/m4/Makefile.am	Mon Jul 07 08:10:39 2008 -0500
    56.3 @@ -0,0 +1,30 @@
    56.4 +EXTRA_DIST = \
    56.5 +	codeset.m4 \
    56.6 +	gettext.m4 \
    56.7 +	glibc21.m4 \
    56.8 +	glibc2.m4 \
    56.9 +	iconv.m4 \
   56.10 +	intdiv0.m4 \
   56.11 +	intmax.m4 \
   56.12 +	inttypes_h.m4 \
   56.13 +	inttypes.m4 \
   56.14 +	inttypes-pri.m4 \
   56.15 +	isc-posix.m4 \
   56.16 +	lcmessage.m4 \
   56.17 +	lib-ld.m4 \
   56.18 +	lib-link.m4 \
   56.19 +	lib-prefix.m4 \
   56.20 +	longdouble.m4 \
   56.21 +	longlong.m4 \
   56.22 +	nls.m4 \
   56.23 +	po.m4 \
   56.24 +	printf-posix.m4 \
   56.25 +	progtest.m4 \
   56.26 +	signed.m4 \
   56.27 +	size_max.m4 \
   56.28 +	stdint_h.m4 \
   56.29 +	uintmax_t.m4 \
   56.30 +	ulonglong.m4 \
   56.31 +	wchar_t.m4 \
   56.32 +	wint_t.m4 \
   56.33 +	xsize.m4
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/main_win.cc	Mon Jul 07 08:10:39 2008 -0500
    57.3 @@ -0,0 +1,657 @@
    57.4 +/* -*- C++ -*-
    57.5 + *
    57.6 + * This file is a part of LEMON, a generic C++ optimization library
    57.7 + *
    57.8 + * Copyright (C) 2003-2006
    57.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   57.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   57.11 + *
   57.12 + * Permission to use, modify and distribute this software is granted
   57.13 + * provided that this copyright notice appears in all copies. For
   57.14 + * precise terms see the accompanying LICENSE file.
   57.15 + *
   57.16 + * This software is provided "AS IS" with no warranty of any kind,
   57.17 + * express or implied, and with no claim as to its suitability for any
   57.18 + * purpose.
   57.19 + *
   57.20 + */
   57.21 +
   57.22 +#ifdef HAVE_CONFIG_H
   57.23 +#include <config.h>
   57.24 +#endif
   57.25 +
   57.26 +#include "main_win.h"
   57.27 +#include "guipixbufs.h"
   57.28 +#include "save_details_dialog.h"
   57.29 +#include "background_chooser_dialog.h"
   57.30 +
   57.31 +#include <mapstorage.h>
   57.32 +#include <graph_displayer_canvas.h>
   57.33 +#include <algowin.h>
   57.34 +#include <new_map_win.h>
   57.35 +#include <nbtab.h>
   57.36 +
   57.37 +#include "i18n.h"
   57.38 +
   57.39 +MainWin::MainWin()
   57.40 +{
   57.41 +  set_title ("no file");
   57.42 +  set_default_size(WIN_WIDTH,WIN_HEIGHT);
   57.43 +  //add(vbox);
   57.44 +  add(table);
   57.45 +
   57.46 +  // custom icons for the toolbar
   57.47 +  Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
   57.48 + 
   57.49 +  Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.50 +      2328, gui_icons_move);
   57.51 +  Glib::RefPtr<Gdk::Pixbuf> p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.52 +      2328, gui_icons_addnode);
   57.53 +  Glib::RefPtr<Gdk::Pixbuf> p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.54 +      2328, gui_icons_addlink);
   57.55 +  Glib::RefPtr<Gdk::Pixbuf> p_delete_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.56 +      2328, gui_icons_delete);
   57.57 +  Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.58 +      2328, gui_icons_editlink);
   57.59 +  Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.60 +      2328, gui_icons_newmap);
   57.61 +  Glib::RefPtr<Gdk::Pixbuf> p_eps_pixbuf = Gdk::Pixbuf::create_from_inline(
   57.62 +      2328, gui_icons_eps);
   57.63 +
   57.64 +  Gtk::IconSource move_icon_source;
   57.65 +  move_icon_source.set_pixbuf(p_move_pixbuf);
   57.66 +  Gtk::IconSet move_icon_set;
   57.67 +  move_icon_set.add_source(move_icon_source);
   57.68 +  p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set);
   57.69 +
   57.70 +  Gtk::IconSource addnode_icon_source;
   57.71 +  addnode_icon_source.set_pixbuf(p_addnode_pixbuf);
   57.72 +  Gtk::IconSet addnode_icon_set;
   57.73 +  addnode_icon_set.add_source(addnode_icon_source);
   57.74 +  p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set);
   57.75 +
   57.76 +  Gtk::IconSource addlink_icon_source;
   57.77 +  addlink_icon_source.set_pixbuf(p_addlink_pixbuf);
   57.78 +  Gtk::IconSet addlink_icon_set;
   57.79 +  addlink_icon_set.add_source(addlink_icon_source);
   57.80 +  p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set);
   57.81 +
   57.82 +  Gtk::IconSource delete_icon_source;
   57.83 +  delete_icon_source.set_pixbuf(p_delete_pixbuf);
   57.84 +  Gtk::IconSet delete_icon_set;
   57.85 +  delete_icon_set.add_source(delete_icon_source);
   57.86 +  p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set);
   57.87 +
   57.88 +  Gtk::IconSource editlink_icon_source;
   57.89 +  editlink_icon_source.set_pixbuf(p_editlink_pixbuf);
   57.90 +  Gtk::IconSet editlink_icon_set;
   57.91 +  editlink_icon_set.add_source(editlink_icon_source);
   57.92 +  p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set);
   57.93 +
   57.94 +  Gtk::IconSource newmap_icon_source;
   57.95 +  newmap_icon_source.set_pixbuf(p_newmap_pixbuf);
   57.96 +  Gtk::IconSet newmap_icon_set;
   57.97 +  newmap_icon_set.add_source(newmap_icon_source);
   57.98 +  p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set);
   57.99 +
  57.100 +  Gtk::IconSource eps_icon_source;
  57.101 +  eps_icon_source.set_pixbuf(p_eps_pixbuf);
  57.102 +  Gtk::IconSet eps_icon_set;
  57.103 +  eps_icon_set.add_source(eps_icon_source);
  57.104 +  p_icon_factory->add(Gtk::StockID("gd-eps"), eps_icon_set);
  57.105 +
  57.106 +  p_icon_factory->add_default();
  57.107 +  
  57.108 +  ag=Gtk::ActionGroup::create();
  57.109 +
  57.110 +  ag->add( Gtk::Action::create("FileMenu", _("_File")) );
  57.111 +  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
  57.112 +      sigc::mem_fun(*this, &MainWin::newTab));
  57.113 +  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
  57.114 +      sigc::mem_fun(*this, &MainWin::openFile));
  57.115 +  ag->add( Gtk::Action::create("FileClearTab", _("Clear Tab")),
  57.116 +      sigc::mem_fun(*this, &MainWin::newFile));
  57.117 +  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
  57.118 +      sigc::mem_fun(*this, &MainWin::saveFile));
  57.119 +  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
  57.120 +      sigc::mem_fun(*this, &MainWin::saveFileAs));
  57.121 +  ag->add( Gtk::Action::create("SaveDetails", _("Save _Details...")),
  57.122 +	   sigc::mem_fun(*this, &MainWin::createSaveDetailsDialog));
  57.123 +  ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
  57.124 +      sigc::mem_fun(*this, &MainWin::closeTab));
  57.125 +  ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
  57.126 +      sigc::mem_fun(*this, &MainWin::hide));
  57.127 +
  57.128 +  ag->add( Gtk::Action::create("ViewMenu", _("_View")) );
  57.129 +  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
  57.130 +      sigc::mem_fun(*this, &MainWin::zoomIn));
  57.131 +  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
  57.132 +      sigc::mem_fun(*this, &MainWin::zoomOut));
  57.133 +  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
  57.134 +      sigc::mem_fun(*this, &MainWin::zoomFit));
  57.135 +  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
  57.136 +      sigc::mem_fun(*this, &MainWin::zoom100));
  57.137 +  ag->add( Gtk::Action::create("SetBackground", _("Set Background...")),
  57.138 +	    sigc::mem_fun(*this, &MainWin::createBackgroundChooser));
  57.139 +  
  57.140 +  ag->add( Gtk::Action::create("ShowMenu", _("_Show")) );
  57.141 +  ag->add( Gtk::Action::create("ShowMaps", _("_Maps")),
  57.142 +	   sigc::mem_fun(*this, &MainWin::createMapWin));
  57.143 +  ag->add( Gtk::Action::create("ShowDesign", _("_Design")),
  57.144 +	   sigc::mem_fun(*this, &MainWin::createDesignWin));
  57.145 +
  57.146 +  ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) );
  57.147 +  ag->add( Gtk::Action::create("AlgoGeneral", _("_General")),
  57.148 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) );
  57.149 +  ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")),
  57.150 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) );
  57.151 +  ag->add( Gtk::Action::create("AlgoDijkstra", _("_Dijkstra")),
  57.152 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 2) );
  57.153 +  ag->add( Gtk::Action::create("AlgoSuurballe", _("_Suurballe")),
  57.154 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 3) );
  57.155 +
  57.156 +  Gtk::RadioAction::Group tool_group;
  57.157 +  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")),
  57.158 +      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) );
  57.159 +  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")),
  57.160 +      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) );
  57.161 +  ag->add( Gtk::RadioAction::create(tool_group, "CreateArc", Gtk::StockID("gd-addlink"), _("Create arc")),
  57.162 +      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) );
  57.163 +  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")),
  57.164 +      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) );
  57.165 +
  57.166 +  ag->add( Gtk::RadioAction::create(tool_group, "EditArcMap", Gtk::StockID("gd-editlink"), _("Edit arc map")),
  57.167 +      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) );
  57.168 +
  57.169 +  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap"), "New map"),
  57.170 +      sigc::mem_fun ( *this , &MainWin::createNewMapWin ) );
  57.171 +
  57.172 +  ag->add( Gtk::Action::create("DesignDigraph", Gtk::Stock::REFRESH),
  57.173 +      sigc::mem_fun ( *this , &MainWin::reDesignDigraph ) );
  57.174 +
  57.175 +  ag->add( Gtk::Action::create("Eps", Gtk::StockID("gd-eps"), "Export to EPS"),
  57.176 +      sigc::mem_fun ( *this , &MainWin::exportToEPS ) );
  57.177 +
  57.178 +  uim=Gtk::UIManager::create();
  57.179 +  uim->insert_action_group(ag);
  57.180 +  add_accel_group(uim->get_accel_group());
  57.181 +
  57.182 +  try
  57.183 +  {
  57.184 +
  57.185 +    Glib::ustring ui_info =
  57.186 +      "<ui>"
  57.187 +      "  <menubar name='MenuBar'>"
  57.188 +      "    <menu action='FileMenu'>"
  57.189 +      "      <menuitem action='FileNew'/>"
  57.190 +      "      <menuitem action='FileOpen'/>"
  57.191 +      "      <menuitem action='FileClearTab'/>"
  57.192 +      "      <menuitem action='FileSave'/>"
  57.193 +      "      <menuitem action='FileSaveAs'/>"
  57.194 +      "      <menuitem action='SaveDetails'/>"
  57.195 +      "      <menuitem action='Close'/>"
  57.196 +      "      <menuitem action='Quit'/>"
  57.197 +      "    </menu>"
  57.198 +      "    <menu action='ViewMenu'>"
  57.199 +      "      <menuitem action='ViewZoomIn' />"
  57.200 +      "      <menuitem action='ViewZoomOut' />"
  57.201 +      "      <menuitem action='ViewZoom100' />"
  57.202 +      "      <menuitem action='ViewZoomFit' />"
  57.203 +      "      <menuitem action='SetBackground' />"
  57.204 +      "    </menu>"
  57.205 +      "    <menu action='ShowMenu'>"
  57.206 +      "      <menuitem action='ShowMaps'/>"
  57.207 +      "      <menuitem action='ShowDesign'/>"
  57.208 +      "    </menu>"
  57.209 +      "    <menu action='AlgoMenu'>"
  57.210 +      "      <menuitem action='AlgoGeneral'/>"
  57.211 +      "      <menuitem action='AlgoKruskal'/>"
  57.212 +      "      <menuitem action='AlgoDijkstra'/>"
  57.213 +      "      <menuitem action='AlgoSuurballe'/>"
  57.214 +      "    </menu>"
  57.215 +      "  </menubar>"
  57.216 +      "  <toolbar name='ToolBar'>"
  57.217 +      "    <toolitem action='FileNew' />"
  57.218 +      "    <toolitem action='FileOpen' />"
  57.219 +      "    <toolitem action='FileSave' />"
  57.220 +      "    <toolitem action='Close' />"
  57.221 +      "    <separator />"
  57.222 +      "    <toolitem action='ViewZoomIn' />"
  57.223 +      "    <toolitem action='ViewZoomOut' />"
  57.224 +      "    <toolitem action='ViewZoom100' />"
  57.225 +      "    <toolitem action='ViewZoomFit' />"
  57.226 +      "    <separator />"
  57.227 +      "    <toolitem action='MoveItem' />"
  57.228 +      "    <toolitem action='CreateNode' />"
  57.229 +      "    <toolitem action='CreateArc' />"
  57.230 +      "    <toolitem action='EraseItem' />"
  57.231 +      "    <toolitem action='EditArcMap' />"
  57.232 +      "    <separator />"
  57.233 +      "    <toolitem action='AddMap' />"
  57.234 +      "    <toolitem action='DesignDigraph' />"
  57.235 +      "    <toolitem action='Eps' />"
  57.236 +      "  </toolbar>"
  57.237 +      "</ui>";
  57.238 +
  57.239 +    uim->add_ui_from_string(ui_info);
  57.240 +
  57.241 +  }
  57.242 +  catch(const Glib::Error& ex)
  57.243 +  {
  57.244 +    std::cerr << "building menus failed: " <<  ex.what();
  57.245 +  }
  57.246 +
  57.247 +  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
  57.248 +  if (menubar){
  57.249 +    //vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
  57.250 +    table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
  57.251 +  }
  57.252 +
  57.253 +  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
  57.254 +  if (toolbar)
  57.255 +  {
  57.256 +    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
  57.257 +    static_cast<Gtk::Toolbar*>(toolbar)->set_tooltips(true);
  57.258 +    //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET);
  57.259 +
  57.260 +    table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
  57.261 +
  57.262 +  }
  57.263 + 
  57.264 +  table2.set_row_spacings(10);
  57.265 +  table2.set_col_spacings(5);
  57.266 +
  57.267 +  auto_scale = Gtk::manage(new Gtk::CheckButton("Autoscale"));
  57.268 +  auto_scale->set_active(false);
  57.269 +  auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
  57.270 +  table2.attach(*auto_scale, 0,2,0,1);
  57.271 +
  57.272 +  Gtk::Label * width_label=Gtk::manage(new Gtk::Label("Arc Width:"));
  57.273 +  table2.attach(*width_label, 0,1,1,2);
  57.274 +  
  57.275 +  Gtk::Adjustment * adjustment_width=Gtk::manage(new Gtk::Adjustment(20, 1, 200, 5, 10));
  57.276 +  
  57.277 +  arc_width = Gtk::manage(new Gtk::SpinButton(*adjustment_width, 5,0));
  57.278 +  arc_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
  57.279 +  table2.attach(*arc_width, 1,2,1,2);
  57.280 +
  57.281 +  Gtk::Label * radius_label= Gtk::manage(new Gtk::Label("Node Radius:"));
  57.282 +  table2.attach(*radius_label, 2,3,1,2);
  57.283 +  
  57.284 +  Gtk::Adjustment * adjustment_radius=Gtk::manage(new Gtk::Adjustment(20, 0, 500, 5, 10));
  57.285 +
  57.286 +  radius_size = Gtk::manage(new Gtk::SpinButton(*adjustment_radius, 5,0));
  57.287 +  radius_size->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
  57.288 +  table2.attach(*radius_size, 3,4,1,2);
  57.289 +
  57.290 +  zoom_track = Gtk::manage(new Gtk::CheckButton("Zoom tracking"));
  57.291 +  zoom_track->set_active(false);
  57.292 +  zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
  57.293 +  table2.attach(*zoom_track, 2,4,0,1);
  57.294 +
  57.295 +
  57.296 +  table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
  57.297 +
  57.298 +  tooltips=Gtk::manage(new Gtk::Tooltips());
  57.299 +  if(tooltips)
  57.300 +    {
  57.301 +      tooltips->set_tip(*zoom_track, "If on, arc widths and node radiuses are constant, independent from zooming");
  57.302 +      tooltips->set_tip(*auto_scale, "If on, glemon automatically determines the size of arcs and nodes");
  57.303 +      tooltips->set_tip(*radius_size, "Sets maximum node radius, if auto-scale is off");
  57.304 +      tooltips->set_tip(*arc_width, "Sets maximum arc width, if auto-scale is off");
  57.305 +
  57.306 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileNew"))->set_tooltip(*tooltips, "Inserts new tab");
  57.307 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileOpen"))->set_tooltip(*tooltips, "Lets you open a file");
  57.308 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/FileSave"))->set_tooltip(*tooltips, "Saves the digraph on the active tab");
  57.309 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/Close"))->set_tooltip(*tooltips, "Closes the active tab");
  57.310 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomIn"))->set_tooltip(*tooltips, "Zoom in the digraph");
  57.311 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomOut"))->set_tooltip(*tooltips, "Zoom out the digraph");
  57.312 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoom100"))->set_tooltip(*tooltips, "Shows actual size of digraph");
  57.313 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomFit"))->set_tooltip(*tooltips, "Fits digraph into window");
  57.314 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/MoveItem"))->set_tooltip(*tooltips, "Moves the clicked item (arc/node)");
  57.315 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateNode"))->set_tooltip(*tooltips, "Adds new node");
  57.316 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/CreateArc"))->set_tooltip(*tooltips, "Lets you create new arc");
  57.317 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EraseItem"))->set_tooltip(*tooltips, "Erases the clicked item (arc/node)");
  57.318 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EditArcMap"))->set_tooltip(*tooltips, "Lets you edit the values written on the items");
  57.319 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/AddMap"))->set_tooltip(*tooltips, "Adds arc/nodemap");
  57.320 +      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/DesignDigraph"))->set_tooltip(*tooltips, "Redesigns your digraph, supposing elastic arcs and propulsation of nodes.");
  57.321 +
  57.322 +      tooltips->enable();
  57.323 +    }
  57.324 +
  57.325 +  active_tab=-1;
  57.326 +  notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
  57.327 +
  57.328 +  active_tool = MOVE;
  57.329 +
  57.330 +  table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
  57.331 +  
  57.332 +  show_all_children();
  57.333 +}
  57.334 +
  57.335 +MainWin::~MainWin()
  57.336 +{
  57.337 +}
  57.338 +
  57.339 +void MainWin::set_tabtitle(std::string name)
  57.340 +{
  57.341 +  if(strinst.find(name)==strinst.end())
  57.342 +    {
  57.343 +      tabnames[active_tab]=name;
  57.344 +      strinst[name]=1;
  57.345 +    }
  57.346 +  else
  57.347 +    {
  57.348 +      strinst[name]++;
  57.349 +      std::ostringstream o;
  57.350 +      o << strinst[name];
  57.351 +      tabnames[active_tab]=name+" - "+o.str();
  57.352 +    }
  57.353 +  set_title(tabnames[active_tab] + " - " + prog_name);
  57.354 +  notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
  57.355 +  updateAlgoWinTabs();
  57.356 +}
  57.357 +
  57.358 +void MainWin::readFile(const std::string & filename)
  57.359 +{
  57.360 +  newTab();
  57.361 +  tabs[active_tab]->readFile(filename);
  57.362 +}
  57.363 +
  57.364 +void MainWin::newTab()
  57.365 +{
  57.366 +  int size=tabs.size();
  57.367 +  tabs.resize(size+1);
  57.368 +  tabnames.resize(size+1);
  57.369 +  active_tab=size;
  57.370 +  tabs[active_tab]=Gtk::manage(new NoteBookTab());
  57.371 +  tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle));
  57.372 +  tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal));
  57.373 +  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
  57.374 +  notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
  57.375 +  notebook.set_current_page(size);
  57.376 +  set_tabtitle(_("unsaved file"));
  57.377 +  updateAlgoWinTabs();
  57.378 +}
  57.379 +
  57.380 +void MainWin::closeTab()
  57.381 +{
  57.382 +  if(active_tab!=-1)
  57.383 +    {
  57.384 +      if (tabs[active_tab]->mapstorage->getModified())
  57.385 +	{
  57.386 +	  Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, 
  57.387 +				     Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
  57.388 +	  mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT);
  57.389 +	  mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  57.390 +	  mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
  57.391 +	  switch (mdialog.run())
  57.392 +	    {
  57.393 +	    case Gtk::RESPONSE_CANCEL:
  57.394 +	      return;
  57.395 +	    case Gtk::RESPONSE_REJECT:
  57.396 +	      break;
  57.397 +	    case Gtk::RESPONSE_ACCEPT:
  57.398 +	      tabs[active_tab]->saveFile();
  57.399 +	      break;
  57.400 +	    }
  57.401 +	}
  57.402 +      //tabs vector will be decreased with the deleted value
  57.403 +      int size=tabs.size();
  57.404 +      if(size>1)
  57.405 +	{
  57.406 +	  for(int i=active_tab+1;i<size;i++)
  57.407 +	    {
  57.408 +	      tabnames[i-1]=tabnames[i];
  57.409 +	      tabs[i-1]=tabs[i];
  57.410 +	    }
  57.411 +	}
  57.412 +      //if size==1 resize will delete the only element
  57.413 +      tabs.resize(size-1);
  57.414 +      tabnames.resize(size-1);
  57.415 +
  57.416 +      int old_active_tab=active_tab;
  57.417 +      notebook.remove_page(active_tab);
  57.418 +
  57.419 +      //If the first tab was active, upon delete notebook
  57.420 +      //will first switch one tab upper and not lower like
  57.421 +      //in the case, when not the first tab was active.
  57.422 +      //But after deletion it will become the first tab,
  57.423 +      //and this should be registrated in tabs vector,
  57.424 +      //as well.
  57.425 +      if((old_active_tab==0)&&(size!=1))
  57.426 +	{
  57.427 +	  onChangeTab(NULL,0);
  57.428 +	}
  57.429 +
  57.430 +      //if this was the last page in notebook, there is
  57.431 +      //no active_tab now
  57.432 +      if(size==1)
  57.433 +	{
  57.434 +	  active_tab=-1;
  57.435 +	}
  57.436 +
  57.437 +      updateAlgoWinTabs();
  57.438 +    }
  57.439 +}
  57.440 +
  57.441 +void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num)
  57.442 +{
  57.443 +  page=page;
  57.444 +  active_tab=page_num;
  57.445 +  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
  57.446 +  set_title(tabnames[active_tab]);
  57.447 +  bool autoscale;
  57.448 +  bool zoomtrack;
  57.449 +  double width;
  57.450 +  double radius;
  57.451 +  tabs[active_tab]->getView(autoscale, zoomtrack, width, radius);
  57.452 +  arc_width->set_value(width);
  57.453 +  radius_size->set_value(radius);
  57.454 +  zoom_track->set_active(zoomtrack);
  57.455 +  auto_scale->set_active(autoscale);
  57.456 +
  57.457 +}
  57.458 +
  57.459 +void MainWin::newFile()
  57.460 +{
  57.461 +  if(active_tab!=-1)
  57.462 +    {
  57.463 +      tabs[active_tab]->newFile();
  57.464 +    }
  57.465 +}
  57.466 + 
  57.467 +void MainWin::openFile()
  57.468 +{
  57.469 +  if(active_tab==-1)
  57.470 +    {
  57.471 +      newTab();
  57.472 +    }
  57.473 +  tabs[active_tab]->openFile();
  57.474 +}
  57.475 + 
  57.476 +void MainWin::saveFile()
  57.477 +{
  57.478 +  if(active_tab!=-1)
  57.479 +    {
  57.480 +      tabs[active_tab]->saveFile();
  57.481 +    }
  57.482 +}
  57.483 + 
  57.484 +void MainWin::saveFileAs()
  57.485 +{
  57.486 +  if(active_tab!=-1)
  57.487 +    {
  57.488 +      tabs[active_tab]->saveFileAs();
  57.489 +    }
  57.490 +}
  57.491 + 
  57.492 +void MainWin::close()
  57.493 +{
  57.494 +  if(active_tab!=-1)
  57.495 +    {
  57.496 +      tabs[active_tab]->close();
  57.497 +    }
  57.498 +}
  57.499 +
  57.500 +void MainWin::zoomIn()
  57.501 +{
  57.502 +  if(active_tab!=-1)
  57.503 +    {
  57.504 +      tabs[active_tab]->gd_canvas->zoomIn();
  57.505 +    }
  57.506 +}
  57.507 +
  57.508 +void MainWin::zoomOut()
  57.509 +{
  57.510 +  if(active_tab!=-1)
  57.511 +    {
  57.512 +      tabs[active_tab]->gd_canvas->zoomOut();
  57.513 +    }
  57.514 +}
  57.515 +
  57.516 +void MainWin::zoomFit()
  57.517 +{
  57.518 +  if(active_tab!=-1)
  57.519 +    {
  57.520 +      tabs[active_tab]->gd_canvas->zoomFit();
  57.521 +    }
  57.522 +}
  57.523 +
  57.524 +void MainWin::zoom100()
  57.525 +{
  57.526 +  if(active_tab!=-1)
  57.527 +    {
  57.528 +      tabs[active_tab]->gd_canvas->zoom100();
  57.529 +    }
  57.530 +}
  57.531 +
  57.532 +void MainWin::createMapWin()
  57.533 +{
  57.534 +  if(active_tab!=-1)
  57.535 +    {
  57.536 +      tabs[active_tab]->createMapWin(tabnames[active_tab]);
  57.537 +    }
  57.538 +}
  57.539 +
  57.540 +void MainWin::createDesignWin()
  57.541 +{
  57.542 +  if(active_tab!=-1)
  57.543 +    {
  57.544 +      tabs[active_tab]->createDesignWin(tabnames[active_tab]);
  57.545 +    }
  57.546 +}
  57.547 +
  57.548 +void MainWin::createAlgoWin(int algoid)
  57.549 +{
  57.550 +  AlgoWin * aw=Gtk::manage(new AlgoWin(algoid, tabnames));
  57.551 +  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
  57.552 +  aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
  57.553 +  aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString));
  57.554 +  aws.insert(aw);
  57.555 +  aw->show();
  57.556 +}
  57.557 +
  57.558 +void MainWin::updateAlgoWinTabs()
  57.559 +{
  57.560 +  std::set< AlgoWin* >::iterator awsi=aws.begin();
  57.561 +  for(;awsi!=aws.end();awsi++)
  57.562 +    {
  57.563 +      (*awsi)->update_tablist(tabnames);
  57.564 +    }
  57.565 +}
  57.566 +
  57.567 +void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
  57.568 +{
  57.569 +  int i=0;
  57.570 +  for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
  57.571 +    {
  57.572 +    }
  57.573 +  awp->update_maplist(tabs[i]->mapstorage);
  57.574 +}
  57.575 +
  57.576 +void MainWin::deRegisterAlgoWin(AlgoWin * awp)
  57.577 +{
  57.578 +  aws.erase(awp);
  57.579 +}
  57.580 +
  57.581 +void MainWin::changeEditorialTool(int tool)
  57.582 +{
  57.583 +  active_tool=tool;
  57.584 +  if(active_tab!=-1)
  57.585 +    {
  57.586 +      tabs[active_tab]->gd_canvas->changeEditorialTool(tool);
  57.587 +    }
  57.588 +}
  57.589 +
  57.590 +void MainWin::createNewMapWin()
  57.591 +{
  57.592 +  if(active_tab!=-1)
  57.593 +    {
  57.594 +      NewMapWin * nmw=Gtk::manage(new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])));
  57.595 +      nmw->show();
  57.596 +    }
  57.597 +}
  57.598 +
  57.599 +void MainWin::createNewMapWinTabString(std::string tabname, bool itisarc)
  57.600 +{
  57.601 +  int i=0;
  57.602 +  for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++)
  57.603 +    {
  57.604 +    }
  57.605 +  createNewMapWinAfterSignal(tabs[i], itisarc);
  57.606 +}
  57.607 +
  57.608 +void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisarc)
  57.609 +{
  57.610 +  std::vector<NoteBookTab*>::iterator nbti=tabs.begin();
  57.611 +  int i=0;
  57.612 +  for(;nbti!=tabs.end();nbti++)
  57.613 +    {
  57.614 +      if(*nbti!=nbt)
  57.615 +	{
  57.616 +	  i++;
  57.617 +	}
  57.618 +      else
  57.619 +	{
  57.620 +	  continue;
  57.621 +	}
  57.622 +    }
  57.623 +  NewMapWin * nmw=Gtk::manage(new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisarc, false));
  57.624 +  nmw->run();
  57.625 +}
  57.626 +
  57.627 +
  57.628 +void MainWin::nodeViewChanged()
  57.629 +{
  57.630 +  double width=arc_width->get_value();
  57.631 +  double radius=radius_size->get_value();
  57.632 +  bool zoomtrack=zoom_track->get_active();
  57.633 +  bool autoscale=auto_scale->get_active();
  57.634 +  tabs[active_tab]->setView(autoscale, zoomtrack, width, radius);
  57.635 +}
  57.636 +
  57.637 +void MainWin::reDesignDigraph()
  57.638 +{
  57.639 +  tabs[active_tab]->reDesignDigraph();
  57.640 +}
  57.641 +
  57.642 +void MainWin::createSaveDetailsDialog()
  57.643 +{
  57.644 +  SaveDetailsDialog dialog(tabs[active_tab]->mapstorage);
  57.645 +  dialog.run();
  57.646 +}
  57.647 +
  57.648 +void MainWin::exportToEPS()
  57.649 +{
  57.650 +  if(active_tab!=-1)
  57.651 +    {
  57.652 +      tabs[active_tab]->createExportToEPSWin(tabnames[active_tab]);
  57.653 +    }
  57.654 +}
  57.655 +
  57.656 +void MainWin::createBackgroundChooser()
  57.657 +{
  57.658 +  BackgroundChooserDialog dialog(tabs[active_tab]->mapstorage);
  57.659 +  dialog.run();
  57.660 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/main_win.h	Mon Jul 07 08:10:39 2008 -0500
    58.3 @@ -0,0 +1,273 @@
    58.4 +/* -*- C++ -*-
    58.5 + *
    58.6 + * This file is a part of LEMON, a generic C++ optimization library
    58.7 + *
    58.8 + * Copyright (C) 2003-2006
    58.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   58.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   58.11 + *
   58.12 + * Permission to use, modify and distribute this software is granted
   58.13 + * provided that this copyright notice appears in all copies. For
   58.14 + * precise terms see the accompanying LICENSE file.
   58.15 + *
   58.16 + * This software is provided "AS IS" with no warranty of any kind,
   58.17 + * express or implied, and with no claim as to its suitability for any
   58.18 + * purpose.
   58.19 + *
   58.20 + */
   58.21 +
   58.22 +#ifndef MAIN_WIN_H
   58.23 +#define MAIN_WIN_H
   58.24 +
   58.25 +#include "all_include.h"
   58.26 +#include <libgnomecanvasmm.h>
   58.27 +#include <libgnomecanvasmm/polygon.h>
   58.28 +#include <set>
   58.29 +
   58.30 +class AlgoWin;
   58.31 +class NoteBookTab;
   58.32 +
   58.33 +///This class is the main window of GUI.
   58.34 +
   58.35 +///It has menus, and a notebook. Notebook has different pages,
   58.36 +///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which digraphs can be drawn.
   58.37 +///To manage creation and close of tabs and tabswitching is the task of MainWin.
   58.38 +class MainWin : public Gtk::Window
   58.39 +{
   58.40 +  ///Container in which the menus and the notebook is.
   58.41 +  //Gtk::VBox vbox;
   58.42 +  Gtk::Table table;
   58.43 +  Gtk::Table table2;
   58.44 +
   58.45 +  ///Container in which the toolbar and the node parametrizer is.
   58.46 +  Gtk::HBox hbox;
   58.47 +
   58.48 +  ///Should nodes be autoscaled or not?
   58.49 +  Gtk::CheckButton * auto_scale;
   58.50 +
   58.51 +  ///Should node size track zoom factor?
   58.52 +  Gtk::CheckButton * zoom_track;
   58.53 +
   58.54 +  ///Minimum and maximum node radius entry
   58.55 +  Gtk::SpinButton * radius_size, * arc_width;
   58.56 +
   58.57 +  ///The notebook that has tabs (\ref NoteBookTab) with different digraphs.
   58.58 +  Gtk::Notebook notebook;
   58.59 +
   58.60 +  ///The tool selected to manipulate digraph.
   58.61 +
   58.62 +  ///It has to be stored, because in case of tabswitching
   58.63 +  ///the correct tool has to be set for the actual digraph.
   58.64 +  int active_tool;
   58.65 +
   58.66 +  ///The number of active tab in the notebook.
   58.67 +  int active_tab;
   58.68 +
   58.69 +  ///Vector of existing tabs in the notebook.
   58.70 +  std::vector<NoteBookTab *> tabs;
   58.71 +
   58.72 +  ///Vector of the name of tabs.
   58.73 +
   58.74 +  ///All \ref NoteBookTab has a name that is stored here. The index of the name
   58.75 +  ///is the same as the index of the \ref NoteBookTab in \ref tabs.
   58.76 +  std::vector<std::string> tabnames;
   58.77 +
   58.78 +  ///Counter of occurence of the same file names.
   58.79 +
   58.80 +  ///If a file is opened more than once we have to score
   58.81 +  ///the occurences to let the titles on tabs different.
   58.82 +  ///If more than one occurence is present, from the second
   58.83 +  ///one near the filename the number of the occurence appear.
   58.84 +  std::map<std::string, int> strinst;
   58.85 +
   58.86 +  ///Set of opened \ref AlgoWin s.
   58.87 +
   58.88 +  ///More than one \refAlgoWin can be opened. We have to
   58.89 +  ///communicate with them in case of new \ref NoteBookTab creation,
   58.90 +  ///\ref NoteBookTab close, or map change. Therefore we have to score
   58.91 +  ///their occurences.
   58.92 +  std::set< AlgoWin* > aws;
   58.93 +
   58.94 +public:
   58.95 +  
   58.96 +  ///Constructor of the \ref MainWin.
   58.97 +
   58.98 +  ///It creates the menus, the toolbar and the notebook in which
   58.99 +  ///\ref NoteBookTab s take place. \ref NoteBookTab s are the
  58.100 +  ///holder of the canvases on which the digraphs are drawn.
  58.101 +  MainWin();
  58.102 +
  58.103 +  ~MainWin();
  58.104 +  ///Sets title of tabs.
  58.105 +
  58.106 +  ///It alse registrates it in \ref tabnames. If more than one
  58.107 +  ///occurence is in the notebook of the same file it has to
  58.108 +  ///extend tabname with the number of occurence.
  58.109 +  void set_tabtitle(std::string);
  58.110 +
  58.111 +  ///ActionGroup for menu
  58.112 +  Glib::RefPtr<Gtk::ActionGroup> ag;
  58.113 +
  58.114 +  ///UIManager for menu
  58.115 +  Glib::RefPtr<Gtk::UIManager> uim;
  58.116 +
  58.117 +  ///Creates a new \ref NoteBookTab and opens the given file.
  58.118 +
  58.119 +  ///It is called only with command line parameters at stratup.
  58.120 +  void readFile(const std::string &);
  58.121 +
  58.122 +  ///Tooltips
  58.123 +  Gtk::Tooltips * tooltips;
  58.124 +
  58.125 +  //Call-backs of buttons
  58.126 +
  58.127 +  ///Callback for 'FileNew' action.
  58.128 +  virtual void newFile();
  58.129 +  ///Callback for 'FileOpen' action.
  58.130 +  virtual void openFile();
  58.131 +  ///Callback for 'FileSave' action.
  58.132 +  virtual void saveFile();
  58.133 +  ///Callback for 'FileSaveAs' action.
  58.134 +  virtual void saveFileAs();
  58.135 +  ///Callback for 'Close' action.
  58.136 +  virtual void close();
  58.137 +
  58.138 +  //Toolbar
  58.139 +
  58.140 +  ///Callback for 'zoomIn' action.
  58.141 +
  58.142 +  ///It calls the appropriate function in
  58.143 +  ///\ref DigraphDisplayerCanvas
  58.144 +  virtual void zoomIn();
  58.145 +  ///Callback for 'zoomOut' action.
  58.146 +
  58.147 +  ///It calls the appropriate function in
  58.148 +  ///\ref DigraphDisplayerCanvas
  58.149 +  virtual void zoomOut();
  58.150 +  ///Callback for 'zoomFit' action.
  58.151 +
  58.152 +  ///It calls the appropriate function in
  58.153 +  ///\ref DigraphDisplayerCanvas
  58.154 +  virtual void zoomFit();
  58.155 +  ///Callback for 'zoom100' action.
  58.156 +
  58.157 +  ///It calls the appropriate function in
  58.158 +  ///\ref DigraphDisplayerCanvas
  58.159 +  virtual void zoom100();
  58.160 +
  58.161 +  ///Callback for Show Maps menupoint.
  58.162 +
  58.163 +  ///It calls the appropriate function in
  58.164 +  ///\ref NoteBookTab
  58.165 +  virtual void createMapWin();
  58.166 +
  58.167 +  ///Callback for Show Design menupoint.
  58.168 +
  58.169 +  ///It calls the appropriate function in
  58.170 +  ///\ref NoteBookTab
  58.171 +  virtual void createDesignWin();
  58.172 +
  58.173 +  ///Pops up an Algorithm window.
  58.174 +
  58.175 +  ///It not only creates but registrates the newly created \ref AlgoWin.
  58.176 +  ///It is necessary, because in case of changement between tabs or maps
  58.177 +  ///we have to communicate with it. Signals are also have to be connected
  58.178 +  ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration).
  58.179 +  ///\param algo type of the algorithm to run.
  58.180 +  virtual void createAlgoWin(int algo);
  58.181 +
  58.182 +  ///Deregisters AlgoWin
  58.183 +
  58.184 +  ///This is the function connected to the closing signal of \ref AlgoWin.
  58.185 +  ///It only deletes the sender \ref AlgoWin from \ref aws. This function
  58.186 +  ///is called only by the closing \ref AlgoWin itself.
  58.187 +  ///\param aw the \ref AlgoWin to delete.
  58.188 +  virtual void deRegisterAlgoWin(AlgoWin * aw);
  58.189 +
  58.190 +  ///Updates list of tabs in all of the \ref AlgoWin
  58.191 +
  58.192 +  ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin
  58.193 +  ///have to be updated. That is why we score all the opened \ref AlgoWin.
  58.194 +  ///During update \ref tabnames will be passed to each \ref AlgoWin.
  58.195 +  virtual void updateAlgoWinTabs();
  58.196 +
  58.197 +  ///Refresh list of maps in the AlgoWin that requested it.
  58.198 +
  58.199 +  ///In an \ref AlgoWin there is a ComboBoxText, in which
  58.200 +  ///a \ref NoteBookTab can be chosen that contains the digraph and the maps,
  58.201 +  ///on which we would like to run algorithms. If we change the
  58.202 +  ///tab the available maps also have to be updated, because
  58.203 +  ///in the different tabs different maps are available. Therefore
  58.204 +  ///on tab change the \ref AlgoWin emits a signal that contains itself
  58.205 +  ///so that the appropriate maps can be sent to it. For the sake of simplicity
  58.206 +  ///the program answers this call with the mapstorage of the newly selected tab.
  58.207 +  ///\param aw the caller \ref AlgoWin
  58.208 +  ///\param tabname the newly selected tab in the \ref AlgoWin
  58.209 +  virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname);
  58.210 +
  58.211 +  ///Registrates the new digraph-editor tool in hand.
  58.212 +
  58.213 +  ///The editor-tool in hand is global, it is the same for all tab
  58.214 +  ///at the same time. Therefore the active tool has to be scored here (\ref active_tool).
  58.215 +  ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool
  58.216 +  ///to the correct value.
  58.217 +  ///\param tool the newly selected digraph-editor tool (See all_include.h)
  58.218 +  virtual void changeEditorialTool(int tool);
  58.219 +
  58.220 +  ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin
  58.221 +
  58.222 +  ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created.
  58.223 +  ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal.
  58.224 +  ///It sends the caller \ref NoteBookTab and whether an arcmap or a nodemap should be created.
  58.225 +  ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its
  58.226 +  ///correct place.
  58.227 +  ///\param nbt the caller tab
  58.228 +  ///\param itisarc true if arcmap has to be created, false if nodemap
  58.229 +  virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisarc);
  58.230 +
  58.231 +  ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin
  58.232 +
  58.233 +  ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up. 
  58.234 +  ///It emits a signal in this case. This function is bound to that signal.
  58.235 +  ///The signal contains the name of \ref NoteBookTab in which the new map has to be
  58.236 +  ///placed and whether the new map is an arcmap or a nodemap.
  58.237 +  ///\ref tabname the tab in which the new map has to be placed
  58.238 +  ///\ref itisarc true if the new map will be arc map, false if it will be nodemap
  58.239 +  virtual void createNewMapWinTabString(std::string tabname, bool itisarc);
  58.240 +
  58.241 +  ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed.
  58.242 +
  58.243 +  ///In this case a general \ref NewMapWin will be popped up. This means that
  58.244 +  ///both arc and nodemap can be created by it. The new map will be placed in
  58.245 +  ///\MapStorage of the actual selected \ref NoteBookTab.
  58.246 +  virtual void createNewMapWin();
  58.247 +
  58.248 +  //Notebook handlers
  58.249 +  ///Callback for 'FileNewTab' action.
  58.250 +  virtual void newTab();
  58.251 +
  58.252 +  ///Callback for 'FileCloseTab' action.
  58.253 +
  58.254 +  ///It closes the actual \ref NoteBookTab and registrates this event:
  58.255 +  ///data is shifted to the correct places in vectors.
  58.256 +  virtual void closeTab();
  58.257 +
  58.258 +  ///Tabswitching handler
  58.259 +
  58.260 +  ///Sets the variables that have to store the actual state, and it
  58.261 +  ///updates the title of window to the actually selected \ref NoteBookTab.
  58.262 +  virtual void onChangeTab(GtkNotebookPage*, guint);
  58.263 +
  58.264 +  virtual void nodeViewChanged();
  58.265 +
  58.266 +  virtual void reDesignDigraph();
  58.267 +
  58.268 +  /// Pops up a SaveDetailsDialog.
  58.269 +  void createSaveDetailsDialog();
  58.270 +
  58.271 +  virtual void exportToEPS();
  58.272 +
  58.273 +  void createBackgroundChooser();
  58.274 +};
  58.275 +
  58.276 +#endif //MAIN_WIN_H
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/map_value.cc	Mon Jul 07 08:10:39 2008 -0500
    59.3 @@ -0,0 +1,153 @@
    59.4 +#include "map_value.h"
    59.5 +#include <sstream>
    59.6 +#include <iostream>
    59.7 +
    59.8 +MapValue::MapValue()
    59.9 +{
   59.10 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.11 +  has_value = false;
   59.12 +}
   59.13 +
   59.14 +MapValue::MapValue(double d)
   59.15 +{
   59.16 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.17 +  p_value = new double(d);
   59.18 +  type = NUMERIC;
   59.19 +  has_value = true;
   59.20 +}
   59.21 +
   59.22 +MapValue::MapValue(std::string str)
   59.23 +{
   59.24 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.25 +  p_value = new std::string(str);
   59.26 +  type = STRING;
   59.27 +  has_value = true;
   59.28 +}
   59.29 +
   59.30 +MapValue::MapValue(const char* str)
   59.31 +{
   59.32 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.33 +  p_value = new std::string(str);
   59.34 +  type = STRING;
   59.35 +  has_value = true;
   59.36 +}
   59.37 +
   59.38 +MapValue::operator double() const
   59.39 +{
   59.40 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.41 +  if (!has_value) throw IllegalOperation();
   59.42 +  if (type == NUMERIC)
   59.43 +    return *(static_cast<double*>(p_value));
   59.44 +  else
   59.45 +    throw IllegalOperation();
   59.46 +}
   59.47 +
   59.48 +MapValue::operator std::string() const
   59.49 +{
   59.50 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.51 +  if (!has_value) throw IllegalOperation();
   59.52 +  std::string ret;
   59.53 +  switch (type)
   59.54 +  {
   59.55 +    case NUMERIC:
   59.56 +      {
   59.57 +        double d = *(static_cast<double*>(p_value));
   59.58 +        std::ostringstream ostr;
   59.59 +        ostr << d;
   59.60 +        ret = ostr.str();
   59.61 +      }
   59.62 +      break;
   59.63 +    case STRING:
   59.64 +      ret = *(static_cast<std::string*>(p_value));
   59.65 +      break;
   59.66 +  }
   59.67 +  return ret;
   59.68 +}
   59.69 +
   59.70 +MapValue::MapValue(const MapValue& v)
   59.71 +{
   59.72 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.73 +  if (!v.has_value) throw IllegalOperation();
   59.74 +  has_value = true;
   59.75 +  type = v.type;
   59.76 +  switch (v.type)
   59.77 +  {
   59.78 +    case NUMERIC:
   59.79 +      p_value = new double(*(static_cast<double*>(v.p_value)));
   59.80 +      break;
   59.81 +    case STRING:
   59.82 +      p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
   59.83 +      break;
   59.84 +  }
   59.85 +}
   59.86 +
   59.87 +MapValue& MapValue::operator=(const MapValue& v)
   59.88 +{
   59.89 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   59.90 +  if (&v != this)
   59.91 +  {
   59.92 +    if (!v.has_value) throw IllegalOperation();
   59.93 +    clear();
   59.94 +    has_value = true;
   59.95 +    type = v.type;
   59.96 +    switch (v.type)
   59.97 +    {
   59.98 +      case NUMERIC:
   59.99 +        p_value = new double(*(static_cast<double*>(v.p_value)));
  59.100 +        break;
  59.101 +      case STRING:
  59.102 +        p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
  59.103 +        break;
  59.104 +    }
  59.105 +  }
  59.106 +  return *this;
  59.107 +}
  59.108 +
  59.109 +MapValue::~MapValue()
  59.110 +{
  59.111 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  59.112 +  clear();
  59.113 +}
  59.114 +
  59.115 +void MapValue::clear()
  59.116 +{
  59.117 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  59.118 +  if (!has_value) return;
  59.119 +  switch (type)
  59.120 +  {
  59.121 +    case NUMERIC:
  59.122 +      delete static_cast<double*>(p_value);
  59.123 +      break;
  59.124 +    case STRING:
  59.125 +      delete static_cast<std::string*>(p_value);
  59.126 +      break;
  59.127 +  }
  59.128 +}
  59.129 +
  59.130 +MapValue::Type MapValue::getType() const
  59.131 +{
  59.132 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  59.133 +  return type;
  59.134 +}
  59.135 +
  59.136 +bool MapValue::hasValue() const
  59.137 +{
  59.138 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  59.139 +  return has_value;
  59.140 +}
  59.141 +
  59.142 +std::ostream& operator<<(std::ostream &os, const MapValue& v)
  59.143 +{
  59.144 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  59.145 +  if (!v.has_value) return os;
  59.146 +  switch (v.type)
  59.147 +  {
  59.148 +    case MapValue::NUMERIC:
  59.149 +      os << *(static_cast<double*>(v.p_value));
  59.150 +      break;
  59.151 +    case MapValue::STRING:
  59.152 +      os << *(static_cast<std::string*>(v.p_value));
  59.153 +      break;
  59.154 +  }
  59.155 +  return os;
  59.156 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/map_value.h	Mon Jul 07 08:10:39 2008 -0500
    60.3 @@ -0,0 +1,43 @@
    60.4 +#ifndef MAP_VALUE_H
    60.5 +#define MAP_VALUE_H
    60.6 +
    60.7 +#include <exception>
    60.8 +#include <functional>
    60.9 +#include <iosfwd>
   60.10 +
   60.11 +class MapValue
   60.12 +{
   60.13 +  public:
   60.14 +    friend std::ostream& operator<<(std::ostream &os, const MapValue& v);
   60.15 +    class IllegalOperation : public std::exception
   60.16 +    {
   60.17 +      virtual const char* what() const throw()
   60.18 +      {
   60.19 +        return "Illegal operation.";
   60.20 +      }
   60.21 +    };
   60.22 +    typedef enum
   60.23 +    {
   60.24 +      NUMERIC = 1 << 0,
   60.25 +      STRING  = 1 << 1
   60.26 +    } Type;
   60.27 +  private:
   60.28 +    bool has_value;
   60.29 +    void* p_value;
   60.30 +    MapValue::Type type;
   60.31 +    void clear();
   60.32 +  public:
   60.33 +    MapValue();
   60.34 +    MapValue(double);
   60.35 +    MapValue(std::string);
   60.36 +    MapValue(const char* str);
   60.37 +    MapValue(const MapValue& v);
   60.38 +    MapValue& operator=(const MapValue& v);
   60.39 +    ~MapValue();
   60.40 +    operator std::string() const;
   60.41 +    operator double() const;
   60.42 +    Type getType() const;
   60.43 +    bool hasValue() const;
   60.44 +};
   60.45 +
   60.46 +#endif
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/map_value_map.cc	Mon Jul 07 08:10:39 2008 -0500
    61.3 @@ -0,0 +1,32 @@
    61.4 +#include "map_value_map.h"
    61.5 +#include "mapstorage.h"
    61.6 +
    61.7 +MapValueArcMap::MapValueArcMap(const std::string& _mapName, MapStorage* _pMapStorage) :
    61.8 +  mapName(_mapName),
    61.9 +  pMapStorage(_pMapStorage)
   61.10 +{
   61.11 +}
   61.12 +
   61.13 +MapValueArcMap::Value MapValueArcMap::operator[](Key k) const {
   61.14 +  return pMapStorage->get(mapName, k);
   61.15 +}
   61.16 +
   61.17 +void MapValueArcMap::set(Key k, Value v)
   61.18 +{
   61.19 +  pMapStorage->set(mapName, k, v);
   61.20 +}
   61.21 +
   61.22 +MapValueNodeMap::MapValueNodeMap(const std::string& _mapName, MapStorage* _pMapStorage) :
   61.23 +  mapName(_mapName),
   61.24 +  pMapStorage(_pMapStorage)
   61.25 +{
   61.26 +}
   61.27 +
   61.28 +MapValueNodeMap::Value MapValueNodeMap::operator[](Key k) const {
   61.29 +  return pMapStorage->get(mapName, k);
   61.30 +}
   61.31 +
   61.32 +void MapValueNodeMap::set(Key k, Value v)
   61.33 +{
   61.34 +  pMapStorage->set(mapName, k, v);
   61.35 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/map_value_map.h	Mon Jul 07 08:10:39 2008 -0500
    62.3 @@ -0,0 +1,36 @@
    62.4 +#ifndef MAP_VALUE_MAP_H
    62.5 +#define MAP_VALUE_MAP_H
    62.6 +
    62.7 +#include "map_value.h"
    62.8 +#include <string>
    62.9 +#include "all_include.h"
   62.10 +
   62.11 +class MapStorage;
   62.12 +
   62.13 +class MapValueArcMap
   62.14 +{
   62.15 +  private:
   62.16 +    std::string mapName;
   62.17 +    MapStorage* pMapStorage;
   62.18 +  public:
   62.19 +    typedef MapValue Value;
   62.20 +    typedef Digraph::Arc Key;
   62.21 +    MapValueArcMap(const std::string&, MapStorage*);
   62.22 +    Value operator[](Key k) const;
   62.23 +    void set(Key k, Value v);
   62.24 +};
   62.25 +
   62.26 +class MapValueNodeMap
   62.27 +{
   62.28 +  private:
   62.29 +    std::string mapName;
   62.30 +    MapStorage* pMapStorage;
   62.31 +  public:
   62.32 +    typedef MapValue Value;
   62.33 +    typedef Digraph::Node Key;
   62.34 +    MapValueNodeMap(const std::string&, MapStorage*);
   62.35 +    Value operator[](Key k) const;
   62.36 +    void set(Key k, Value v);
   62.37 +};
   62.38 +
   62.39 +#endif
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/map_win.cc	Mon Jul 07 08:10:39 2008 -0500
    63.3 @@ -0,0 +1,204 @@
    63.4 +/* -*- C++ -*-
    63.5 + *
    63.6 + * This file is a part of LEMON, a generic C++ optimization library
    63.7 + *
    63.8 + * Copyright (C) 2003-2006
    63.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   63.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   63.11 + *
   63.12 + * Permission to use, modify and distribute this software is granted
   63.13 + * provided that this copyright notice appears in all copies. For
   63.14 + * precise terms see the accompanying LICENSE file.
   63.15 + *
   63.16 + * This software is provided "AS IS" with no warranty of any kind,
   63.17 + * express or implied, and with no claim as to its suitability for any
   63.18 + * purpose.
   63.19 + *
   63.20 + */
   63.21 +
   63.22 +#include <map_win.h>
   63.23 +#include <nbtab.h>
   63.24 +#include <mapselector.h>
   63.25 +#include <set>
   63.26 +
   63.27 +bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
   63.28 +{
   63.29 +  if(e->keyval==GDK_Escape)
   63.30 +  {
   63.31 +    mytab.closeMapWin();
   63.32 +    //    hide();
   63.33 +  }
   63.34 +  return true;
   63.35 +}
   63.36 +
   63.37 +MapWin::MapWin(const std::string& title,
   63.38 +    std::vector<std::string> n_eml,
   63.39 +    std::vector<std::string> s_eml,
   63.40 +    std::vector<std::string> n_nml,
   63.41 +    std::vector<std::string> s_nml,
   63.42 +    NoteBookTab & mw):mytab(mw)
   63.43 +{
   63.44 +  set_title(title);
   63.45 +  set_default_size(200, 50);
   63.46 +
   63.47 +  set_resizable(false);
   63.48 +
   63.49 +  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
   63.50 +
   63.51 +  mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title));
   63.52 +
   63.53 +  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
   63.54 +
   63.55 +  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
   63.56 +
   63.57 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   63.58 +  {
   63.59 +    switch (i)
   63.60 +    {
   63.61 +      case E_WIDTH:
   63.62 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   63.63 +            mytab.getActiveArcMap(i), arc_property_strings[i],
   63.64 +            true, true, NUM);
   63.65 +        break;
   63.66 +      case E_COLOR:
   63.67 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   63.68 +            mytab.getActiveArcMap(i), arc_property_strings[i],
   63.69 +            true, true, NUM);
   63.70 +        break;
   63.71 +      case E_TEXT:
   63.72 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   63.73 +            mytab.getActiveArcMap(i), arc_property_strings[i],
   63.74 +            true, true, ALL);
   63.75 +        break;
   63.76 +    }
   63.77 +
   63.78 +    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   63.79 +
   63.80 +    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::arcMapChanged), i));
   63.81 +    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
   63.82 +  }
   63.83 +
   63.84 +  vbox.pack_start(*(new Gtk::Label("Arc properties")));
   63.85 +
   63.86 +  vbox.pack_start(*table);
   63.87 +
   63.88 +  vbox.pack_start(*(new Gtk::HSeparator));
   63.89 +
   63.90 +  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
   63.91 +
   63.92 +  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
   63.93 +
   63.94 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
   63.95 +  {
   63.96 +    switch (i)
   63.97 +    {
   63.98 +      case N_RADIUS:
   63.99 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
  63.100 +            mytab.getActiveNodeMap(i), node_property_strings[i],
  63.101 +            false, true, NUM);
  63.102 +        break;
  63.103 +      case N_COLOR:
  63.104 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
  63.105 +            mytab.getActiveNodeMap(i), node_property_strings[i],
  63.106 +            false, true, NUM);
  63.107 +        break;
  63.108 +      case N_TEXT:
  63.109 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
  63.110 +            mytab.getActiveNodeMap(i), node_property_strings[i],
  63.111 +            false, true, ALL);
  63.112 +        break;
  63.113 +    }
  63.114 +
  63.115 +    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
  63.116 +
  63.117 +    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
  63.118 +    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
  63.119 +  }
  63.120 +
  63.121 +  add(vbox);
  63.122 +
  63.123 +  vbox.pack_start(*(new Gtk::Label("Node properties")));
  63.124 +
  63.125 +  vbox.pack_start(*table);
  63.126 +
  63.127 +  update(n_eml, s_eml, n_nml, s_nml);
  63.128 +
  63.129 +  show_all_children();
  63.130 +
  63.131 +}
  63.132 +
  63.133 +void MapWin::nodeMapChanged(std::string mapname, int prop)
  63.134 +{
  63.135 +  mytab.propertyChange(false, prop, mapname);
  63.136 +}
  63.137 +
  63.138 +void MapWin::arcMapChanged(std::string mapname, int prop)
  63.139 +{
  63.140 +  mytab.propertyChange(true, prop, mapname);
  63.141 +}
  63.142 +
  63.143 +void MapWin::newMapWinNeeded(bool itisarc)
  63.144 +{
  63.145 +  mytab.popupNewMapWin(itisarc);
  63.146 +}
  63.147 +
  63.148 +void MapWin::update(
  63.149 +    std::vector<std::string> n_eml,
  63.150 +    std::vector<std::string> s_eml,
  63.151 +    std::vector<std::string> n_nml,
  63.152 +    std::vector<std::string> s_nml)
  63.153 +{
  63.154 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  63.155 +  {
  63.156 +    e_combo_array[i]->update_list(n_eml, s_eml);
  63.157 +  }
  63.158 +
  63.159 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  63.160 +  {
  63.161 +    n_combo_array[i]->update_list(n_nml, s_nml);
  63.162 +  }
  63.163 +
  63.164 +  mytab.active_maps_needed();
  63.165 +}
  63.166 +
  63.167 +void MapWin::registerNewArcMap(std::string newmapname, MapValue::Type type)
  63.168 +{
  63.169 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  63.170 +  {
  63.171 +    //filling in combo box with choices
  63.172 +    e_combo_array[i]->append_text((Glib::ustring)newmapname, type);
  63.173 +  }
  63.174 +}
  63.175 +
  63.176 +void MapWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
  63.177 +{
  63.178 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  63.179 +  {
  63.180 +    //filling in combo box with choices
  63.181 +    n_combo_array[i]->append_text((Glib::ustring)newmapname, type);
  63.182 +  }
  63.183 +}
  63.184 +
  63.185 +bool MapWin::on_delete_event(GdkEventAny * event)
  63.186 +{
  63.187 +  event=event;
  63.188 +  mytab.closeMapWin();
  63.189 +  return true;
  63.190 +}
  63.191 +
  63.192 +void MapWin::changeEntry(bool isitarc, int prop, std::string mapname)
  63.193 +{
  63.194 +  if(isitarc)
  63.195 +    {
  63.196 +      e_combo_array[prop]->set_active_text(mapname);
  63.197 +    }
  63.198 +  else
  63.199 +    {
  63.200 +      n_combo_array[prop]->set_active_text(mapname);
  63.201 +    }
  63.202 +}
  63.203 +
  63.204 +void MapWin::set_title(std::string tabname)
  63.205 +{
  63.206 +  Gtk::Window::set_title("Map Setup - "+tabname);
  63.207 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/map_win.h	Mon Jul 07 08:10:39 2008 -0500
    64.3 @@ -0,0 +1,142 @@
    64.4 +/* -*- C++ -*-
    64.5 + *
    64.6 + * This file is a part of LEMON, a generic C++ optimization library
    64.7 + *
    64.8 + * Copyright (C) 2003-2006
    64.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   64.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   64.11 + *
   64.12 + * Permission to use, modify and distribute this software is granted
   64.13 + * provided that this copyright notice appears in all copies. For
   64.14 + * precise terms see the accompanying LICENSE file.
   64.15 + *
   64.16 + * This software is provided "AS IS" with no warranty of any kind,
   64.17 + * express or implied, and with no claim as to its suitability for any
   64.18 + * purpose.
   64.19 + *
   64.20 + */
   64.21 +
   64.22 +#ifndef MAP_WIN_H
   64.23 +#define MAP_WIN_H
   64.24 +
   64.25 +class NoteBookTab;
   64.26 +class MapSelector;
   64.27 +
   64.28 +#include <all_include.h>
   64.29 +#include <libgnomecanvasmm.h>
   64.30 +#include <libgnomecanvasmm/polygon.h>
   64.31 +#include "map_value.h"
   64.32 +
   64.33 +///Digraph visualization setup window.
   64.34 +
   64.35 +///This class is responsible for creating a window,
   64.36 +///on which the visualization attributes can be
   64.37 +///assigned to maps.
   64.38 +class MapWin : public Gtk::Window
   64.39 +{
   64.40 +protected:
   64.41 +  ///\ref NoteBookTab to that the \ref MapWin belongs to.
   64.42 +  NoteBookTab & mytab;
   64.43 +
   64.44 +  ///Designing element
   64.45 +  Gtk::Table * table;
   64.46 +  
   64.47 +  ///\ref MapSelectors for each property
   64.48 +
   64.49 +  ///Each property has an own \ref MapSelector through which
   64.50 +  ///the map to visualize by the property van be set.
   64.51 +  MapSelector ** e_combo_array;
   64.52 +
   64.53 +  ///\ref MapSelectors for each property
   64.54 +
   64.55 +  ///Each property has an own \ref MapSelector through which
   64.56 +  ///the map to visualize by the property van be set.
   64.57 +  MapSelector ** n_combo_array;
   64.58 +
   64.59 +  ///Information holder
   64.60 +  Gtk::Label * label;
   64.61 +
   64.62 +  ///Container in which elements are organized.
   64.63 +  Gtk::VBox vbox;
   64.64 +
   64.65 +public:
   64.66 +  ///Constructor
   64.67 +
   64.68 +  ///It creates the widgets shown in \ref MapWin and
   64.69 +  ///binds the needed signal to the correct place.
   64.70 +  ///\param title title of window
   64.71 +  ///\param mw the owner \ref NoteBookTab (\ref mytab)
   64.72 +  MapWin(const std::string& title, 
   64.73 +      std::vector<std::string> n_eml,
   64.74 +      std::vector<std::string> s_eml,
   64.75 +      std::vector<std::string> n_nml,
   64.76 +      std::vector<std::string> s_nml,
   64.77 +      NoteBookTab & mw);
   64.78 +
   64.79 +  ///Deregistrates \ref MapWin in its \ref NoteBookTab (\ref mytab)
   64.80 +  virtual bool on_delete_event(GdkEventAny *);
   64.81 +
   64.82 +  ///Handles changement in nodemap selection
   64.83 +
   64.84 +  ///If \ref MapSelector emits a signal that indicates
   64.85 +  ///changement in nodemap selection this function will
   64.86 +  ///be called. It calls the appropriate handler function,
   64.87 +  ///\ref NoteBookTab::propertyChange with parameters describing the changement.
   64.88 +  ///\param mapname the recently selected map
   64.89 +  ///\param prop the changed property
   64.90 +  void nodeMapChanged(std::string mapname, int prop);
   64.91 +
   64.92 +  ///Handles changement in arcmap selection
   64.93 +
   64.94 +  ///If \ref MapSelector emits a signal that indicates
   64.95 +  ///changement in arcmap selection this function will
   64.96 +  ///be called. It calls the appropriate handler function,
   64.97 +  ///\ref NoteBookTab::propertyChange with parameters describing the changement.
   64.98 +  ///\param mapname the recently selected map
   64.99 +  ///\param prop the changed property
  64.100 +  void arcMapChanged(std::string mapname, int prop);
  64.101 +
  64.102 +  ///Indicates to the owner \ref NoteBookTab that a \ref NewMapWin should be opened.
  64.103 +
  64.104 +  ///This function is bound to the
  64.105 +  ///signal emitted by the \ref MapSelector in case of
  64.106 +  ///the user wants to create a new map. It only pass the
  64.107 +  ///information further to the tab owning this \ref MapWin that is needed to open the
  64.108 +  ///\ref NewMapWin. (\ref NoteBookTab::popupNewMapWin)
  64.109 +  ///\param itisarc should the new map will be an arcmap? (or nodemap)
  64.110 +  void newMapWinNeeded(bool itisarc);
  64.111 +
  64.112 +  ///This function inserts name of the new arcmap in the name list in \ref MapSelector s
  64.113 +
  64.114 +  ///\param new_name
  64.115 +  ///name of new map
  64.116 +  void registerNewArcMap(std::string new_name, MapValue::Type type);
  64.117 +
  64.118 +  ///This function inserts name of the new nodemap in the name list in \ref MapSelector s
  64.119 +
  64.120 +  ///\param new_name
  64.121 +  ///name of new map
  64.122 +  void registerNewNodeMap(std::string new_name, MapValue::Type type);
  64.123 +
  64.124 +  ///Close window if Esc key pressed.
  64.125 +  virtual bool closeIfEscapeIsPressed(GdkEventKey*);
  64.126 +
  64.127 +  ///Updates list of maps in all \ref MapSelector
  64.128 +
  64.129 +  ///This function is called by \ref NoteBookTab, when the file
  64.130 +  ///showed in it has changed, therefore the contained maps
  64.131 +  ///have changed as well. \ref NoteBookTab knows, whether it
  64.132 +  ///has to call this function or not from the \ref NoteBookTab::mapwinexists
  64.133 +  ///variable.
  64.134 +  void update(
  64.135 +    std::vector<std::string> n_eml,
  64.136 +    std::vector<std::string> s_eml,
  64.137 +    std::vector<std::string> n_nml,
  64.138 +    std::vector<std::string> s_nml);
  64.139 +
  64.140 +  void changeEntry(bool, int, std::string);
  64.141 +
  64.142 +  void set_title(std::string);
  64.143 +};
  64.144 +
  64.145 +#endif //MAP_WIN_H
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/mapselector.cc	Mon Jul 07 08:10:39 2008 -0500
    65.3 @@ -0,0 +1,189 @@
    65.4 +/* -*- C++ -*-
    65.5 + *
    65.6 + * This file is a part of LEMON, a generic C++ optimization library
    65.7 + *
    65.8 + * Copyright (C) 2003-2006
    65.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   65.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   65.11 + *
   65.12 + * Permission to use, modify and distribute this software is granted
   65.13 + * provided that this copyright notice appears in all copies. For
   65.14 + * precise terms see the accompanying LICENSE file.
   65.15 + *
   65.16 + * This software is provided "AS IS" with no warranty of any kind,
   65.17 + * express or implied, and with no claim as to its suitability for any
   65.18 + * purpose.
   65.19 + *
   65.20 + */
   65.21 +
   65.22 +#include <mapselector.h>
   65.23 +
   65.24 +MapSelector::MapSelector(std::vector<std::string> n_ml,
   65.25 +    std::vector<std::string> s_ml, std::string act,
   65.26 +    std::string labeltext, bool arc, bool d, MapType type) :
   65.27 +  def(d),
   65.28 +  itisarc(arc),
   65.29 +  set_new_map(false),
   65.30 +  label(labeltext),
   65.31 +  map_type(type),
   65.32 +  newbut(Gtk::Stock::NEW)
   65.33 +{
   65.34 +  update_list(n_ml, s_ml);
   65.35 +
   65.36 +  if(act=="")
   65.37 +  {
   65.38 +    cbt.set_active(0);
   65.39 +    default_state=true;
   65.40 +  }
   65.41 +  else
   65.42 +  {
   65.43 +    cbt.set_active_text((Glib::ustring)act);
   65.44 +    default_state=false;
   65.45 +  }
   65.46 +
   65.47 +  //binding signal to the actual entry
   65.48 +  cbt.signal_changed().connect
   65.49 +    (
   65.50 +     sigc::mem_fun((*this), &MapSelector::comboChanged),
   65.51 +     false
   65.52 +    );
   65.53 +
   65.54 +  label.set_width_chars(longest_property_string_length);
   65.55 +
   65.56 +  if(def)
   65.57 +  {
   65.58 +    defbut.set_label("Reset");
   65.59 +    defbut.signal_pressed().connect
   65.60 +      (
   65.61 +       sigc::mem_fun(*this, &MapSelector::reset)
   65.62 +      );
   65.63 +  }
   65.64 +
   65.65 +
   65.66 +  newbut.signal_pressed().connect
   65.67 +    (
   65.68 +     sigc::mem_fun(*this, &MapSelector::new_but_pressed)
   65.69 +    );
   65.70 +
   65.71 +  add(label);
   65.72 +
   65.73 +  add(cbt);
   65.74 +
   65.75 +  if(def)
   65.76 +  {
   65.77 +    add(defbut);
   65.78 +  }
   65.79 +
   65.80 +  add(newbut);
   65.81 +}
   65.82 +
   65.83 +void MapSelector::new_but_pressed()
   65.84 +{
   65.85 +  set_new_map=true;
   65.86 +  signal_newmapwin.emit(itisarc);
   65.87 +}
   65.88 +
   65.89 +void MapSelector::update_list(std::vector<std::string> n_ml,
   65.90 +    std::vector<std::string> s_ml)
   65.91 +{
   65.92 +  int prev_act=cbt.get_active_row_number();
   65.93 +  cbt.clear();
   65.94 +  cbt_content.clear();
   65.95 +
   65.96 +  if (map_type & NUM)
   65.97 +  {
   65.98 +    std::vector< std::string >::iterator emsi=n_ml.begin();
   65.99 +    for(;emsi!=n_ml.end();emsi++)
  65.100 +    {
  65.101 +      cbt.append_text(*emsi);
  65.102 +      cbt_content.push_back(*emsi);
  65.103 +    }
  65.104 +  }
  65.105 +  if (map_type & STR)
  65.106 +  {
  65.107 +    std::vector< std::string >::iterator emsi=s_ml.begin();
  65.108 +    for(;emsi!=s_ml.end();emsi++)
  65.109 +    {
  65.110 +      cbt.append_text(*emsi);
  65.111 +      cbt_content.push_back(*emsi);
  65.112 +    }
  65.113 +  }
  65.114 +  if(def)
  65.115 +    {
  65.116 +      cbt.prepend_text("Default values");
  65.117 +      cbt_content.push_back("Default values");
  65.118 +    }
  65.119 +  if(prev_act!=-1)
  65.120 +    {
  65.121 +      cbt.set_active(prev_act);
  65.122 +    }
  65.123 +}
  65.124 +
  65.125 +void MapSelector::comboChanged()
  65.126 +{
  65.127 +  if(cbt.get_active_row_number()!=0 || !def)
  65.128 +    {
  65.129 +      default_state=false;
  65.130 +      Glib::ustring mapname = cbt.get_active_text();
  65.131 +      if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
  65.132 +	{
  65.133 +	  signal_cbt.emit(mapname);
  65.134 +	}
  65.135 +    }
  65.136 +  else if((!default_state)&&(cbt.get_active_row_number()==0))
  65.137 +    {
  65.138 +      reset();
  65.139 +    }
  65.140 +}
  65.141 +
  65.142 +void MapSelector::reset()
  65.143 +{
  65.144 +  default_state=true;
  65.145 +
  65.146 +  cbt.set_active(0);
  65.147 +
  65.148 +  signal_cbt.emit("");
  65.149 +}
  65.150 +
  65.151 +
  65.152 +Glib::ustring MapSelector::get_active_text()
  65.153 +{
  65.154 +  return cbt.get_active_text();
  65.155 +}
  65.156 +
  65.157 +void MapSelector::set_active_text(Glib::ustring text)
  65.158 +{
  65.159 +  if(text.compare(""))
  65.160 +    {
  65.161 +      cbt.set_active_text(text);
  65.162 +    }
  65.163 +  else
  65.164 +    { 
  65.165 +      cbt.set_active_text("Default values");
  65.166 +    }
  65.167 +}
  65.168 +
  65.169 +void MapSelector::append_text(Glib::ustring text, MapValue::Type type)
  65.170 +{
  65.171 +  if (type & map_type)
  65.172 +  {
  65.173 +    cbt.append_text(text);
  65.174 +    cbt_content.push_back(text);
  65.175 +
  65.176 +    if(set_new_map)
  65.177 +    {
  65.178 +      set_active_text(text);
  65.179 +      set_new_map=false;
  65.180 +    }
  65.181 +  }
  65.182 +}
  65.183 +
  65.184 +sigc::signal<void, std::string> MapSelector::signal_cbt_ch()
  65.185 +{
  65.186 +  return signal_cbt;
  65.187 +}
  65.188 +
  65.189 +sigc::signal<void, bool> MapSelector::signal_newmapwin_needed()
  65.190 +{
  65.191 +  return signal_newmapwin;
  65.192 +}
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/mapselector.h	Mon Jul 07 08:10:39 2008 -0500
    66.3 @@ -0,0 +1,178 @@
    66.4 +/* -*- C++ -*-
    66.5 + *
    66.6 + * This file is a part of LEMON, a generic C++ optimization library
    66.7 + *
    66.8 + * Copyright (C) 2003-2006
    66.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   66.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   66.11 + *
   66.12 + * Permission to use, modify and distribute this software is granted
   66.13 + * provided that this copyright notice appears in all copies. For
   66.14 + * precise terms see the accompanying LICENSE file.
   66.15 + *
   66.16 + * This software is provided "AS IS" with no warranty of any kind,
   66.17 + * express or implied, and with no claim as to its suitability for any
   66.18 + * purpose.
   66.19 + *
   66.20 + */
   66.21 +
   66.22 +#ifndef MAPSELECTOR_H
   66.23 +#define MAPSELECTOR_H
   66.24 +
   66.25 +#include <all_include.h>
   66.26 +#include <libgnomecanvasmm.h>
   66.27 +#include <libgnomecanvasmm/polygon.h>
   66.28 +#include "map_value.h"
   66.29 +
   66.30 +///A widget by which node and arcmaps can be selected, deselected and created.
   66.31 +
   66.32 +///During the usage of \ref glemon we have to select
   66.33 +///maps several times. We also need some aid-function
   66.34 +///like new map creation and deselecting previously
   66.35 +///selected map. Instead of writing a the mapselection
   66.36 +///at all occurences we can use this widget by connecting
   66.37 +///its signals to the correct place.
   66.38 +class MapSelector : public Gtk::HBox
   66.39 +{
   66.40 + protected:
   66.41 +  ///This signal indicates that the selection has been changed by user.
   66.42 +  sigc::signal<void, std::string> signal_cbt;
   66.43 +
   66.44 +  ///Signal that indicates that user wants to create a new map.
   66.45 +  sigc::signal<void, bool> signal_newmapwin;
   66.46 +
   66.47 +  ///If this is true, beyond the mapnames a 'Default' selection is available as well.
   66.48 +
   66.49 +  ///For example \ref MapWin needs 'Default' option as well. In this case no map
   66.50 +  ///will be visualized by the appropriate property.
   66.51 +  ///But \ref AlgoWin do not need 'Default' option, because if no map is selected,
   66.52 +  ///no algorithm can be run.
   66.53 +  ///Its value is got and set in contructor.
   66.54 +  bool def;
   66.55 +
   66.56 +  ///Are the names of arcmaps or nodemaps stored here.
   66.57 +  bool itisarc;
   66.58 +
   66.59 +  ///Shows whether 'Default' option is selected or not.
   66.60 +  bool default_state;
   66.61 +
   66.62 +  ///It is true when the new button had been pressed but the new map has not been registrated yet.
   66.63 +
   66.64 +  ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector
   66.65 +  ///this variable is set to true. When the new map
   66.66 +  ///is done, it will be registrated in all existing \ref MapSelector 
   66.67 +  ///by \ref append_text function. That function checks
   66.68 +  ///whether this variable is true. If it is true that means
   66.69 +  ///that this \ref MapSelector has requested \ref NewMapWin.
   66.70 +  ///Therefore it set itself to the recently created map.
   66.71 +  ///After that \ref set_new_map is set again false, not to
   66.72 +  ///set maps active if \ref MapSelector piece is not the requester.
   66.73 +  bool set_new_map;
   66.74 +
   66.75 +  ///The widget that holds the names of maps.
   66.76 +
   66.77 +  ///It can be rolled down
   66.78 +  ///Names in it are selectable.
   66.79 +  Gtk::ComboBoxText cbt;
   66.80 +
   66.81 +  std::vector<std::string> cbt_content;
   66.82 +
   66.83 +  ///New button.
   66.84 +
   66.85 +  ///By pressing it
   66.86 +  ///\ref NewMapWin wilol pop-up
   66.87 +  Gtk::Button newbut;
   66.88 +
   66.89 +  ///Reset button.
   66.90 +
   66.91 +  ///If pressed \ref cbt will
   66.92 +  ///set to 'Default' option.
   66.93 +  ///
   66.94 +  ///It is visible only if \ref def is true.
   66.95 +  Gtk::Button defbut;
   66.96 +
   66.97 +  ///Shows purpose of \ref MapSelector piece.
   66.98 +  Gtk::Label label;
   66.99 +
  66.100 +  /// Which types of maps (integer, string, ...) to display.
  66.101 +  MapType map_type;
  66.102 +
  66.103 + public:
  66.104 +
  66.105 +  ///Constructor of \ref MapSelector
  66.106 +
  66.107 +  ///Creates the layout and binds signal to the correct place.
  66.108 +  ///\param mapstorage Pointer to the \ref MapStorage to get the map list from.
  66.109 +  ///\param act preselected option
  66.110 +  ///\param purpose text of label indicating purpose of \ref MapStorage
  66.111 +  ///\param itisarc do \ref MapSelector contains arcmap names or nodemapnames.
  66.112 +  ///\param def do we need 'Default' option. See \ref def.
  66.113 +  ///\param type Specifies which types of maps to display.
  66.114 +  MapSelector(std::vector<std::string> n_ml,
  66.115 +      std::vector<std::string> s_ml, std::string act, std::string labeltext,
  66.116 +      bool arc, bool d = true, MapType type = ALL);
  66.117 +
  66.118 +  ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
  66.119 +  sigc::signal<void, std::string> signal_cbt_ch();
  66.120 +
  66.121 +  ///Returns signal emitted if the user has pressed New button (\ref newbut) (\ref signal_newmapwin)
  66.122 +  sigc::signal<void, bool> signal_newmapwin_needed();
  66.123 +
  66.124 +  ///Maintain \ref cbt.
  66.125 +
  66.126 +  ///Fills in \ref cbt with names, taking
  66.127 +  ///into account that the previously selected option
  66.128 +  ///has to be set back after the operation.
  66.129 +  void update_list(std::vector<std::string> n_ml,
  66.130 +      std::vector<std::string> s_ml);
  66.131 +
  66.132 +  ///Handles changement in \ref cbt.
  66.133 +
  66.134 +  ///In default case it emits a signal with the selected option.
  66.135 +  ///But if 'Default' option is selected, it resets the \ref MapSelector
  66.136 +  virtual void comboChanged();
  66.137 +
  66.138 +  ///Requests a \ref NewMapWin
  66.139 +
  66.140 +  ///See \ref set_new_map.
  66.141 +  ///First it sets \ref set_new_map true to be identified
  66.142 +  ///at registration of new map that
  66.143 +  ///it has sent the \ref signal_newmapwin, therefore it
  66.144 +  ///has to set \ref cbt to that option.
  66.145 +  virtual void new_but_pressed();
  66.146 +
  66.147 +  ///If called, 'Default' option is selected, that means unselection of any maps.
  66.148 +
  66.149 +  ///Practically this means that if this is called,
  66.150 +  ///properties of digraph will set to default state.
  66.151 +  ///The function achieves this by emitting appropriately
  66.152 +  ///parametrized signal_cbt.
  66.153 +  virtual void reset();
  66.154 +
  66.155 +  ///Returns the currently selected option.
  66.156 +  Glib::ustring get_active_text();
  66.157 +
  66.158 +  ///Sets the parameter active in \ref cbt.
  66.159 +
  66.160 +  ///\param new_value the
  66.161 +  ///new value to be set in \ref cbt.
  66.162 +  void set_active_text(Glib::ustring new_value);
  66.163 +
  66.164 +  ///Sets the parameter active in \ref cbt.
  66.165 +  ///\param index the
  66.166 +  ///index of row to be set in \ref cbt.
  66.167 +  void set_active(int index){cbt.set_active(index);};
  66.168 +
  66.169 +  ///Clear all options from \ref cbt.
  66.170 +  void clear(){cbt.clear();};
  66.171 +
  66.172 +  ///Appends a new option to the existing ones in \ref cbt.
  66.173 +
  66.174 +  ///If \ref set_new_map is true, the
  66.175 +  ///\ref MapSelector has requested the opened \ref NewMapWin,
  66.176 +  ///from that the option to append is coming. In this case
  66.177 +  ///this function  will set \ref cbt to the new option.
  66.178 +  ///\param new_option new option to append
  66.179 +  void append_text(Glib::ustring new_option, MapValue::Type);
  66.180 +};
  66.181 +#endif //MAPSELECTOR_H
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/mapstorage.cc	Mon Jul 07 08:10:39 2008 -0500
    67.3 @@ -0,0 +1,1534 @@
    67.4 +/* -*- C++ -*-
    67.5 + *
    67.6 + * This file is a part of LEMON, a generic C++ optimization library
    67.7 + *
    67.8 + * Copyright (C) 2003-2006
    67.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   67.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   67.11 + *
   67.12 + * Permission to use, modify and distribute this software is granted
   67.13 + * provided that this copyright notice appears in all cop	ies. For
   67.14 + * precise terms see the accompanying LICENSE file.
   67.15 + *
   67.16 + * This software is provided "AS IS" with no warranty of any kind,
   67.17 + * express or implied, and with no claim as to its suitability for any
   67.18 + * purpose.
   67.19 + *
   67.20 + */
   67.21 +
   67.22 +#include "i18n.h"
   67.23 +#include <limits>
   67.24 +#include <cmath>
   67.25 +#include <iostream>
   67.26 +#include <fstream>
   67.27 +#include <string>
   67.28 +#include <algorithm>
   67.29 +#include <gtkmm.h>
   67.30 +#include "file_import_dialog.h"
   67.31 +#include <mapstorage.h>
   67.32 +#include <gui_writer.h>
   67.33 +#include <gui_reader.h>
   67.34 +#include <lemon/graph_to_eps.h>
   67.35 +#include <lemon/lgf_reader.h>
   67.36 +#include <lemon/lgf_writer.h>
   67.37 +
   67.38 +const int i_d=20;
   67.39 +const double a_d=0.05;
   67.40 +const double p_d=40000;
   67.41 +
   67.42 +MapStorage::MapStorage() :
   67.43 +  gui_sect_save_dest(LGF_FILE),
   67.44 +  node_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
   67.45 +  arrow_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
   67.46 +  modified(false),
   67.47 +  file_name(""),
   67.48 +  max_node_label(0),
   67.49 +  max_arc_label(0),
   67.50 +  node_coords_one_map_name("coord"),
   67.51 +  node_coords_two_maps_1_name("coord_x"),
   67.52 +  node_coords_two_maps_2_name("coord_y"),
   67.53 +  arrow_coords_one_map_name("arrow"),
   67.54 +  arrow_coords_two_maps_1_name("arrow_x"),
   67.55 +  arrow_coords_two_maps_2_name("arrow_y"),
   67.56 +  iterations(i_d),
   67.57 +  attraction(a_d),
   67.58 +  propulsation(p_d),
   67.59 +  node_coords_x(digraph),
   67.60 +  node_coords_y(digraph),
   67.61 +  arrow_coords_x(digraph),
   67.62 +  arrow_coords_y(digraph),
   67.63 +  node_label(digraph),
   67.64 +  arc_label(digraph),
   67.65 +  background_set(false)
   67.66 +{
   67.67 +  node_coords.setXMap(node_coords_x);
   67.68 +  node_coords.setYMap(node_coords_y);
   67.69 +  arrow_coords.setXMap(arrow_coords_x);
   67.70 +  arrow_coords.setYMap(arrow_coords_y);
   67.71 +
   67.72 +  active_nodemaps.resize(NODE_PROPERTY_NUM);
   67.73 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
   67.74 +    {
   67.75 +      active_nodemaps[i]="";
   67.76 +    }
   67.77 +
   67.78 +  active_arcmaps.resize(EDGE_PROPERTY_NUM);
   67.79 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   67.80 +    {
   67.81 +      active_arcmaps[i]="";
   67.82 +    }
   67.83 +}
   67.84 +
   67.85 +MapStorage::~MapStorage()
   67.86 +{
   67.87 +  clear();
   67.88 +}
   67.89 +
   67.90 +void MapStorage::createNodeMap(const std::string& name, MapValue::Type type,
   67.91 +    MapValue def_val)
   67.92 +{
   67.93 +  NodeMapStore::const_iterator it = nodemaps.find(name);
   67.94 +  if (it != nodemaps.end())
   67.95 +    throw Error("Node map " + name + " already exists.");
   67.96 +
   67.97 +  switch (type)
   67.98 +  {
   67.99 +    case MapValue::NUMERIC:
  67.100 +      nodemaps[name] = new NumericNodeMapData(digraph, def_val);
  67.101 +      break;
  67.102 +    case MapValue::STRING:
  67.103 +      nodemaps[name] = new StringNodeMapData(digraph, def_val);
  67.104 +      break;
  67.105 +  }
  67.106 +
  67.107 +  nodemaps[name]->default_value = def_val;
  67.108 +
  67.109 +  signal_node_map.emit(name, type);
  67.110 +}
  67.111 +
  67.112 +void MapStorage::createArcMap(const std::string& name, MapValue::Type type,
  67.113 +    MapValue def_val)
  67.114 +{
  67.115 +  ArcMapStore::const_iterator it = arcmaps.find(name);
  67.116 +  if (it != arcmaps.end())
  67.117 +    throw Error("Arc map " + name + " already exists.");
  67.118 +
  67.119 +  switch (type)
  67.120 +  {
  67.121 +    case MapValue::NUMERIC:
  67.122 +      arcmaps[name] = new NumericArcMapData(digraph, def_val);
  67.123 +      break;
  67.124 +    case MapValue::STRING:
  67.125 +      arcmaps[name] = new StringArcMapData(digraph, def_val);
  67.126 +      break;
  67.127 +  }
  67.128 +
  67.129 +  arcmaps[name]->default_value = def_val;
  67.130 +
  67.131 +  signal_arc_map.emit(name, type);
  67.132 +}
  67.133 +
  67.134 +void MapStorage::changeActiveMap(bool itisarc, int prop, std::string mapname)
  67.135 +{
  67.136 +  if(itisarc)
  67.137 +    {
  67.138 +      active_arcmaps[prop]=mapname;
  67.139 +    }
  67.140 +  else
  67.141 +    {
  67.142 +      active_nodemaps[prop]=mapname;
  67.143 +    }
  67.144 +  signal_prop.emit(itisarc, prop);
  67.145 +}
  67.146 +
  67.147 +void MapStorage::broadcastActiveMaps()
  67.148 +{
  67.149 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  67.150 +    {
  67.151 +      signal_map_win.emit(false, i, active_nodemaps[i]);
  67.152 +    }
  67.153 +  
  67.154 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  67.155 +    {
  67.156 +      signal_map_win.emit(true, i, active_arcmaps[i]);
  67.157 +    }
  67.158 +}
  67.159 +
  67.160 +std::string MapStorage::getActiveArcMap(int prop)
  67.161 +{
  67.162 +  return active_arcmaps[prop];
  67.163 +}
  67.164 +
  67.165 +std::string MapStorage::getActiveNodeMap(int prop)
  67.166 +{
  67.167 +  return active_nodemaps[prop];
  67.168 +}
  67.169 +
  67.170 +std::vector<std::string> MapStorage::getArcMapList(MapType type)
  67.171 +{
  67.172 +  if (type == ALL)
  67.173 +  {
  67.174 +    std::vector<std::string> ret;
  67.175 +    for (ArcMapStore::const_iterator it = arcmaps.begin();
  67.176 +        it != arcmaps.end(); ++it)
  67.177 +    {
  67.178 +      ret.push_back(it->first);
  67.179 +    }
  67.180 +    return ret;
  67.181 +  }
  67.182 +  else
  67.183 +  {
  67.184 +    std::vector<std::string> ret;
  67.185 +    for (ArcMapStore::const_iterator it = arcmaps.begin();
  67.186 +        it != arcmaps.end(); ++it)
  67.187 +    {
  67.188 +      ArcMapData* data = getArcMapData(it->first);
  67.189 +      MapValue::Type t = data->type();
  67.190 +      if ((t == MapValue::NUMERIC && (type & NUM)) ||
  67.191 +          (t == MapValue::STRING && (type & STR)))
  67.192 +      {
  67.193 +        ret.push_back(it->first);
  67.194 +      }
  67.195 +    }
  67.196 +    return ret;
  67.197 +  }
  67.198 +}
  67.199 +
  67.200 +std::vector<std::string> MapStorage::getNodeMapList(MapType type)
  67.201 +{
  67.202 +  if (type == ALL)
  67.203 +  {
  67.204 +    std::vector<std::string> ret;
  67.205 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  67.206 +        it != nodemaps.end(); ++it)
  67.207 +    {
  67.208 +      ret.push_back(it->first);
  67.209 +    }
  67.210 +    return ret;
  67.211 +  }
  67.212 +  else
  67.213 +  {
  67.214 +    std::vector<std::string> ret;
  67.215 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  67.216 +        it != nodemaps.end(); ++it)
  67.217 +    {
  67.218 +      NodeMapData* data = getNodeMapData(it->first);
  67.219 +      MapValue::Type t = data->type();
  67.220 +      if ((t == MapValue::NUMERIC && (type & NUM)) ||
  67.221 +          (t == MapValue::STRING && (type & STR)))
  67.222 +      {
  67.223 +        ret.push_back(it->first);
  67.224 +      }
  67.225 +    }
  67.226 +    return ret;
  67.227 +  }
  67.228 +}
  67.229 +
  67.230 +sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
  67.231 +{
  67.232 +  return signal_prop;
  67.233 +}
  67.234 +
  67.235 +int MapStorage::readFromFile(const std::string &filename)
  67.236 +{
  67.237 +  using std::vector;
  67.238 +  using std::map;
  67.239 +  using std::string;
  67.240 +
  67.241 +  //reading content of file
  67.242 +  LgfContents content(filename);
  67.243 +  try
  67.244 +    {
  67.245 +      content.run();
  67.246 +    }
  67.247 +  catch (Exception& error)
  67.248 +    {
  67.249 +      Gtk::MessageDialog mdialog(error.what());
  67.250 +      mdialog.run();
  67.251 +      clear();
  67.252 +      return 1;
  67.253 +    }
  67.254 +
  67.255 +  // check whether the .conf file exists
  67.256 +  bool gui_data_in_conf = g_file_test((filename + ".conf").c_str(),
  67.257 +      (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR));
  67.258 +
  67.259 +  // check whether the .lgf file contains a gui section
  67.260 +  bool gui_data_in_lgf = false;
  67.261 +  {
  67.262 +    for(int i=0;i<content.extraSectionNum();i++)
  67.263 +      {
  67.264 +	if(content.extraSection(i)=="gui")
  67.265 +	  {
  67.266 +	    gui_data_in_lgf = true;
  67.267 +	  }
  67.268 +      }
  67.269 +  }
  67.270 +
  67.271 +  bool gui_data_found = gui_data_in_lgf || gui_data_in_conf;
  67.272 +
  67.273 +  // ask for user input if both exist
  67.274 +  bool use_gui_data_in_lgf = false;
  67.275 +  if (gui_data_in_conf && gui_data_in_lgf)
  67.276 +  {
  67.277 +    Gtk::MessageDialog mdialog(_("<b>Found both ") + filename +
  67.278 +        _(".conf and a gui section in ") + filename + _(".</b>"), true,
  67.279 +        Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE);
  67.280 +	  mdialog.add_button(_("Use the ._conf file"), 1);
  67.281 +	  mdialog.add_button(_("Use the _gui section"), 2);
  67.282 +    switch (mdialog.run())
  67.283 +    {
  67.284 +      case 1:
  67.285 +        use_gui_data_in_lgf = false;
  67.286 +        break;
  67.287 +      case 2:
  67.288 +        use_gui_data_in_lgf = true;
  67.289 +        break;
  67.290 +      case Gtk::RESPONSE_NONE:
  67.291 +        return 1;
  67.292 +    }
  67.293 +  }
  67.294 +  else
  67.295 +  {
  67.296 +    use_gui_data_in_lgf = gui_data_in_lgf;
  67.297 +  }
  67.298 +
  67.299 +  if (gui_data_found)
  67.300 +  {
  67.301 +    GUISectData gui_data;
  67.302 +    if (use_gui_data_in_lgf)
  67.303 +    {
  67.304 +      // read the gui section from the .lgf file
  67.305 +      try
  67.306 +      {
  67.307 +	sectionReader(filename).sectionStream("gui", GuiReader(this, gui_data)).run();
  67.308 +        gui_sect_save_dest = LGF_FILE;
  67.309 +      }
  67.310 +      catch (Exception& error)
  67.311 +      {
  67.312 +        clear();
  67.313 +        return 1;
  67.314 +      }
  67.315 +    }
  67.316 +    else
  67.317 +    {
  67.318 +      // read the gui section from the .conf file
  67.319 +      try
  67.320 +      {
  67.321 +	sectionReader(filename + ".conf").sectionStream("gui", GuiReader(this, gui_data)).run();
  67.322 +        gui_sect_save_dest = CONF_FILE;
  67.323 +      }
  67.324 +      catch (Exception& error)
  67.325 +      {
  67.326 +        clear();
  67.327 +        return 1;
  67.328 +      }
  67.329 +    }
  67.330 +
  67.331 +    // read the digraph and maps form the .lgf file
  67.332 +    try
  67.333 +    {
  67.334 +      std::string node_coord_xmap_name, node_coord_ymap_name;
  67.335 +      std::string arrow_coord_xmap_name, arrow_coord_ymap_name;
  67.336 +
  67.337 +      if (gui_data.node_coords_save_dest ==
  67.338 +          MapStorage::SpecMapSaveOpts::NESET_SECT)
  67.339 +      {
  67.340 +        switch (gui_data.node_coords_save_map_num)
  67.341 +        {
  67.342 +          case SpecMapSaveOpts::ONE_MAP:
  67.343 +            node_coord_xmap_name = gui_data.node_coords_one_map_name + ":x";
  67.344 +            node_coord_ymap_name = gui_data.node_coords_one_map_name + ":y";
  67.345 +            node_coords_one_map_name = gui_data.node_coords_one_map_name;
  67.346 +            break;
  67.347 +          case SpecMapSaveOpts::TWO_MAPS:
  67.348 +            node_coord_xmap_name = gui_data.node_coords_two_maps_1_name;
  67.349 +            node_coord_ymap_name = gui_data.node_coords_two_maps_2_name;
  67.350 +            node_coords_two_maps_1_name = gui_data.node_coords_two_maps_1_name;
  67.351 +            node_coords_two_maps_2_name = gui_data.node_coords_two_maps_2_name;
  67.352 +            break;
  67.353 +        }
  67.354 +        node_coords_save_dest = gui_data.node_coords_save_dest;
  67.355 +        node_coords_save_map_num = gui_data.node_coords_save_map_num;
  67.356 +      }
  67.357 +
  67.358 +      if (gui_data.arrow_coords_save_dest ==
  67.359 +          MapStorage::SpecMapSaveOpts::NESET_SECT)
  67.360 +      {
  67.361 +        switch (gui_data.arrow_coords_save_map_num)
  67.362 +        {
  67.363 +          case SpecMapSaveOpts::ONE_MAP:
  67.364 +            arrow_coord_xmap_name = gui_data.arrow_coords_one_map_name + ":x";
  67.365 +            arrow_coord_ymap_name = gui_data.arrow_coords_one_map_name + ":y";
  67.366 +            arrow_coords_one_map_name = gui_data.arrow_coords_one_map_name;
  67.367 +            break;
  67.368 +          case SpecMapSaveOpts::TWO_MAPS:
  67.369 +            arrow_coord_xmap_name = gui_data.arrow_coords_two_maps_1_name;
  67.370 +            arrow_coord_ymap_name = gui_data.arrow_coords_two_maps_2_name;
  67.371 +            arrow_coords_two_maps_1_name =
  67.372 +              gui_data.arrow_coords_two_maps_1_name;
  67.373 +            arrow_coords_two_maps_2_name =
  67.374 +              gui_data.arrow_coords_two_maps_2_name;
  67.375 +            break;
  67.376 +        }
  67.377 +        arrow_coords_save_dest = gui_data.arrow_coords_save_dest;
  67.378 +        arrow_coords_save_map_num = gui_data.arrow_coords_save_map_num;
  67.379 +      }
  67.380 +      readLGF(filename, true,
  67.381 +          gui_data.main_node_map_names, gui_data.main_arc_map_names,
  67.382 +          gui_data.node_map_types, gui_data.arc_map_types,
  67.383 +          node_coord_xmap_name, node_coord_ymap_name,
  67.384 +          arrow_coord_xmap_name, arrow_coord_ymap_name);
  67.385 +    }
  67.386 +    catch (Exception& error)
  67.387 +    {
  67.388 +      clear();
  67.389 +      return 1;
  67.390 +    }
  67.391 +
  67.392 +    // add the maps from the gui section
  67.393 +    for (vector<string>::const_iterator
  67.394 +        it = gui_data.gui_node_map_names.begin();
  67.395 +        it != gui_data.gui_node_map_names.end(); ++it)
  67.396 +    {
  67.397 +      string map_name = *it;
  67.398 +      switch (gui_data.node_map_types[map_name])
  67.399 +      {
  67.400 +        case MapValue::NUMERIC:
  67.401 +          {
  67.402 +            createNodeMap(map_name, MapValue::NUMERIC, double());
  67.403 +            NumericNodeMap& dmap = getNumericNodeMap(map_name);
  67.404 +            map<int, double>& smap = *gui_data.numeric_node_maps[map_name];
  67.405 +            for (NodeIt n(digraph); n != INVALID; ++n)
  67.406 +            {
  67.407 +              dmap[n] = smap[node_label[n]];
  67.408 +            }
  67.409 +            break;
  67.410 +          }
  67.411 +        case MapValue::STRING:
  67.412 +          {
  67.413 +            createNodeMap(map_name, MapValue::STRING, string());
  67.414 +            StringNodeMap& dmap = getStringNodeMap(map_name);
  67.415 +            map<int, string>& smap = *gui_data.string_node_maps[map_name];
  67.416 +            for (NodeIt n(digraph); n != INVALID; ++n)
  67.417 +            {
  67.418 +              dmap[n] = smap[node_label[n]];
  67.419 +            }
  67.420 +            break;
  67.421 +          }
  67.422 +      }
  67.423 +      getNodeMapData(map_name)->save_dest = GUI_SECT;
  67.424 +    }
  67.425 +    for (vector<string>::const_iterator
  67.426 +        it = gui_data.gui_arc_map_names.begin();
  67.427 +        it != gui_data.gui_arc_map_names.end(); ++it)
  67.428 +    {
  67.429 +      string map_name = *it;
  67.430 +      switch (gui_data.arc_map_types[map_name])
  67.431 +      {
  67.432 +        case MapValue::NUMERIC:
  67.433 +          {
  67.434 +            createArcMap(map_name, MapValue::NUMERIC, double());
  67.435 +            NumericArcMap& dmap = getNumericArcMap(map_name);
  67.436 +            map<int, double>& smap = *gui_data.numeric_arc_maps[map_name];
  67.437 +            for (ArcIt e(digraph); e != INVALID; ++e)
  67.438 +            {
  67.439 +              dmap[e] = smap[arc_label[e]];
  67.440 +            }
  67.441 +            break;
  67.442 +          }
  67.443 +        case MapValue::STRING:
  67.444 +          {
  67.445 +            createArcMap(map_name, MapValue::STRING, string());
  67.446 +            StringArcMap& dmap = getStringArcMap(map_name);
  67.447 +            map<int, string>& smap = *gui_data.string_arc_maps[map_name];
  67.448 +            for (ArcIt e(digraph); e != INVALID; ++e)
  67.449 +            {
  67.450 +              dmap[e] = smap[arc_label[e]];
  67.451 +            }
  67.452 +            break;
  67.453 +          }
  67.454 +      }
  67.455 +      getArcMapData(map_name)->save_dest = GUI_SECT;
  67.456 +    }
  67.457 +
  67.458 +    // restore the node coordinate maps
  67.459 +    if (gui_data.node_coords_save_dest ==
  67.460 +        MapStorage::SpecMapSaveOpts::GUI_SECT)
  67.461 +    {
  67.462 +      for (NodeIt n(digraph); n != INVALID; ++n)
  67.463 +      {
  67.464 +        node_coords.set(n, gui_data.node_coord_map[node_label[n]]);
  67.465 +      }
  67.466 +      node_coords_save_dest = gui_data.node_coords_save_dest;
  67.467 +    }
  67.468 +    // restore the arrow coordinate maps
  67.469 +    if (gui_data.arrow_coords_save_dest ==
  67.470 +        MapStorage::SpecMapSaveOpts::GUI_SECT)
  67.471 +    {
  67.472 +      for (ArcIt e(digraph); e != INVALID; ++e)
  67.473 +      {
  67.474 +        arrow_coords.set(e, gui_data.arrow_coord_map[arc_label[e]]);
  67.475 +      }
  67.476 +      arrow_coords_save_dest = gui_data.arrow_coords_save_dest;
  67.477 +    }
  67.478 +  }
  67.479 +  else
  67.480 +  {
  67.481 +    // there is no gui section neither in the .lgf file nor in the .conf file
  67.482 +    {
  67.483 +      if (content.nodeSectionNum() < 1)
  67.484 +      {
  67.485 +        Gtk::MessageDialog mdialog("No nodeset found in file.");
  67.486 +        mdialog.run();
  67.487 +        clear();
  67.488 +        return 1;
  67.489 +      }
  67.490 +
  67.491 +      if (content.arcSectionNum() < 1)
  67.492 +      {
  67.493 +        Gtk::MessageDialog mdialog("No arcset found in file.");
  67.494 +        mdialog.run();
  67.495 +        clear();
  67.496 +        return 1;
  67.497 +      }
  67.498 +
  67.499 +      std::vector<std::string> nodeMapNames = content.nodeMapNames(0);
  67.500 +      std::vector<std::string> arcMapNames = content.arcMapNames(0);
  67.501 +      
  67.502 +      bool read_arc_label = true;
  67.503 +      if (std::find(arcMapNames.begin(), arcMapNames.end(), "label") ==
  67.504 +          arcMapNames.end())
  67.505 +      {
  67.506 +        read_arc_label = false;
  67.507 +      }
  67.508 +
  67.509 +      nodeMapNames.erase(
  67.510 +          std::remove(nodeMapNames.begin(), nodeMapNames.end(), "label"),
  67.511 +          nodeMapNames.end());
  67.512 +
  67.513 +      arcMapNames.erase(
  67.514 +          std::remove(arcMapNames.begin(), arcMapNames.end(), "label"),
  67.515 +          arcMapNames.end());
  67.516 +
  67.517 +      FileImportDialog::ImportData data(nodeMapNames, arcMapNames);
  67.518 +      FileImportDialog fidialog(&data);
  67.519 +      int response = fidialog.run();
  67.520 +      if (response == Gtk::RESPONSE_OK)
  67.521 +      {
  67.522 +        try
  67.523 +        {
  67.524 +          std::string node_coord_xmap_name, node_coord_ymap_name;
  67.525 +          std::string arrow_coord_xmap_name, arrow_coord_ymap_name;
  67.526 +          bool gen_node_coords = false;
  67.527 +          bool gen_arrow_coords = false;
  67.528 +
  67.529 +          switch (data.node_coord_load_from)
  67.530 +          {
  67.531 +            case FileImportDialog::ImportData::ONE_MAP:
  67.532 +              node_coord_xmap_name = data.node_coord_one_map_name + ":x";
  67.533 +              node_coord_ymap_name = data.node_coord_one_map_name + ":y";
  67.534 +              node_coords_one_map_name = data.node_coord_one_map_name;
  67.535 +
  67.536 +              node_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  67.537 +              node_coords_save_map_num = SpecMapSaveOpts::ONE_MAP;
  67.538 +              break;
  67.539 +            case FileImportDialog::ImportData::TWO_MAPS:
  67.540 +              node_coord_xmap_name = data.node_coord_two_maps_1_name;
  67.541 +              node_coord_ymap_name = data.node_coord_two_maps_2_name;
  67.542 +              node_coords_two_maps_1_name = data.node_coord_two_maps_1_name;
  67.543 +              node_coords_two_maps_2_name = data.node_coord_two_maps_2_name;
  67.544 +
  67.545 +              node_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  67.546 +              node_coords_save_map_num = SpecMapSaveOpts::TWO_MAPS;
  67.547 +              break;
  67.548 +            case FileImportDialog::ImportData::DONT_READ:
  67.549 +              node_coord_xmap_name = "";
  67.550 +              node_coord_ymap_name = "";
  67.551 +
  67.552 +              node_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  67.553 +              gen_node_coords = true;
  67.554 +              break;
  67.555 +          }
  67.556 +
  67.557 +          switch (data.arrow_coord_load_from)
  67.558 +          {
  67.559 +            case FileImportDialog::ImportData::ONE_MAP:
  67.560 +              arrow_coord_xmap_name = data.arrow_coord_one_map_name + ":x";
  67.561 +              arrow_coord_ymap_name = data.arrow_coord_one_map_name + ":y";
  67.562 +              arrow_coords_one_map_name = data.arrow_coord_one_map_name;
  67.563 +
  67.564 +              arrow_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  67.565 +              arrow_coords_save_map_num = SpecMapSaveOpts::ONE_MAP;
  67.566 +              break;
  67.567 +            case FileImportDialog::ImportData::TWO_MAPS:
  67.568 +              arrow_coord_xmap_name = data.arrow_coord_two_maps_1_name;
  67.569 +              arrow_coord_ymap_name = data.arrow_coord_two_maps_2_name;
  67.570 +              arrow_coords_two_maps_1_name = data.arrow_coord_two_maps_1_name;
  67.571 +              arrow_coords_two_maps_2_name = data.arrow_coord_two_maps_2_name;
  67.572 +
  67.573 +              arrow_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  67.574 +              arrow_coords_save_map_num = SpecMapSaveOpts::TWO_MAPS;
  67.575 +              break;
  67.576 +            case FileImportDialog::ImportData::DONT_READ:
  67.577 +              arrow_coord_xmap_name = "";
  67.578 +              arrow_coord_ymap_name = "";
  67.579 +
  67.580 +              arrow_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  67.581 +              gen_arrow_coords = true;
  67.582 +              break;
  67.583 +          }
  67.584 +
  67.585 +          // read arc and node maps
  67.586 +          std::vector<std::string> node_map_names;
  67.587 +          std::vector<std::string> arc_map_names;
  67.588 +          std::map<std::string, MapValue::Type> node_map_types;
  67.589 +          std::map<std::string, MapValue::Type> arc_map_types;
  67.590 +          for (std::vector<std::string>::const_iterator it =
  67.591 +              data.numeric_node_map_names.begin();
  67.592 +              it != data.numeric_node_map_names.end(); ++it)
  67.593 +          {
  67.594 +            node_map_names.push_back(*it);
  67.595 +            node_map_types[*it] = MapValue::NUMERIC;
  67.596 +          }
  67.597 +          for (std::vector<std::string>::const_iterator it =
  67.598 +              data.string_node_map_names.begin();
  67.599 +              it != data.string_node_map_names.end(); ++it)
  67.600 +          {
  67.601 +            node_map_names.push_back(*it);
  67.602 +            node_map_types[*it] = MapValue::STRING;
  67.603 +          }
  67.604 +          for (std::vector<std::string>::const_iterator it =
  67.605 +              data.numeric_arc_map_names.begin();
  67.606 +              it != data.numeric_arc_map_names.end(); ++it)
  67.607 +          {
  67.608 +            arc_map_names.push_back(*it);
  67.609 +            arc_map_types[*it] = MapValue::NUMERIC;
  67.610 +          }
  67.611 +          for (std::vector<std::string>::const_iterator it =
  67.612 +              data.string_arc_map_names.begin();
  67.613 +              it != data.string_arc_map_names.end(); ++it)
  67.614 +          {
  67.615 +            arc_map_names.push_back(*it);
  67.616 +            arc_map_types[*it] = MapValue::STRING;
  67.617 +          }
  67.618 +
  67.619 +          readLGF(filename, read_arc_label,
  67.620 +              node_map_names, arc_map_names,
  67.621 +              node_map_types, arc_map_types,
  67.622 +              node_coord_xmap_name, node_coord_ymap_name,
  67.623 +              arrow_coord_xmap_name, arrow_coord_ymap_name);
  67.624 +
  67.625 +          // generate arc labels
  67.626 +          if (!read_arc_label)
  67.627 +          {
  67.628 +            int l = 0;
  67.629 +            for (ArcIt e(digraph); e != INVALID; ++e)
  67.630 +            {
  67.631 +              arc_label[e] = l++;
  67.632 +            }
  67.633 +          }
  67.634 +
  67.635 +          if (gen_node_coords)
  67.636 +          {
  67.637 +            // generate node coordinates
  67.638 +            int node_num = 0;
  67.639 +            for (NodeIt n(digraph); n != INVALID; ++n) { node_num++; }
  67.640 +            const double pi = 3.142;
  67.641 +            double step = 2 * pi / (double) node_num;
  67.642 +            int i = 0;
  67.643 +            for (NodeIt n(digraph); n != INVALID; ++n)
  67.644 +            {
  67.645 +              setNodeCoords(n,
  67.646 +                  XY(250.0 * std::cos(i * step),
  67.647 +                    250.0 * std::sin(i * step)));
  67.648 +              i++;
  67.649 +            }
  67.650 +          }
  67.651 +          if (gen_arrow_coords)
  67.652 +          {
  67.653 +            // generate arrow coordinates
  67.654 +            for (ArcIt e(digraph); e != INVALID; ++e)
  67.655 +            {
  67.656 +              if (digraph.source(e) == digraph.target(e))
  67.657 +              {
  67.658 +                setArrowCoords(e,
  67.659 +                    getNodeCoords(digraph.source(e)) + XY(0.0, 80.0));
  67.660 +              }
  67.661 +              else
  67.662 +              {
  67.663 +                setArrowCoords(e,
  67.664 +                    (getNodeCoords(digraph.source(e)) +
  67.665 +                     getNodeCoords(digraph.target(e))) / 2.0);
  67.666 +              }
  67.667 +            }
  67.668 +          }
  67.669 +        }
  67.670 +        catch (Exception& error)
  67.671 +        {
  67.672 +          clear();
  67.673 +          return 1;
  67.674 +        }
  67.675 +      }
  67.676 +      else
  67.677 +      {
  67.678 +        clear();
  67.679 +        return 1;
  67.680 +      }
  67.681 +    }
  67.682 +  }
  67.683 +
  67.684 +  // set max_node_label
  67.685 +  {
  67.686 +    max_node_label = std::numeric_limits<int>::min();
  67.687 +    for (NodeIt n(digraph); n != INVALID; ++n)
  67.688 +    {
  67.689 +      if (node_label[n] > max_node_label)
  67.690 +      {
  67.691 +        max_node_label = node_label[n];
  67.692 +      }
  67.693 +    }
  67.694 +  }
  67.695 +  // set max_arc_label
  67.696 +  {
  67.697 +    max_arc_label = std::numeric_limits<int>::min();
  67.698 +    for (ArcIt e(digraph); e != INVALID; ++e)
  67.699 +    {
  67.700 +      if (arc_label[e] > max_arc_label)
  67.701 +      {
  67.702 +        max_arc_label = arc_label[e];
  67.703 +      }
  67.704 +    }
  67.705 +  }
  67.706 +
  67.707 +  return 0;
  67.708 +}
  67.709 +
  67.710 +void MapStorage::writeToFile(const std::string &filename)
  67.711 +{
  67.712 +  // relabel nodes and arcs
  67.713 +  int i = 0;
  67.714 +  for (NodeIt n(digraph); n != INVALID; ++n)
  67.715 +  {
  67.716 +    node_label[n] = i++;
  67.717 +  }
  67.718 +  max_node_label = i-1;
  67.719 +  i = 0;
  67.720 +  for (ArcIt e(digraph); e != INVALID; ++e)
  67.721 +  {
  67.722 +    arc_label[e] = i++;
  67.723 +  }
  67.724 +  max_arc_label = i-1;
  67.725 +
  67.726 +  // write .lgf file
  67.727 +  {
  67.728 +    DigraphWriter<Digraph> gwriter(filename, digraph);
  67.729 +
  67.730 +    gwriter.nodeMap("label", node_label);
  67.731 +    gwriter.arcMap("label", arc_label);
  67.732 +
  67.733 +    // write node maps
  67.734 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  67.735 +        it != nodemaps.end(); ++it)
  67.736 +    {
  67.737 +      if (it->second->save_dest == NESET_SECT)
  67.738 +      {
  67.739 +        switch (it->second->type())
  67.740 +        {
  67.741 +          case MapValue::NUMERIC:
  67.742 +            gwriter.nodeMap(it->first, getNumericNodeMap(it->first));
  67.743 +            break;
  67.744 +          case MapValue::STRING:
  67.745 +            gwriter.nodeMap(it->first, getStringNodeMap(it->first));
  67.746 +            break;
  67.747 +        }
  67.748 +      }
  67.749 +    }
  67.750 +
  67.751 +    // write arc maps
  67.752 +    for (ArcMapStore::const_iterator it = arcmaps.begin();
  67.753 +        it != arcmaps.end(); ++it)
  67.754 +    {
  67.755 +      if (it->second->save_dest == NESET_SECT)
  67.756 +      {
  67.757 +        switch (it->second->type())
  67.758 +        {
  67.759 +          case MapValue::NUMERIC:
  67.760 +            gwriter.arcMap(it->first, getNumericArcMap(it->first));
  67.761 +            break;
  67.762 +          case MapValue::STRING:
  67.763 +            gwriter.arcMap(it->first, getStringArcMap(it->first));
  67.764 +            break;
  67.765 +        }
  67.766 +      }
  67.767 +    }
  67.768 +
  67.769 +    // write node coordinates
  67.770 +    switch (getNodeCoordsSaveDest())
  67.771 +    {
  67.772 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  67.773 +        break;
  67.774 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  67.775 +        switch (getNodeCoordsSaveMapNum())
  67.776 +        {
  67.777 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  67.778 +            gwriter.nodeMap(node_coords_one_map_name + ":x",
  67.779 +                node_coords_x);
  67.780 +            gwriter.nodeMap(node_coords_one_map_name + ":y",
  67.781 +                node_coords_y);
  67.782 +            break;
  67.783 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  67.784 +            gwriter.nodeMap(node_coords_two_maps_1_name,
  67.785 +                node_coords_x);
  67.786 +            gwriter.nodeMap(node_coords_two_maps_2_name,
  67.787 +                node_coords_y);
  67.788 +            break;
  67.789 +        }
  67.790 +        break;
  67.791 +    }
  67.792 +
  67.793 +    // write arrow coordinates
  67.794 +    switch (getArrowCoordsSaveDest())
  67.795 +    {
  67.796 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  67.797 +        break;
  67.798 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  67.799 +        switch (getArrowCoordsSaveMapNum())
  67.800 +        {
  67.801 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  67.802 +            gwriter.arcMap(arrow_coords_one_map_name + ":x",
  67.803 +                arrow_coords_x);
  67.804 +            gwriter.arcMap(arrow_coords_one_map_name + ":y",
  67.805 +                arrow_coords_y);
  67.806 +            break;
  67.807 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  67.808 +            gwriter.arcMap(arrow_coords_two_maps_1_name,
  67.809 +                arrow_coords_x);
  67.810 +            gwriter.arcMap(arrow_coords_two_maps_2_name,
  67.811 +                arrow_coords_y);
  67.812 +            break;
  67.813 +        }
  67.814 +        break;
  67.815 +    }
  67.816 +
  67.817 +    if (gui_sect_save_dest == LGF_FILE)
  67.818 +    {
  67.819 +      GuiWriter gui_writer(this);
  67.820 +      gui_writer.write(gwriter.ostream());
  67.821 +      gwriter.run();
  67.822 +    }
  67.823 +    else
  67.824 +    {
  67.825 +      gwriter.run();
  67.826 +    }
  67.827 +  }
  67.828 +
  67.829 +  // write .conf file
  67.830 +  if (gui_sect_save_dest == CONF_FILE)
  67.831 +  {
  67.832 +    DigraphWriter<Digraph> lwriter(filename + ".conf", digraph);
  67.833 +    GuiWriter gui_writer(this);
  67.834 +    gui_writer.write(lwriter.ostream());
  67.835 +    lwriter.run();
  67.836 +  }
  67.837 +}
  67.838 +
  67.839 +void MapStorage::clear()
  67.840 +{
  67.841 +  for (NodeMapStore::iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
  67.842 +  {
  67.843 +    delete it->second;
  67.844 +    nodemaps.erase(it);
  67.845 +  }
  67.846 +  for (ArcMapStore::iterator it = arcmaps.begin(); it != arcmaps.end(); ++it)
  67.847 +  {
  67.848 +    delete it->second;
  67.849 +    arcmaps.erase(it);
  67.850 +  }
  67.851 +  digraph.clear();
  67.852 +  file_name = "";
  67.853 +  modified = false;
  67.854 +  max_node_label = 0;
  67.855 +  max_arc_label = 0;
  67.856 +  background_set = false;
  67.857 +
  67.858 +  gui_sect_save_dest = LGF_FILE;
  67.859 +  node_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  67.860 +  arrow_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  67.861 +  node_coords_one_map_name = "coord";
  67.862 +  node_coords_two_maps_1_name = "coord_x";
  67.863 +  node_coords_two_maps_2_name = "coord_y";
  67.864 +  arrow_coords_one_map_name = "arrow";
  67.865 +  arrow_coords_two_maps_1_name = "arrow_x";
  67.866 +  arrow_coords_two_maps_2_name = "arrow_y";
  67.867 +
  67.868 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
  67.869 +    {
  67.870 +      changeActiveMap(false, i, "");
  67.871 +      signal_map_win.emit(false, i, "");
  67.872 +    }
  67.873 +  
  67.874 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  67.875 +    {
  67.876 +      changeActiveMap(true, i, "");
  67.877 +      signal_map_win.emit(true, i, "");
  67.878 +    }
  67.879 +
  67.880 +  attraction=a_d;
  67.881 +  propulsation=p_d;
  67.882 +  iterations=i_d;
  67.883 +
  67.884 +  signal_design_win.emit(attraction, propulsation, iterations);
  67.885 +}
  67.886 +
  67.887 +void MapStorage::mapChanged(bool itisarc, std::string mapname)
  67.888 +{
  67.889 +  if(itisarc)
  67.890 +  {
  67.891 +    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  67.892 +    {
  67.893 +      if(active_arcmaps[i]==mapname)
  67.894 +      {
  67.895 +        signal_prop.emit(itisarc, i);
  67.896 +      }
  67.897 +    }
  67.898 +  }
  67.899 +  else
  67.900 +  {
  67.901 +    for(int i=0;i<NODE_PROPERTY_NUM;i++)
  67.902 +    {
  67.903 +      if(active_nodemaps[i]==mapname)
  67.904 +      {
  67.905 +        signal_prop.emit(itisarc, i);
  67.906 +      }
  67.907 +    }
  67.908 +  }
  67.909 +}
  67.910 +
  67.911 +void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
  67.912 +{
  67.913 +  attraction_p=attraction;
  67.914 +  propulsation_p=propulsation;
  67.915 +  iterations_p=iterations;
  67.916 +}
  67.917 +
  67.918 +void MapStorage::set_attraction(double attraction_p)
  67.919 +{
  67.920 +  attraction=attraction_p;
  67.921 +}
  67.922 +
  67.923 +void MapStorage::set_propulsation(double propulsation_p)
  67.924 +{
  67.925 +  propulsation=propulsation_p;
  67.926 +}
  67.927 +
  67.928 +void MapStorage::set_iteration(int iterations_p)
  67.929 +{
  67.930 +  iterations=iterations_p;
  67.931 +}
  67.932 +
  67.933 +void MapStorage::redesign_data_changed()
  67.934 +{
  67.935 +  signal_design_win.emit(attraction, propulsation, iterations);
  67.936 +}
  67.937 +
  67.938 +XY MapStorage::getNodeCoords(Node n) const
  67.939 +{
  67.940 +  return node_coords[n];
  67.941 +}
  67.942 +
  67.943 +void MapStorage::setNodeCoords(Node n, XY c)
  67.944 +{
  67.945 +  node_coords.set(n, c);
  67.946 +}
  67.947 +
  67.948 +XY MapStorage::getArrowCoords(Arc e) const
  67.949 +{
  67.950 +  return arrow_coords[e];
  67.951 +}
  67.952 +
  67.953 +void MapStorage::setArrowCoords(Arc e, XY c)
  67.954 +{
  67.955 +  arrow_coords.set(e, c);
  67.956 +}
  67.957 +
  67.958 +MapValue MapStorage::get(const std::string& name, Node node) const
  67.959 +{
  67.960 +  NodeMapData* data = getNodeMapData(name);
  67.961 +  return data->get(node);
  67.962 +}
  67.963 +
  67.964 +void MapStorage::set(const std::string& name, Node node, MapValue val)
  67.965 +{
  67.966 +  NodeMapData* data = getNodeMapData(name);
  67.967 +  data->set(node, val);
  67.968 +}
  67.969 +
  67.970 +MapValue MapStorage::get(const std::string& name, Arc arc) const
  67.971 +{
  67.972 +  ArcMapData* data = getArcMapData(name);
  67.973 +  return data->get(arc);
  67.974 +}
  67.975 +
  67.976 +void MapStorage::set(const std::string& name, Arc arc, MapValue val)
  67.977 +{
  67.978 +  ArcMapData* data = getArcMapData(name);
  67.979 +  data->set(arc, val);
  67.980 +}
  67.981 +
  67.982 +const std::string& MapStorage::getFileName() const
  67.983 +{
  67.984 +  return file_name;
  67.985 +}
  67.986 +
  67.987 +void MapStorage::setFileName(const std::string& fn)
  67.988 +{
  67.989 +  file_name = fn;
  67.990 +}
  67.991 +
  67.992 +bool MapStorage::getModified() const
  67.993 +{
  67.994 +  return modified;
  67.995 +}
  67.996 +
  67.997 +void MapStorage::setModified(bool m)
  67.998 +{
  67.999 +  modified = m;
 67.1000 +}
 67.1001 +
 67.1002 +Node MapStorage::addNode(XY coords)
 67.1003 +{
 67.1004 +  Node node = digraph.addNode();
 67.1005 +
 67.1006 +  setNodeCoords(node, coords);
 67.1007 +
 67.1008 +  max_node_label++;
 67.1009 +
 67.1010 +  node_label[node] = max_node_label;
 67.1011 +
 67.1012 +  std::vector<std::string> node_maps = getNodeMapList();
 67.1013 +  for (std::vector<std::string>::const_iterator it = node_maps.begin();
 67.1014 +      it != node_maps.end(); ++it)
 67.1015 +  {
 67.1016 +    NodeMapData* data = getNodeMapData(*it);
 67.1017 +    set(*it, node, data->default_value);
 67.1018 +  }
 67.1019 +
 67.1020 +  return node;
 67.1021 +}
 67.1022 +
 67.1023 +Arc MapStorage::addArc(Node from, Node to)
 67.1024 +{
 67.1025 +  Arc arc = digraph.addArc(from, to);
 67.1026 +
 67.1027 +  if (from == to)
 67.1028 +  {
 67.1029 +    setArrowCoords(arc, getNodeCoords(from) + XY(0.0, 80.0));
 67.1030 +  }
 67.1031 +  else
 67.1032 +  {
 67.1033 +    setArrowCoords(arc, (getNodeCoords(from) + getNodeCoords(to)) / 2.0);
 67.1034 +  }
 67.1035 +
 67.1036 +  max_arc_label++;
 67.1037 +
 67.1038 +  arc_label[arc] = max_arc_label;
 67.1039 +
 67.1040 +  std::vector<std::string> arc_maps = getArcMapList();
 67.1041 +  for (std::vector<std::string>::const_iterator it = arc_maps.begin();
 67.1042 +      it != arc_maps.end(); ++it)
 67.1043 +  {
 67.1044 +    ArcMapData* data = getArcMapData(*it);
 67.1045 +    set(*it, arc, data->default_value);
 67.1046 +  }
 67.1047 +  return arc;
 67.1048 +}
 67.1049 +
 67.1050 +MapStorage::NumericNodeMap& MapStorage::getNumericNodeMap(const std::string& name)
 67.1051 +{
 67.1052 +  NodeMapData* data = getNodeMapData(name);
 67.1053 +  if (data->type() != MapValue::NUMERIC)
 67.1054 +    throw Error("Numeric node map " + name + " does not exists.");
 67.1055 +  return static_cast<NumericNodeMapData*>(data)->map;
 67.1056 +}
 67.1057 +
 67.1058 +MapStorage::StringNodeMap& MapStorage::getStringNodeMap(const std::string& name)
 67.1059 +{
 67.1060 +  NodeMapData* data = getNodeMapData(name);
 67.1061 +  if (data->type() != MapValue::STRING)
 67.1062 +    throw Error("String node map " + name + " does not exists.");
 67.1063 +  return static_cast<StringNodeMapData*>(data)->map;
 67.1064 +}
 67.1065 +
 67.1066 +MapStorage::NumericArcMap& MapStorage::getNumericArcMap(const std::string& name)
 67.1067 +{
 67.1068 +  ArcMapData* data = getArcMapData(name);
 67.1069 +  if (data->type() != MapValue::NUMERIC)
 67.1070 +    throw Error("Numeric arc map " + name + " does not exists.");
 67.1071 +  return static_cast<NumericArcMapData*>(data)->map;
 67.1072 +}
 67.1073 +
 67.1074 +MapStorage::StringArcMap& MapStorage::getStringArcMap(const std::string& name)
 67.1075 +{
 67.1076 +  ArcMapData* data = getArcMapData(name);
 67.1077 +  if (data->type() != MapValue::STRING)
 67.1078 +    throw Error("String arc map " + name + " does not exists.");
 67.1079 +  return static_cast<StringArcMapData*>(data)->map;
 67.1080 +}
 67.1081 +
 67.1082 +MapValueArcMap MapStorage::getArcMap(const std::string& name)
 67.1083 +{
 67.1084 +  return MapValueArcMap(name, this);
 67.1085 +}
 67.1086 +
 67.1087 +MapValueNodeMap MapStorage::getNodeMap(const std::string& name)
 67.1088 +{
 67.1089 +  return MapValueNodeMap(name, this);
 67.1090 +}
 67.1091 +
 67.1092 +int MapStorage::getLabel(Node n) const
 67.1093 +{
 67.1094 +  return node_label[n];
 67.1095 +}
 67.1096 +
 67.1097 +int MapStorage::getLabel(Arc e) const
 67.1098 +{
 67.1099 +  return arc_label[e];
 67.1100 +}
 67.1101 +
 67.1102 +MapStorage::GuiSectSaveDest MapStorage::getGUIDataSaveLocation()
 67.1103 +{
 67.1104 +  return gui_sect_save_dest;
 67.1105 +}
 67.1106 +
 67.1107 +void MapStorage::setGUIDataSaveLocation(MapStorage::GuiSectSaveDest dest)
 67.1108 +{
 67.1109 +  gui_sect_save_dest = dest;
 67.1110 +}
 67.1111 +
 67.1112 +MapStorage::MapSaveDest MapStorage::getNodeMapSaveDest(std::string name) const
 67.1113 +{
 67.1114 +  NodeMapData *data = getNodeMapData(name);
 67.1115 +  return data->save_dest;
 67.1116 +}
 67.1117 +
 67.1118 +MapStorage::MapSaveDest MapStorage::getArcMapSaveDest(std::string name) const
 67.1119 +{
 67.1120 +  ArcMapData *data = getArcMapData(name);
 67.1121 +  return data->save_dest;
 67.1122 +}
 67.1123 +
 67.1124 +void MapStorage::setNodeMapSaveDest(std::string name, MapStorage::MapSaveDest dest)
 67.1125 +{
 67.1126 +  NodeMapData *data = getNodeMapData(name);
 67.1127 +  data->save_dest = dest;
 67.1128 +}
 67.1129 +
 67.1130 +void MapStorage::setArcMapSaveDest(std::string name, MapStorage::MapSaveDest dest)
 67.1131 +{
 67.1132 +  ArcMapData *data = getArcMapData(name);
 67.1133 +  data->save_dest = dest;
 67.1134 +}
 67.1135 +
 67.1136 +MapStorage::ArcMapData* MapStorage::getArcMapData(std::string name) const
 67.1137 +{
 67.1138 +  ArcMapStore::const_iterator it = arcmaps.find(name);
 67.1139 +  if (it != arcmaps.end())
 67.1140 +    return it->second;
 67.1141 +  else
 67.1142 +    throw Error("Arc map " + name + " does not exists.");
 67.1143 +}
 67.1144 +
 67.1145 +MapStorage::NodeMapData* MapStorage::getNodeMapData(std::string name) const
 67.1146 +{
 67.1147 +  NodeMapStore::const_iterator it = nodemaps.find(name);
 67.1148 +  if (it != nodemaps.end())
 67.1149 +    return it->second;
 67.1150 +  else
 67.1151 +    throw Error("Node map " + name + " does not exists.");
 67.1152 +}
 67.1153 +
 67.1154 +MapValue::Type MapStorage::getNodeMapElementType(std::string name) const
 67.1155 +{
 67.1156 +  NodeMapData *data = getNodeMapData(name);
 67.1157 +  return data->type();
 67.1158 +}
 67.1159 +
 67.1160 +MapValue::Type MapStorage::getArcMapElementType(std::string name) const
 67.1161 +{
 67.1162 +  ArcMapData *data = getArcMapData(name);
 67.1163 +  return data->type();
 67.1164 +}
 67.1165 +
 67.1166 +const MapStorage::NodeLabelMap& MapStorage::getNodeLabelMap()
 67.1167 +{
 67.1168 +  return node_label;
 67.1169 +}
 67.1170 +
 67.1171 +const MapStorage::ArcLabelMap& MapStorage::getArcLabelMap()
 67.1172 +{
 67.1173 +  return arc_label;
 67.1174 +}
 67.1175 +
 67.1176 +const Digraph& MapStorage::getDigraph()
 67.1177 +{
 67.1178 +  return digraph;
 67.1179 +}
 67.1180 +
 67.1181 +bool MapStorage::nodeMapExists(std::string name)
 67.1182 +{
 67.1183 +  NodeMapStore::const_iterator it = nodemaps.find(name);
 67.1184 +  if (it == nodemaps.end())
 67.1185 +    return false;
 67.1186 +  else
 67.1187 +    return true;
 67.1188 +}
 67.1189 +
 67.1190 +bool MapStorage::arcMapExists(std::string name)
 67.1191 +{
 67.1192 +  ArcMapStore::const_iterator it = arcmaps.find(name);
 67.1193 +  if (it == arcmaps.end())
 67.1194 +    return false;
 67.1195 +  else
 67.1196 +    return true;
 67.1197 +}
 67.1198 +
 67.1199 +std::vector<std::string> MapStorage::getArcMaps(MapType type)
 67.1200 +{
 67.1201 +  std::vector<std::string> maps;
 67.1202 +  for (ArcMapStore::const_iterator it = arcmaps.begin(); it != arcmaps.end(); ++it)
 67.1203 +  {
 67.1204 +    if (it->second->type() & type)
 67.1205 +    {
 67.1206 +      maps.push_back(it->first);
 67.1207 +    }
 67.1208 +  }
 67.1209 +  return maps;
 67.1210 +}
 67.1211 +
 67.1212 +std::vector<std::string> MapStorage::getNodeMaps(MapType type)
 67.1213 +{
 67.1214 +  std::vector<std::string> maps;
 67.1215 +  for (NodeMapStore::const_iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
 67.1216 +  {
 67.1217 +    if (it->second->type() & type)
 67.1218 +    {
 67.1219 +      maps.push_back(it->first);
 67.1220 +    }
 67.1221 +  }
 67.1222 +  return maps;
 67.1223 +}
 67.1224 +
 67.1225 +MapStorage::NodeCoordMap& MapStorage::getNodeCoordMap()
 67.1226 +{
 67.1227 +  return node_coords;
 67.1228 +}
 67.1229 +
 67.1230 +MapStorage::ArrowCoordMap& MapStorage::getArrowCoordMap()
 67.1231 +{
 67.1232 +  return arrow_coords;
 67.1233 +}
 67.1234 +
 67.1235 +MapStorage::SpecMapSaveOpts::Dest MapStorage::getNodeCoordsSaveDest()
 67.1236 +{
 67.1237 +  return node_coords_save_dest;
 67.1238 +}
 67.1239 +
 67.1240 +MapStorage::SpecMapSaveOpts::Dest MapStorage::getArrowCoordsSaveDest()
 67.1241 +{
 67.1242 +  return arrow_coords_save_dest;
 67.1243 +}
 67.1244 +
 67.1245 +void MapStorage::setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::Dest dest)
 67.1246 +{
 67.1247 +  node_coords_save_dest = dest;
 67.1248 +}
 67.1249 +
 67.1250 +void MapStorage::setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::Dest dest)
 67.1251 +{
 67.1252 +  arrow_coords_save_dest = dest;
 67.1253 +}
 67.1254 +
 67.1255 +MapStorage::SpecMapSaveOpts::MapNum MapStorage::getNodeCoordsSaveMapNum()
 67.1256 +{
 67.1257 +  return node_coords_save_map_num;
 67.1258 +}
 67.1259 +
 67.1260 +MapStorage::SpecMapSaveOpts::MapNum MapStorage::getArrowCoordsSaveMapNum()
 67.1261 +{
 67.1262 +  return arrow_coords_save_map_num;
 67.1263 +}
 67.1264 +
 67.1265 +void MapStorage::setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::MapNum num)
 67.1266 +{
 67.1267 +  node_coords_save_map_num = num;
 67.1268 +}
 67.1269 +
 67.1270 +void MapStorage::setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::MapNum num)
 67.1271 +{
 67.1272 +  arrow_coords_save_map_num = num;
 67.1273 +}
 67.1274 +
 67.1275 +const std::string& MapStorage::getNodeCoordsOneMapName()
 67.1276 +{
 67.1277 +  return node_coords_one_map_name;
 67.1278 +}
 67.1279 +const std::string& MapStorage::getNodeCoordsTwoMaps1Name()
 67.1280 +{
 67.1281 +  return node_coords_two_maps_1_name;
 67.1282 +}
 67.1283 +const std::string& MapStorage::getNodeCoordsTwoMaps2Name()
 67.1284 +{
 67.1285 +  return node_coords_two_maps_2_name;
 67.1286 +}
 67.1287 +
 67.1288 +void MapStorage::setNodeCoordsOneMapName(const std::string& name)
 67.1289 +{
 67.1290 +  node_coords_one_map_name = name;
 67.1291 +}
 67.1292 +void MapStorage::setNodeCoordsTwoMaps1Name(const std::string& name)
 67.1293 +{
 67.1294 +  node_coords_two_maps_1_name = name;
 67.1295 +}
 67.1296 +void MapStorage::setNodeCoordsTwoMaps2Name(const std::string& name)
 67.1297 +{
 67.1298 +  node_coords_two_maps_2_name = name;
 67.1299 +}
 67.1300 +
 67.1301 +const std::string& MapStorage::getArrowCoordsOneMapName()
 67.1302 +{
 67.1303 +  return arrow_coords_one_map_name;
 67.1304 +}
 67.1305 +const std::string& MapStorage::getArrowCoordsTwoMaps1Name()
 67.1306 +{
 67.1307 +  return arrow_coords_two_maps_1_name;
 67.1308 +}
 67.1309 +const std::string& MapStorage::getArrowCoordsTwoMaps2Name()
 67.1310 +{
 67.1311 +  return arrow_coords_two_maps_2_name;
 67.1312 +}
 67.1313 +
 67.1314 +void MapStorage::setArrowCoordsOneMapName(const std::string& name)
 67.1315 +{
 67.1316 +  arrow_coords_one_map_name = name;
 67.1317 +}
 67.1318 +void MapStorage::setArrowCoordsTwoMaps1Name(const std::string& name)
 67.1319 +{
 67.1320 +  arrow_coords_two_maps_1_name = name;
 67.1321 +}
 67.1322 +void MapStorage::setArrowCoordsTwoMaps2Name(const std::string& name)
 67.1323 +{
 67.1324 +  arrow_coords_two_maps_2_name = name;
 67.1325 +}
 67.1326 +
 67.1327 +void MapStorage::readLGF(
 67.1328 +    const std::string& filename,
 67.1329 +    bool read_arc_label,
 67.1330 +    const std::vector<std::string>& node_map_names,
 67.1331 +    const std::vector<std::string>& arc_map_names,
 67.1332 +    const std::map<std::string, MapValue::Type>& node_map_types,
 67.1333 +    const std::map<std::string, MapValue::Type>& arc_map_types,
 67.1334 +    const std::string& node_coord_xmap_name,
 67.1335 +    const std::string& node_coord_ymap_name,
 67.1336 +    const std::string& arrow_coord_xmap_name,
 67.1337 +    const std::string& arrow_coord_ymap_name)
 67.1338 +{
 67.1339 +  using std::vector;
 67.1340 +  using std::map;
 67.1341 +  using std::string;
 67.1342 +
 67.1343 +  DigraphReader<Digraph> greader(filename, digraph);
 67.1344 +
 67.1345 +  // read the label maps
 67.1346 +  greader.nodeMap("label", node_label);
 67.1347 +  if (read_arc_label)
 67.1348 +    greader.arcMap("label", arc_label);
 67.1349 +
 67.1350 +  // read the node maps
 67.1351 +  for (vector<string>::const_iterator
 67.1352 +      it = node_map_names.begin();
 67.1353 +      it != node_map_names.end(); ++it)
 67.1354 +  {
 67.1355 +    switch (node_map_types.find(*it)->second)
 67.1356 +    {
 67.1357 +      case MapValue::NUMERIC:
 67.1358 +        {
 67.1359 +          createNodeMap(*it, MapValue::NUMERIC, double());
 67.1360 +          greader.nodeMap(*it, getNumericNodeMap(*it));
 67.1361 +          break;
 67.1362 +        }
 67.1363 +      case MapValue::STRING:
 67.1364 +        {
 67.1365 +          createNodeMap(*it, MapValue::STRING, string());
 67.1366 +          greader.nodeMap(*it, getStringNodeMap(*it));
 67.1367 +          break;
 67.1368 +        }
 67.1369 +    }
 67.1370 +    getNodeMapData(*it)->save_dest = NESET_SECT;
 67.1371 +  }
 67.1372 +
 67.1373 +  // read the arc maps
 67.1374 +  for (vector<string>::const_iterator
 67.1375 +      it = arc_map_names.begin();
 67.1376 +      it != arc_map_names.end(); ++it)
 67.1377 +  {
 67.1378 +    switch (arc_map_types.find(*it)->second)
 67.1379 +    {
 67.1380 +      case MapValue::NUMERIC:
 67.1381 +        {
 67.1382 +          createArcMap(*it, MapValue::NUMERIC, double());
 67.1383 +          greader.arcMap(*it, getNumericArcMap(*it));
 67.1384 +          break;
 67.1385 +        }
 67.1386 +      case MapValue::STRING:
 67.1387 +        {
 67.1388 +          createArcMap(*it, MapValue::STRING, string());
 67.1389 +          greader.arcMap(*it, getStringArcMap(*it));
 67.1390 +          break;
 67.1391 +        }
 67.1392 +    }
 67.1393 +    getArcMapData(*it)->save_dest = NESET_SECT;
 67.1394 +  }
 67.1395 +
 67.1396 +  // read the node coordinate maps
 67.1397 +  if (node_coord_xmap_name != "")
 67.1398 +    greader.nodeMap(node_coord_xmap_name, node_coords_x);
 67.1399 +  if (node_coord_ymap_name != "")
 67.1400 +    greader.nodeMap(node_coord_ymap_name, node_coords_y);
 67.1401 +
 67.1402 +  // read the arrow coordinate maps
 67.1403 +  if (arrow_coord_xmap_name != "")
 67.1404 +    greader.arcMap(arrow_coord_xmap_name, arrow_coords_x);
 67.1405 +  if (arrow_coord_ymap_name != "")
 67.1406 +    greader.arcMap(arrow_coord_ymap_name, arrow_coords_y);
 67.1407 +
 67.1408 +  greader.run();
 67.1409 +}
 67.1410 +
 67.1411 +void MapStorage::setBackground(const std::string& file_name)
 67.1412 +{
 67.1413 +  if (file_name == background_file_name) return;
 67.1414 +  if (file_name == "")
 67.1415 +  {
 67.1416 +    background_file_name = "";
 67.1417 +    background_set = false;
 67.1418 +  }
 67.1419 +  else
 67.1420 +  {
 67.1421 +    background_file_name = file_name;
 67.1422 +    background_set = true;
 67.1423 +  }
 67.1424 +  signal_background.emit();
 67.1425 +}
 67.1426 +
 67.1427 +const std::string& MapStorage::getBackgroundFilename()
 67.1428 +{
 67.1429 +  return background_file_name;
 67.1430 +}
 67.1431 +
 67.1432 +bool MapStorage::isBackgroundSet()
 67.1433 +{
 67.1434 +  return background_set;
 67.1435 +}
 67.1436 +
 67.1437 +double MapStorage::getBackgroundScaling()
 67.1438 +{
 67.1439 +  return background_scaling;
 67.1440 +}
 67.1441 +
 67.1442 +void MapStorage::setBackgroundScaling(double scaling)
 67.1443 +{
 67.1444 +  background_scaling = scaling;
 67.1445 +}
 67.1446 +
 67.1447 +void MapStorage::exportDigraphToEPS(std::vector<bool> options, std::string filename, std::string shapemap)
 67.1448 +{
 67.1449 +  Digraph::NodeMap<int> _shapes(digraph, 0);
 67.1450 +  Digraph::NodeMap<int> _nodeColors(digraph, 0);
 67.1451 +  Digraph::ArcMap<int> _arcColors(digraph, 0);
 67.1452 +  Digraph::NodeMap<double> _nodeSizes(digraph, 6.0);
 67.1453 +  Digraph::ArcMap<double> _arcWidths(digraph, 1.0);
 67.1454 +  bool _drawArrows=options[ARROWS];
 67.1455 +  bool _enableParallel=options[PAR];
 67.1456 +
 67.1457 +  std::string emptyString="";
 67.1458 +  Digraph::NodeMap<std::string> _nodeTextMap(digraph,emptyString);
 67.1459 +
 67.1460 +  //_nodeTextMap=(Digraph::NodeMap<void> *)&emptyStringMap;
 67.1461 +
 67.1462 +  if(options[N_MAPS])
 67.1463 +    {
 67.1464 +      if(active_nodemaps[N_RADIUS]!="")
 67.1465 +	{
 67.1466 +	  _nodeSizes=getNumericNodeMap(active_nodemaps[N_RADIUS]);
 67.1467 +	}
 67.1468 +      if(active_nodemaps[N_COLOR]!="")
 67.1469 +	{
 67.1470 +	  for(NodeIt ni(digraph);ni!=INVALID;++ni)
 67.1471 +	    {
 67.1472 +	      _nodeColors[ni]=(int)get(active_nodemaps[N_COLOR], ni);
 67.1473 +	    }
 67.1474 +	}
 67.1475 +      if(active_nodemaps[N_TEXT]!="")
 67.1476 +	{
 67.1477 +	  for(NodeIt ni(digraph);ni!=INVALID;++ni)
 67.1478 +	    {
 67.1479 +	      std::ostringstream o;
 67.1480 +	      o << get(active_nodemaps[N_TEXT], ni);
 67.1481 +	      _nodeTextMap[ni]=o.str();	      
 67.1482 +	    }
 67.1483 +	}
 67.1484 +    }
 67.1485 +  if(options[E_MAPS])
 67.1486 +    {
 67.1487 +      if(active_arcmaps[E_WIDTH]!="")
 67.1488 +	{
 67.1489 +	  _arcWidths=getNumericArcMap(active_arcmaps[E_WIDTH]);
 67.1490 +	}
 67.1491 +      if(active_arcmaps[E_COLOR]!="")
 67.1492 +	{
 67.1493 +	  for(ArcIt ei(digraph);ei!=INVALID;++ei)
 67.1494 +	    {
 67.1495 +	      _arcColors[ei]=(int)get(active_arcmaps[E_COLOR], ei);
 67.1496 +	    }
 67.1497 +	}
 67.1498 +    }
 67.1499 +  if(shapemap!="Default values")
 67.1500 +    {
 67.1501 +      double min = std::numeric_limits<double>::max();
 67.1502 +      double max = std::numeric_limits<double>::min();
 67.1503 +      for (NodeIt n(digraph); n != INVALID; ++n)
 67.1504 +      {
 67.1505 +        double v = static_cast<double>(get(shapemap, n));
 67.1506 +        if (v < min) min = v;
 67.1507 +        if (v > max) max = v;
 67.1508 +      }
 67.1509 +      if((min>=0)&&(max<=4))
 67.1510 +	{
 67.1511 +          NumericNodeMap& map = static_cast<NumericNodeMapData*>(getNodeMapData(shapemap))->map;
 67.1512 +          for (NodeIt n(digraph); n != INVALID; ++n)
 67.1513 +          {
 67.1514 +            _shapes[n] = static_cast<int>(map[n]);
 67.1515 +          }
 67.1516 +	}
 67.1517 +    }
 67.1518 +
 67.1519 +  Palette palette;
 67.1520 +  Palette paletteW(true);
 67.1521 +
 67.1522 +  graphToEps(digraph,filename).
 67.1523 +    title("Sample .eps figure (fits to A4)").
 67.1524 +    copyright("(C) 2006 LEMON Project").
 67.1525 +    absoluteNodeSizes().absoluteArcWidths().
 67.1526 +    nodeScale(2).nodeSizes(_nodeSizes).
 67.1527 +    coords(node_coords).
 67.1528 +    nodeShapes(_shapes).
 67.1529 +    nodeColors(composeMap(paletteW,_nodeColors)).
 67.1530 +    arcColors(composeMap(palette,_arcColors)).
 67.1531 +    arcWidthScale(0.3).arcWidths(_arcWidths).
 67.1532 +    nodeTexts(_nodeTextMap).nodeTextSize(7).
 67.1533 +    enableParallel(_enableParallel).parArcDist(5).
 67.1534 +    drawArrows(_drawArrows).arrowWidth(7).arrowLength(7).
 67.1535 +    run();
 67.1536 +
 67.1537 +}
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/mapstorage.h	Mon Jul 07 08:10:39 2008 -0500
    68.3 @@ -0,0 +1,530 @@
    68.4 +/* -*- C++ -*-
    68.5 + *
    68.6 + * This file is a part of LEMON, a generic C++ optimization library
    68.7 + *
    68.8 + * Copyright (C) 2003-2006
    68.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   68.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   68.11 + *
   68.12 + * Permission to use, modify and distribute this software is granted
   68.13 + * provided that this copyright notice appears in all copies. For
   68.14 + * precise terms see the accompanying LICENSE file.
   68.15 + *
   68.16 + * This software is provided "AS IS" with no warranty of any kind,
   68.17 + * express or implied, and with no claim as to its suitability for any
   68.18 + * purpose.
   68.19 + *
   68.20 + */
   68.21 +
   68.22 +#ifndef MAPSTORAGE_H
   68.23 +#define MAPSTORAGE_H
   68.24 +
   68.25 +class Mapstorage;
   68.26 +
   68.27 +#include <vector>
   68.28 +#include <map>
   68.29 +#include <string>
   68.30 +#include "all_include.h"
   68.31 +#include "xymap.h"
   68.32 +#include <libgnomecanvasmm.h>
   68.33 +#include "map_value.h"
   68.34 +#include "map_value_map.h"
   68.35 +
   68.36 +///class MapStorage handles NodeMaps and ArcMaps.
   68.37 +
   68.38 +///Class MapStorage is responsible for storing
   68.39 +///NodeMaps and ArcMaps that can be shown later
   68.40 +///on GUI. Therefore maps can be added to it,
   68.41 +///and datas over the added maps can be queried.
   68.42 +///The maps will be stored in an std::map,
   68.43 +///referenced with their names. Unfortunately at
   68.44 +///the moment it works only with double type maps
   68.45 +///
   68.46 +///\todo too many things are public!!
   68.47 +class MapStorage
   68.48 +{
   68.49 +private:
   68.50 +  std::string background_file_name;
   68.51 +  bool background_set;
   68.52 +  double background_scaling;
   68.53 +public:
   68.54 +  class Error : public std::exception
   68.55 +  {
   68.56 +    private:
   68.57 +      std::string message;
   68.58 +    public:
   68.59 +      Error(const std::string& msg) : message(msg) {}
   68.60 +      virtual const char* what() const throw()
   68.61 +      {
   68.62 +        return message.c_str();
   68.63 +      }
   68.64 +      ~Error() throw() {}
   68.65 +  };
   68.66 +
   68.67 +  void setBackground(const std::string& file_name);
   68.68 +  const std::string& getBackgroundFilename();
   68.69 +  bool isBackgroundSet();
   68.70 +  double getBackgroundScaling();
   68.71 +  void setBackgroundScaling(double scaling);
   68.72 +
   68.73 +  enum MapSaveDest { GUI_SECT, NESET_SECT, DONT_SAVE };
   68.74 +  enum GuiSectSaveDest { LGF_FILE, CONF_FILE };
   68.75 +  struct SpecMapSaveOpts
   68.76 +  {
   68.77 +    enum Dest { GUI_SECT, NESET_SECT };
   68.78 +    enum MapNum { ONE_MAP, TWO_MAPS };
   68.79 +  };
   68.80 +
   68.81 +  typedef Digraph::NodeMap<double> NumericNodeMap;
   68.82 +  typedef Digraph::NodeMap<std::string> StringNodeMap;
   68.83 +  typedef Digraph::ArcMap<double> NumericArcMap;
   68.84 +  typedef Digraph::ArcMap<std::string> StringArcMap;
   68.85 +  typedef Digraph::NodeMap<int> NodeLabelMap;
   68.86 +  typedef Digraph::ArcMap<int> ArcLabelMap;
   68.87 +  typedef XYMap<Digraph::NodeMap<double> > NodeCoordMap;
   68.88 +  typedef XYMap<Digraph::ArcMap<double> > ArrowCoordMap;
   68.89 +
   68.90 +  struct ArcMapData
   68.91 +  {
   68.92 +    /// where to save the map
   68.93 +    MapSaveDest save_dest;
   68.94 +    /// read-only or read-write
   68.95 +    bool writeable;
   68.96 +    /// default value
   68.97 +    MapValue default_value;
   68.98 +    virtual MapValue::Type type() = 0;
   68.99 +    virtual MapValue get(Arc e) = 0;
  68.100 +    virtual void set(Arc e, MapValue v) = 0;
  68.101 +    ArcMapData(MapValue def_val) :
  68.102 +      save_dest(GUI_SECT),
  68.103 +      writeable(true),
  68.104 +      default_value(def_val)
  68.105 +    {}
  68.106 +  };
  68.107 +
  68.108 +  struct NumericArcMapData : public ArcMapData
  68.109 +  {
  68.110 +    NumericArcMap map;
  68.111 +    MapValue::Type type() { return MapValue::NUMERIC; }
  68.112 +    MapValue get(Arc e) { return MapValue(map[e]); }
  68.113 +    void set(Arc e, MapValue v) { map.set(e, static_cast<double>(v)); }
  68.114 +    NumericArcMapData(Digraph& g, double def_val) :
  68.115 +      ArcMapData(MapValue(def_val)),
  68.116 +      map(g, def_val)
  68.117 +    {}
  68.118 +  };
  68.119 +
  68.120 +  struct StringArcMapData : public ArcMapData
  68.121 +  {
  68.122 +    StringArcMap map;
  68.123 +    MapValue::Type type() { return MapValue::STRING; }
  68.124 +    MapValue get(Arc e) { return MapValue(map[e]); }
  68.125 +    void set(Arc e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
  68.126 +    StringArcMapData(Digraph& g, std::string def_val) :
  68.127 +      ArcMapData(MapValue(def_val)),
  68.128 +      map(g, def_val)
  68.129 +    {}
  68.130 +  };
  68.131 +
  68.132 +  struct NodeMapData
  68.133 +  {
  68.134 +    /// where to save the map
  68.135 +    MapSaveDest save_dest;
  68.136 +    /// read-only or read-write
  68.137 +    bool writeable;
  68.138 +    /// default value
  68.139 +    MapValue default_value;
  68.140 +    virtual MapValue::Type type() = 0;
  68.141 +    virtual MapValue get(Node e) = 0;
  68.142 +    virtual void set(Node e, MapValue v) = 0;
  68.143 +    NodeMapData(MapValue def_val) :
  68.144 +      save_dest(GUI_SECT),
  68.145 +      writeable(true),
  68.146 +      default_value(def_val)
  68.147 +    {}
  68.148 +  };
  68.149 +
  68.150 +  struct NumericNodeMapData : public NodeMapData
  68.151 +  {
  68.152 +    NumericNodeMap map;
  68.153 +    MapValue::Type type() { return MapValue::NUMERIC; }
  68.154 +    MapValue get(Node e) { return MapValue(map[e]); }
  68.155 +    void set(Node e, MapValue v) { map.set(e, static_cast<double>(v)); }
  68.156 +    NumericNodeMapData(Digraph& g, double def_val) :
  68.157 +      NodeMapData(MapValue(def_val)),
  68.158 +      map(g, def_val)
  68.159 +    {}
  68.160 +  };
  68.161 +
  68.162 +  struct StringNodeMapData : public NodeMapData
  68.163 +  {
  68.164 +    StringNodeMap map;
  68.165 +    MapValue::Type type() { return MapValue::STRING; }
  68.166 +    MapValue get(Node e) { return MapValue(map[e]); }
  68.167 +    void set(Node e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
  68.168 +    StringNodeMapData(Digraph& g, std::string def_val) :
  68.169 +      NodeMapData(MapValue(def_val)),
  68.170 +      map(g, def_val)
  68.171 +    {}
  68.172 +  };
  68.173 +
  68.174 +  typedef std::map<std::string, NodeMapData*> NodeMapStore;
  68.175 +  typedef std::map<std::string, ArcMapData*> ArcMapStore;
  68.176 +
  68.177 +  struct GUISectData
  68.178 +  {
  68.179 +    std::vector<std::string> main_node_map_names;
  68.180 +    std::vector<std::string> main_arc_map_names;
  68.181 +
  68.182 +    std::vector<std::string> gui_node_map_names;
  68.183 +    std::vector<std::string> gui_arc_map_names;
  68.184 +
  68.185 +    std::map<std::string, MapValue::Type> node_map_types;
  68.186 +    std::map<std::string, MapValue::Type> arc_map_types;
  68.187 +
  68.188 +    std::map<std::string, std::map<int, double>* > numeric_node_maps;
  68.189 +    std::map<std::string, std::map<int, std::string>* > string_node_maps;
  68.190 +
  68.191 +    std::map<std::string, std::map<int, double>* > numeric_arc_maps;
  68.192 +    std::map<std::string, std::map<int, std::string>* > string_arc_maps;
  68.193 +
  68.194 +    std::map<int, XY> node_coord_map;
  68.195 +    std::map<int, XY> arrow_coord_map;
  68.196 +
  68.197 +    SpecMapSaveOpts::Dest node_coords_save_dest;
  68.198 +    SpecMapSaveOpts::MapNum node_coords_save_map_num;
  68.199 +    std::string node_coords_one_map_name;
  68.200 +    std::string node_coords_two_maps_1_name;
  68.201 +    std::string node_coords_two_maps_2_name;
  68.202 +
  68.203 +    SpecMapSaveOpts::Dest arrow_coords_save_dest;
  68.204 +    SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
  68.205 +    std::string arrow_coords_one_map_name;
  68.206 +    std::string arrow_coords_two_maps_1_name;
  68.207 +    std::string arrow_coords_two_maps_2_name;
  68.208 +
  68.209 +    ~GUISectData()
  68.210 +    {
  68.211 +      using std::map;
  68.212 +      using std::vector;
  68.213 +      using std::pair;
  68.214 +      using std::string;
  68.215 +
  68.216 +      for (map<string, map<int, double>* >::iterator it =
  68.217 +          numeric_node_maps.begin(); it != numeric_node_maps.end(); ++it)
  68.218 +      {
  68.219 +        delete it->second;
  68.220 +      }
  68.221 +      for (map<string, map<int, string>* >::iterator it =
  68.222 +          string_node_maps.begin(); it != string_node_maps.end(); ++it)
  68.223 +      {
  68.224 +        delete it->second;
  68.225 +      }
  68.226 +      for (map<string, map<int, double>* >::iterator it =
  68.227 +          numeric_arc_maps.begin(); it != numeric_arc_maps.end(); ++it)
  68.228 +      {
  68.229 +        delete it->second;
  68.230 +      }
  68.231 +      for (map<string, map<int, string>* >::iterator it =
  68.232 +          string_arc_maps.begin(); it != string_arc_maps.end(); ++it)
  68.233 +      {
  68.234 +        delete it->second;
  68.235 +      }
  68.236 +    }
  68.237 +  };
  68.238 +public:
  68.239 +  ///The digraph for which the datas are stored.
  68.240 +  Digraph digraph;
  68.241 +  const Digraph& getDigraph();
  68.242 +
  68.243 +private:
  68.244 +  GuiSectSaveDest gui_sect_save_dest;
  68.245 +
  68.246 +  SpecMapSaveOpts::Dest node_coords_save_dest;
  68.247 +  SpecMapSaveOpts::MapNum node_coords_save_map_num;
  68.248 +  SpecMapSaveOpts::Dest arrow_coords_save_dest;
  68.249 +  SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
  68.250 +
  68.251 +  NodeMapStore nodemaps;
  68.252 +  ArcMapStore arcmaps;
  68.253 +
  68.254 +  NodeLabelMap node_label;
  68.255 +  ArcLabelMap arc_label;
  68.256 +
  68.257 +  /// the coordinates of the nodes
  68.258 +  NodeCoordMap node_coords;
  68.259 +  Digraph::NodeMap<double> node_coords_x;
  68.260 +  Digraph::NodeMap<double> node_coords_y;
  68.261 +
  68.262 +  /// the coordinates of the arrows on the arcs
  68.263 +  ArrowCoordMap arrow_coords;
  68.264 +  Digraph::ArcMap<double> arrow_coords_x;
  68.265 +  Digraph::ArcMap<double> arrow_coords_y;
  68.266 +
  68.267 +  ///The content of the object has changed, update is needed.
  68.268 +  bool modified;
  68.269 +
  68.270 +  ///Name of file loaded in object.
  68.271 +  std::string file_name;
  68.272 +
  68.273 +  // the largest node label
  68.274 +  int max_node_label;
  68.275 +
  68.276 +  // the largest arc label
  68.277 +  int max_arc_label;
  68.278 +
  68.279 +  std::string node_coords_one_map_name;
  68.280 +  std::string node_coords_two_maps_1_name;
  68.281 +  std::string node_coords_two_maps_2_name;
  68.282 +
  68.283 +  std::string arrow_coords_one_map_name;
  68.284 +  std::string arrow_coords_two_maps_1_name;
  68.285 +  std::string arrow_coords_two_maps_2_name;
  68.286 +
  68.287 +public:
  68.288 +  ///Stores the default values for the different visualization node attributes
  68.289 +  std::vector<Digraph::NodeMap<double> > default_nodemaps;
  68.290 +
  68.291 +  ///Stores the default values for the different visualization arc attributes
  68.292 +  std::vector<Digraph::ArcMap<double> > default_arcmaps;
  68.293 +
  68.294 +  ///Stores the active maps for the different visualization node attributes
  68.295 +  std::vector< std::string > active_nodemaps;
  68.296 +
  68.297 +  /// Stores the active maps for the different visualization arc attributes
  68.298 +  std::vector< std::string > active_arcmaps;
  68.299 +
  68.300 +protected:
  68.301 +
  68.302 +  /// Signal emitted on any change made on map values
  68.303 +
  68.304 +  /// Signal emitted if the visualization of the maps might have to be updated.
  68.305 +  /// bool shows us whether the changed map is arc or nodemap.
  68.306 +  /// int tells us the refreshed property
  68.307 +  sigc::signal<void, bool, int> signal_prop;
  68.308 +
  68.309 +  /// Signal emitted in the case of nodemap addition
  68.310 +
  68.311 +  /// std::string is the
  68.312 +  ///name of the new map
  68.313 +  sigc::signal<void, std::string, MapValue::Type> signal_node_map;
  68.314 +
  68.315 +  /// Signal emitted in the case of arcmap addition
  68.316 +
  68.317 +  /// std::string is the
  68.318 +  ///name of the new map
  68.319 +  sigc::signal<void, std::string, MapValue::Type> signal_arc_map;
  68.320 +
  68.321 +  /// Signal emitted, when entry in \ref MapWin should be changed.
  68.322 +  sigc::signal<void, bool, int, std::string> signal_map_win;
  68.323 +
  68.324 +  /// Signal emitted, when entry in \ref DesignWin should be changed.
  68.325 +  sigc::signal<void, double, double, int> signal_design_win;
  68.326 +
  68.327 +  ///Signal emitted when background should be set by \ref NoteBookTab
  68.328 +  sigc::signal<void> signal_background;
  68.329 +
  68.330 +  ///Iteration number during digraph design
  68.331 +  int iterations;
  68.332 +
  68.333 +  ///Attraction factor during digraph design
  68.334 +  double attraction;
  68.335 +
  68.336 +  ///Propulsation factor during digraph design
  68.337 +  double propulsation;
  68.338 +
  68.339 +public:
  68.340 +  ///Constructor of MapStorage.
  68.341 +
  68.342 +  ///Its all activity is initializing default values
  68.343 +  ///for different visualization attributes.
  68.344 +  MapStorage();
  68.345 +
  68.346 +  ///Destructor of MapStorage
  68.347 +
  68.348 +  ///Maps stored here are created with new. Destructor
  68.349 +  ///deletes them to free up the reserved memory.
  68.350 +  ~MapStorage();
  68.351 +
  68.352 +  /// Registrates if the shown map by any attribute has changed to another.
  68.353 +
  68.354 +  ///It handles the \ref active_arcmaps and
  68.355 +  ///\ref active_nodemaps vectors. It also emits \ref signal_prop signal to let
  68.356 +  ///know the interested objects that the visible map of a certain
  68.357 +  ///attribute has changed.
  68.358 +  ///\param itisarc arcmap or nodemap has changed
  68.359 +  ///\param prop the property of which the map is changed
  68.360 +  ///\param mapname the visible map
  68.361 +  void changeActiveMap(bool itisarc , int prop , std::string mapname);
  68.362 +
  68.363 +  ///Emits signals that let change the active maps in \ref MapWin.
  68.364 +  void broadcastActiveMaps();
  68.365 +
  68.366 +  /// Returns the active arcmap shown by a visualization property.
  68.367 +
  68.368 +  /// \param prop is the property
  68.369 +  ///that shows the requested map.
  68.370 +  std::string getActiveArcMap(int prop);
  68.371 +
  68.372 +  /// Returns the active nodemap shown by a visualization property.
  68.373 +
  68.374 +  /// \param prop is the property
  68.375 +  ///that shows the requested map.
  68.376 +  std::string getActiveNodeMap(int prop);
  68.377 +
  68.378 +  /// Returns the names of the arcmaps stored here.
  68.379 +  std::vector<std::string> getArcMapList(MapType type = ALL);
  68.380 +
  68.381 +  /// Returns the names of the nodemaps stored here.
  68.382 +  std::vector<std::string> getNodeMapList(MapType type = ALL);
  68.383 +
  68.384 +  ///returns \ref signal_prop to be able to connect functions to it
  68.385 +  sigc::signal<void, bool, int> signal_prop_ch();
  68.386 +
  68.387 +  ///returns \ref signal_node_map to be able to connect functions to it
  68.388 +  sigc::signal<void, std::string, MapValue::Type> signal_node_map_ch(){return signal_node_map;};
  68.389 +
  68.390 +  ///returns \ref signal_arc_map to be able to connect functions to it
  68.391 +  sigc::signal<void, std::string, MapValue::Type> signal_arc_map_ch(){return signal_arc_map;};
  68.392 +
  68.393 +  ///returns \ref signal_map_win to be able to connect functions to it
  68.394 +  sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
  68.395 +
  68.396 +  ///returns \ref signal_design_win to be able to connect functions to it
  68.397 +  sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
  68.398 +
  68.399 +  void createNodeMap(const std::string& name, MapValue::Type type,
  68.400 +    MapValue def_val);
  68.401 +  void createArcMap(const std::string& name, MapValue::Type type,
  68.402 +    MapValue def_val);
  68.403 +
  68.404 +  ///returns \ref signal_background to be able to connect functions to it
  68.405 +  sigc::signal<void> signal_background_ch(){return signal_background;};
  68.406 +
  68.407 +
  68.408 +  ///Adds given map to storage.
  68.409 +
  68.410 +  ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
  68.411 +
  68.412 +  ///If values in a map have changed, this function checks, whether it is displayed.
  68.413 +  ///This check means searching the given mapname between active maps
  68.414 +  ///(\ref active_nodemaps, \ref active_arcmaps). If it is there at a certain property,
  68.415 +  ///it emits a signal with the property, where the gotten mapname was found. One signal
  68.416 +  ///is emitted for each property displaying the given map.
  68.417 +  ///\param itisarc whether the map an arcmap or nodemap
  68.418 +  ///\param mapname name of map to visualize
  68.419 +  void mapChanged(bool itisarc, std::string mapname);
  68.420 +
  68.421 +  ///Read datas from the given filename.
  68.422 +  int readFromFile(const std::string &);
  68.423 +
  68.424 +  ///Save datas to the given filename.
  68.425 +  void writeToFile(const std::string &);
  68.426 +
  68.427 +  ///Deletes all datastructures stored here.
  68.428 +  void clear();
  68.429 +
  68.430 +  void get_design_data(double &, double &, int &);
  68.431 +  void set_attraction(double);
  68.432 +  void set_propulsation(double);
  68.433 +  void set_iteration(int);
  68.434 +
  68.435 +  void redesign_data_changed();
  68.436 +
  68.437 +  XY getNodeCoords(Node n) const;
  68.438 +  void setNodeCoords(Node n, XY c);
  68.439 +  XY getArrowCoords(Arc e) const;
  68.440 +  void setArrowCoords(Arc e, XY c);
  68.441 +
  68.442 +  MapValue get(const std::string& name, Node node) const;
  68.443 +  void set(const std::string& name, Node node, MapValue val);
  68.444 +  MapValue get(const std::string& name, Arc arc) const;
  68.445 +  void set(const std::string& name, Arc arc, MapValue val);
  68.446 +
  68.447 +  const std::string& getFileName() const;
  68.448 +  void setFileName(const std::string& fn);
  68.449 +
  68.450 +  bool getModified() const;
  68.451 +  void setModified(bool m = true);
  68.452 +
  68.453 +  Node addNode(XY);
  68.454 +  Arc addArc(Node, Node);
  68.455 +
  68.456 +  NumericNodeMap& getNumericNodeMap(const std::string& name);
  68.457 +  StringNodeMap& getStringNodeMap(const std::string& name);
  68.458 +  NumericArcMap& getNumericArcMap(const std::string& name);
  68.459 +  StringArcMap& getStringArcMap(const std::string& name);
  68.460 +
  68.461 +  MapValueArcMap getArcMap(const std::string& name);
  68.462 +  MapValueNodeMap getNodeMap(const std::string& name);
  68.463 +
  68.464 +  int getLabel(Node) const;
  68.465 +  int getLabel(Arc) const;
  68.466 +
  68.467 +  GuiSectSaveDest getGUIDataSaveLocation();
  68.468 +  void setGUIDataSaveLocation(GuiSectSaveDest dest);
  68.469 +
  68.470 +  MapSaveDest getNodeMapSaveDest(std::string name) const;
  68.471 +  MapSaveDest getArcMapSaveDest(std::string name) const;
  68.472 +  void setNodeMapSaveDest(std::string name, MapSaveDest dest);
  68.473 +  void setArcMapSaveDest(std::string name, MapSaveDest dest);
  68.474 +
  68.475 +  SpecMapSaveOpts::Dest getNodeCoordsSaveDest();
  68.476 +  SpecMapSaveOpts::Dest getArrowCoordsSaveDest();
  68.477 +  void setNodeCoordsSaveDest(SpecMapSaveOpts::Dest dest);
  68.478 +  void setArrowCoordsSaveDest(SpecMapSaveOpts::Dest dest);
  68.479 +
  68.480 +  SpecMapSaveOpts::MapNum getNodeCoordsSaveMapNum();
  68.481 +  SpecMapSaveOpts::MapNum getArrowCoordsSaveMapNum();
  68.482 +  void setNodeCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
  68.483 +  void setArrowCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
  68.484 +
  68.485 +  MapValue::Type getNodeMapElementType(std::string name) const;
  68.486 +  MapValue::Type getArcMapElementType(std::string name) const;
  68.487 +
  68.488 +  const NodeLabelMap& getNodeLabelMap();
  68.489 +  const ArcLabelMap& getArcLabelMap();
  68.490 +
  68.491 +  bool nodeMapExists(std::string name);
  68.492 +  bool arcMapExists(std::string name);
  68.493 +
  68.494 +  std::vector<std::string> getArcMaps(MapType type = ALL);
  68.495 +  std::vector<std::string> getNodeMaps(MapType type = ALL);
  68.496 +
  68.497 +  NodeCoordMap& getNodeCoordMap();
  68.498 +  ArrowCoordMap& getArrowCoordMap();
  68.499 +
  68.500 +  const std::string& getNodeCoordsOneMapName();
  68.501 +  const std::string& getNodeCoordsTwoMaps1Name();
  68.502 +  const std::string& getNodeCoordsTwoMaps2Name();
  68.503 +  void setNodeCoordsOneMapName(const std::string& name);
  68.504 +  void setNodeCoordsTwoMaps1Name(const std::string& name);
  68.505 +  void setNodeCoordsTwoMaps2Name(const std::string& name);
  68.506 +
  68.507 +  const std::string& getArrowCoordsOneMapName();
  68.508 +  const std::string& getArrowCoordsTwoMaps1Name();
  68.509 +  const std::string& getArrowCoordsTwoMaps2Name();
  68.510 +  void setArrowCoordsOneMapName(const std::string& name);
  68.511 +  void setArrowCoordsTwoMaps1Name(const std::string& name);
  68.512 +  void setArrowCoordsTwoMaps2Name(const std::string& name);
  68.513 +
  68.514 +private:
  68.515 +  ArcMapData* getArcMapData(std::string name) const;
  68.516 +  NodeMapData* getNodeMapData(std::string name) const;
  68.517 +  void readLGF(
  68.518 +      const std::string& filename,
  68.519 +      bool read_arc_label,
  68.520 +      const std::vector<std::string>& node_map_names,
  68.521 +      const std::vector<std::string>& arc_map_names,
  68.522 +      const std::map<std::string, MapValue::Type>& node_map_types,
  68.523 +      const std::map<std::string, MapValue::Type>& arc_map_types,
  68.524 +      const std::string& node_coord_xmap_name,
  68.525 +      const std::string& node_coord_ymap_name,
  68.526 +      const std::string& arrow_coord_xmap_name,
  68.527 +      const std::string& arrow_coord_ymap_name);
  68.528 +
  68.529 +public:
  68.530 +  void exportDigraphToEPS(std::vector<bool>, std::string, std::string);
  68.531 +};
  68.532 +
  68.533 +#endif //MAPSTORAGE_H
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/nbtab.cc	Mon Jul 07 08:10:39 2008 -0500
    69.3 @@ -0,0 +1,372 @@
    69.4 +/* -*- C++ -*-
    69.5 + *
    69.6 + * This file is a part of LEMON, a generic C++ optimization library
    69.7 + *
    69.8 + * Copyright (C) 2003-2006
    69.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   69.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   69.11 + *
   69.12 + * Permission to use, modify and distribute this software is granted
   69.13 + * provided that this copyright notice appears in all copies. For
   69.14 + * precise terms see the accompanying LICENSE file.
   69.15 + *
   69.16 + * This software is provided "AS IS" with no warranty of any kind,
   69.17 + * express or implied, and with no claim as to its suitability for any
   69.18 + * purpose.
   69.19 + *
   69.20 + */
   69.21 +
   69.22 +#include <nbtab.h>
   69.23 +#include <mapstorage.h>
   69.24 +#include <eps_win.h>
   69.25 +#include <map_win.h>
   69.26 +#include <design_win.h>
   69.27 +#include <graph_displayer_canvas.h>
   69.28 +
   69.29 +
   69.30 +
   69.31 +NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false), epswinexists(false)
   69.32 +{
   69.33 +  mapstorage=new MapStorage();
   69.34 +
   69.35 +  Gtk::ScrolledWindow *pScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow);
   69.36 +  pScrolledWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
   69.37 +  gd_canvas=Gtk::manage(new DigraphDisplayerCanvas(*this));
   69.38 +  pScrolledWindow->add(*gd_canvas);
   69.39 +  add(*pScrolledWindow);
   69.40 +
   69.41 +  //connecting signals - controller character
   69.42 +  mapstorage->signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &DigraphDisplayerCanvas::propertyChange));
   69.43 +  mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
   69.44 +  mapstorage->signal_arc_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewArcMap));
   69.45 +  mapstorage->signal_background_ch().connect(sigc::mem_fun(*gd_canvas, &DigraphDisplayerCanvas::setBackground));
   69.46 +  show_all_children();
   69.47 +  show();
   69.48 +}
   69.49 +
   69.50 +NoteBookTab::~NoteBookTab()
   69.51 +{
   69.52 +  delete mapstorage;
   69.53 +}
   69.54 +
   69.55 +void NoteBookTab::readFile(const std::string &file)
   69.56 +{
   69.57 +  mapstorage->readFromFile(file);
   69.58 +  mapstorage->setFileName(file);
   69.59 +  mapstorage->setModified(false);
   69.60 +  gd_canvas->drawDigraph();
   69.61 +  if(mapwinexists)
   69.62 +    {
   69.63 +      mapwin->update(
   69.64 +          mapstorage->getArcMapList(NUM),
   69.65 +          mapstorage->getArcMapList(STR),
   69.66 +          mapstorage->getNodeMapList(NUM),
   69.67 +          mapstorage->getNodeMapList(STR));
   69.68 +    }
   69.69 +  title_changed(Glib::filename_display_basename(file));
   69.70 +}
   69.71 +
   69.72 +void NoteBookTab::newFile()
   69.73 +{
   69.74 +  if (mapstorage->getModified())
   69.75 +  {
   69.76 +    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
   69.77 +        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
   69.78 +    mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
   69.79 +    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   69.80 +    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
   69.81 +    switch (mdialog.run())
   69.82 +    {
   69.83 +      case Gtk::RESPONSE_CANCEL:
   69.84 +        return;
   69.85 +      case Gtk::RESPONSE_REJECT:
   69.86 +        break;
   69.87 +      case Gtk::RESPONSE_ACCEPT:
   69.88 +        saveFile();
   69.89 +        break;
   69.90 +    }
   69.91 +  }
   69.92 +  gd_canvas->clear();
   69.93 +  mapstorage->clear();
   69.94 +  if(mapwinexists)
   69.95 +    {
   69.96 +      mapwin->update(
   69.97 +          mapstorage->getArcMapList(NUM),
   69.98 +          mapstorage->getArcMapList(STR),
   69.99 +          mapstorage->getNodeMapList(NUM),
  69.100 +          mapstorage->getNodeMapList(STR));
  69.101 +    }
  69.102 +  title_changed("unsaved file");
  69.103 +}
  69.104 +
  69.105 +void NoteBookTab::openFile()
  69.106 +{
  69.107 +  if (mapstorage->getModified())
  69.108 +  {
  69.109 +    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 
  69.110 +        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
  69.111 +    mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
  69.112 +    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  69.113 +    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
  69.114 +    switch (mdialog.run())
  69.115 +    {
  69.116 +      case Gtk::RESPONSE_CANCEL:
  69.117 +        return;
  69.118 +      case Gtk::RESPONSE_REJECT:
  69.119 +        break;
  69.120 +      case Gtk::RESPONSE_ACCEPT:
  69.121 +        saveFile();
  69.122 +        break;
  69.123 +    }
  69.124 +  }
  69.125 +  Gtk::FileChooserDialog fcdialog("Open File");
  69.126 +  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  69.127 +  fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
  69.128 +  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
  69.129 +  {
  69.130 +    gd_canvas->clear();
  69.131 +    std::cout << mapstorage << std::endl;
  69.132 +    mapstorage->clear();
  69.133 +    Glib::ustring filename = fcdialog.get_filename();
  69.134 +    if (!mapstorage->readFromFile(filename))
  69.135 +    {
  69.136 +      mapstorage->setFileName(filename);
  69.137 +      mapstorage->setModified(false);
  69.138 +      gd_canvas->drawDigraph();
  69.139 +      if(mapwinexists)
  69.140 +	{
  69.141 +          mapwin->update(
  69.142 +              mapstorage->getArcMapList(NUM),
  69.143 +              mapstorage->getArcMapList(STR),
  69.144 +              mapstorage->getNodeMapList(NUM),
  69.145 +              mapstorage->getNodeMapList(STR));
  69.146 +	}
  69.147 +      title_changed(Glib::filename_display_basename(filename));
  69.148 +    }
  69.149 +  }
  69.150 +}
  69.151 +
  69.152 +void NoteBookTab::saveFile()
  69.153 +{
  69.154 +  if (mapstorage->getFileName() == "") {
  69.155 +    saveFileAs();
  69.156 +  }
  69.157 +  else
  69.158 +  {
  69.159 +    mapstorage->writeToFile(mapstorage->getFileName());
  69.160 +    mapstorage->setModified(false);
  69.161 +    title_changed(Glib::filename_display_basename(mapstorage->getFileName()));
  69.162 +  }
  69.163 +}
  69.164 +
  69.165 +void NoteBookTab::saveFileAs()
  69.166 +{
  69.167 +  Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
  69.168 +  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  69.169 +  fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
  69.170 +  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
  69.171 +  {
  69.172 +    Glib::ustring filename = fcdialog.get_filename();
  69.173 +    mapstorage->setFileName(filename);
  69.174 +    mapstorage->writeToFile(filename);
  69.175 +    mapstorage->setModified(false);
  69.176 +    title_changed(Glib::filename_display_basename(filename));
  69.177 +  }
  69.178 +}
  69.179 +
  69.180 +void NoteBookTab::close()
  69.181 +{
  69.182 +  if (mapstorage->getModified())
  69.183 +  {
  69.184 +    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
  69.185 +        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
  69.186 +    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
  69.187 +    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  69.188 +    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
  69.189 +    switch (mdialog.run())
  69.190 +    {
  69.191 +      case Gtk::RESPONSE_CANCEL:
  69.192 +        return;
  69.193 +      case Gtk::RESPONSE_REJECT:
  69.194 +        break;
  69.195 +      case Gtk::RESPONSE_ACCEPT:
  69.196 +        saveFile();
  69.197 +        break;
  69.198 +    }
  69.199 +  }
  69.200 +  gd_canvas->clear();
  69.201 +  mapstorage->clear();
  69.202 +  if(mapwinexists)
  69.203 +    {
  69.204 +      mapwin->update(
  69.205 +          mapstorage->getArcMapList(NUM),
  69.206 +          mapstorage->getArcMapList(STR),
  69.207 +          mapstorage->getNodeMapList(NUM),
  69.208 +          mapstorage->getNodeMapList(STR));
  69.209 +    }
  69.210 +  title_changed("unsaved file");
  69.211 +}
  69.212 +
  69.213 +void NoteBookTab::propertyChange(bool itisarc, int prop, std::string mapname)
  69.214 +{
  69.215 +  mapstorage->changeActiveMap(itisarc, prop, mapname);
  69.216 +}
  69.217 +
  69.218 +sigc::signal<void, NoteBookTab *, bool> NoteBookTab::signal_newmap_needed()
  69.219 +{
  69.220 +  return signal_newmap;
  69.221 +}
  69.222 +
  69.223 +void NoteBookTab::popupNewMapWin(bool itisarc)
  69.224 +{
  69.225 +  signal_newmap.emit(this, itisarc);
  69.226 +}
  69.227 +
  69.228 +std::string NoteBookTab::getActiveArcMap(int prop)
  69.229 +{
  69.230 +  return mapstorage->getActiveArcMap(prop);
  69.231 +}
  69.232 +
  69.233 +std::string NoteBookTab::getActiveNodeMap(int prop)
  69.234 +{
  69.235 +  return mapstorage->getActiveNodeMap(prop);
  69.236 +}
  69.237 +
  69.238 +void NoteBookTab::registerNewArcMap(std::string mapname, MapValue::Type type)
  69.239 +{
  69.240 +  if(mapwinexists)
  69.241 +    {
  69.242 +      mapwin->registerNewArcMap(mapname, type);
  69.243 +    }
  69.244 +}
  69.245 +
  69.246 +void NoteBookTab::registerNewNodeMap(std::string mapname, MapValue::Type type)
  69.247 +{
  69.248 +  if(mapwinexists)
  69.249 +    {
  69.250 +      mapwin->registerNewNodeMap(mapname, type);
  69.251 +    }
  69.252 +  if(epswinexists)
  69.253 +    {
  69.254 +      epswin->registerNewNodeMap(mapname, type);
  69.255 +    }
  69.256 +}
  69.257 +
  69.258 +void NoteBookTab::createMapWin(std::string name)
  69.259 +{
  69.260 +  if(!mapwinexists)
  69.261 +    {
  69.262 +      mapwin=new MapWin("Map Setup - "+name,
  69.263 +          mapstorage->getArcMapList(NUM),
  69.264 +          mapstorage->getArcMapList(STR),
  69.265 +          mapstorage->getNodeMapList(NUM),
  69.266 +          mapstorage->getNodeMapList(STR),
  69.267 +          *this);
  69.268 +      mapst2mapwin=mapstorage->signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
  69.269 +      mapwin->show();
  69.270 +      mapwinexists=true;
  69.271 +    }
  69.272 +}
  69.273 +
  69.274 +void NoteBookTab::createExportToEPSWin(std::string name)
  69.275 +{
  69.276 +  if(!epswinexists)
  69.277 +    {
  69.278 +      epswin=new EpsWin("Export to EPS - "+name, mapstorage->getNodeMapList(NUM), mapstorage->getNodeMapList(STR));
  69.279 +      epswin->show();
  69.280 +      epswinexists=true;
  69.281 +      epswin->signal_eps_details_ch().connect(sigc::mem_fun(*this, &NoteBookTab::exportDigraphToEPS));
  69.282 +      epswin->signal_eps_close_ch().connect(sigc::mem_fun(*this, &NoteBookTab::closeEpsWin));
  69.283 +      epswin->signal_new_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::popupNewMapWin));
  69.284 +    }
  69.285 +}
  69.286 +
  69.287 +
  69.288 +void NoteBookTab::createDesignWin(std::string name)
  69.289 +{
  69.290 +  if(!designwinexists)
  69.291 +    {
  69.292 +      double attraction, propulsation;
  69.293 +      int iterations;
  69.294 +      mapstorage->get_design_data(attraction, propulsation, iterations);
  69.295 +      designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations);
  69.296 +
  69.297 +      designwin->signal_attraction().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_attraction));
  69.298 +      designwin->signal_propulsation().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_propulsation));
  69.299 +      designwin->signal_iteration().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_iteration));
  69.300 +      designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &DigraphDisplayerCanvas::reDesignDigraph));
  69.301 +
  69.302 +      designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
  69.303 +
  69.304 +      mapst2designwin=mapstorage->signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data));
  69.305 +
  69.306 +      designwin->show();
  69.307 +      designwinexists=true;
  69.308 +    }
  69.309 +}
  69.310 +
  69.311 +void NoteBookTab::closeMapWin()
  69.312 +{
  69.313 +  mapst2mapwin.disconnect();
  69.314 +  mapwinexists=false;
  69.315 +  delete mapwin;
  69.316 +}
  69.317 +
  69.318 +void NoteBookTab::closeEpsWin()
  69.319 +{
  69.320 +  epswinexists=false;
  69.321 +  delete epswin;
  69.322 +}
  69.323 +
  69.324 +bool NoteBookTab::closeDesignWin(GdkEventAny * e)
  69.325 +{
  69.326 +  if(e->type==GDK_DELETE)
  69.327 +    {
  69.328 +      designwinexists=false;
  69.329 +      mapst2designwin.disconnect();
  69.330 +      delete designwin;
  69.331 +    }
  69.332 +}
  69.333 +
  69.334 +sigc::signal<void, std::string> NoteBookTab::signal_title_ch()
  69.335 +{
  69.336 +  return signal_title;
  69.337 +}
  69.338 +
  69.339 +void NoteBookTab::setView(bool autoscale, bool zoomtrack, double width, double radius)
  69.340 +{
  69.341 +  gd_canvas->setView(autoscale, zoomtrack, width, radius);
  69.342 +}
  69.343 +
  69.344 +void NoteBookTab::getView(bool & autoscale, bool & zoomtrack, double& width, double& radius)
  69.345 +{
  69.346 +  gd_canvas->getView(autoscale, zoomtrack, width, radius);
  69.347 +}
  69.348 +
  69.349 +void NoteBookTab::reDesignDigraph()
  69.350 +{
  69.351 +  gd_canvas->reDesignDigraph();
  69.352 +}
  69.353 +
  69.354 +void NoteBookTab::active_maps_needed()
  69.355 +{
  69.356 +  mapstorage->broadcastActiveMaps();
  69.357 +}
  69.358 +
  69.359 +void NoteBookTab::exportDigraphToEPS(std::vector<bool> options, std::string filename, std::string shapemap)
  69.360 +{
  69.361 +  mapstorage->exportDigraphToEPS(options, filename, shapemap);
  69.362 +}
  69.363 +
  69.364 +void NoteBookTab::title_changed(std::string newtitle)
  69.365 +{
  69.366 +  signal_title.emit(newtitle);
  69.367 +  if(epswinexists)
  69.368 +    {
  69.369 +      epswin->set_title(newtitle);
  69.370 +    }
  69.371 +  if(designwinexists)
  69.372 +    {
  69.373 +      designwin->set_title(newtitle);
  69.374 +    }
  69.375 +}
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/nbtab.h	Mon Jul 07 08:10:39 2008 -0500
    70.3 @@ -0,0 +1,256 @@
    70.4 +/* -*- C++ -*-
    70.5 + *
    70.6 + * This file is a part of LEMON, a generic C++ optimization library
    70.7 + *
    70.8 + * Copyright (C) 2003-2006
    70.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   70.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   70.11 + *
   70.12 + * Permission to use, modify and distribute this software is granted
   70.13 + * provided that this copyright notice appears in all copies. For
   70.14 + * precise terms see the accompanying LICENSE file.
   70.15 + *
   70.16 + * This software is provided "AS IS" with no warranty of any kind,
   70.17 + * express or implied, and with no claim as to its suitability for any
   70.18 + * purpose.
   70.19 + *
   70.20 + */
   70.21 +
   70.22 +#ifndef NBTAB_H
   70.23 +#define NBTAB_H
   70.24 +
   70.25 +class MapStorage;
   70.26 +class EpsWin;
   70.27 +class MapWin;
   70.28 +class DesignWin;
   70.29 +class DigraphDisplayerCanvas;
   70.30 +
   70.31 +#include <libgnomecanvasmm.h>
   70.32 +#include <libgnomecanvasmm/polygon.h>
   70.33 +#include "map_value.h"
   70.34 +
   70.35 +///One tab in the Notebook that is placed in the main window (\ref MainWin).
   70.36 +
   70.37 +///One digraph and all of its accessories like maps are assigned to one tab in the notebook.
   70.38 +///\ref NoteBookTab is responsible for the user defined display of the digraph: view can be
   70.39 +///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
   70.40 +///view of digraph. This is \ref Mapwin window.
   70.41 +///
   70.42 +///\ref NoteBookTab is also
   70.43 +///responsible for modify the digraph if it is
   70.44 +///requested. Therefore it is responsible for translating user events to modifications to
   70.45 +///do on digraph, like node/arc addition/deletion, map modification, addition and so on.
   70.46 +///
   70.47 +///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
   70.48 +///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
   70.49 +///
   70.50 +///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
   70.51 +///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
   70.52 +///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
   70.53 +class NoteBookTab : public Gtk::VBox
   70.54 +{
   70.55 +public:
   70.56 +  
   70.57 +  ///Constructor of \ref NoteBookTab
   70.58 +
   70.59 +  ///It initiates the \re DigraphDisplayerCanvas, on which the digraph will be drawn
   70.60 +  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
   70.61 +  NoteBookTab();
   70.62 +  
   70.63 +  ~NoteBookTab();
   70.64 +  
   70.65 +  ///Maps assigned to the digraph displayed in this \ref NoteBookTab of notebook.
   70.66 +  MapStorage * mapstorage;
   70.67 +    
   70.68 +  ///Title changement indicator.
   70.69 +
   70.70 +  ///If digraph is loaded from disk or saved to disk or changed its name somehow
   70.71 +  ///this signal will be emit to let
   70.72 +  ///\ref MainWin know that it has to modify the title of the main window.
   70.73 +  ///It contains the new title.
   70.74 +  sigc::signal<void, std::string> signal_title;
   70.75 +
   70.76 +  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
   70.77 +  sigc::signal<void, std::string> signal_title_ch();
   70.78 +
   70.79 +  ///Indicates that new map window should be popped up.
   70.80 +
   70.81 +  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
   70.82 +  ///The signal contains whether an arcmap or a nodemap should be popped up. \ref NewMapWin
   70.83 +  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
   70.84 +  ///but for example \ref MainWin and \ref AlgoWin s as well.
   70.85 +  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
   70.86 +
   70.87 +  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
   70.88 +  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
   70.89 +
   70.90 +  ///Loads the given file.
   70.91 +
   70.92 +  ///The given file will be load in the \ref MapStorage and afeter that
   70.93 +  ///\ref DigraphDisplayerCanvas will be requested to display the digraph.
   70.94 +  ///\ref DigraphDisplayer will get datas from the recently set \ref MapStorage.
   70.95 +  void readFile(const std::string &);
   70.96 +    
   70.97 +  ///The digraph will be drawn on this \ref DigraphDisplayerCanvas
   70.98 +  DigraphDisplayerCanvas * gd_canvas;
   70.99 +
  70.100 +  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
  70.101 +  bool mapwinexists;
  70.102 +
  70.103 +  ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
  70.104 +  bool designwinexists;
  70.105 +
  70.106 +  ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
  70.107 +  bool epswinexists;
  70.108 +
  70.109 +  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
  70.110 +
  70.111 +  ///Only one of this window can be opened at the same time (\ref mapwinexists), 
  70.112 +  ///because there is no need for more, one per tab is enough.
  70.113 +  ///There won1t be benefit of more than one, but it would be
  70.114 +  ///more complicated to synchronize them.
  70.115 +  MapWin * mapwin;
  70.116 +    
  70.117 +  ///Address of the only \ref DesignWin that the \ref NoteBookTab can open.
  70.118 +
  70.119 +  ///Only one of this window can be opened at the same time (\ref designwinexists), 
  70.120 +  ///because there is no need for more, one per tab is enough.
  70.121 +  ///There won't be benefit of more than one, but it would be
  70.122 +  ///more complicated to synchronize them.
  70.123 +  DesignWin * designwin;
  70.124 +
  70.125 +  ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
  70.126 +
  70.127 +  ///Only one of this window can be opened at the same time (\ref epswinexists), 
  70.128 +  ///because there is no need for more, one per tab is enough.
  70.129 +  ///There won't be benefit of more than one.
  70.130 +  EpsWin * epswin;
  70.131 +
  70.132 +public:
  70.133 +  ///Callback for 'FileNew' action.
  70.134 +  virtual void newFile();
  70.135 +  ///Callback for 'FileOpen' action.
  70.136 +  virtual void openFile();
  70.137 +  ///Callback for 'FileSave' action.
  70.138 +  virtual void saveFile();
  70.139 +  ///Callback for 'FileSaveAs' action.
  70.140 +  virtual void saveFileAs();
  70.141 +  ///Callback for 'Close' action.
  70.142 +  virtual void close();
  70.143 +
  70.144 +  ///Handles changement of view of digraph.
  70.145 +
  70.146 +  ///If the user changes the map to show by a property to a nother in \ref MapWin,
  70.147 +  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
  70.148 +  ///the new map to display by the changed property. After that \ref MapStorage will
  70.149 +  ///emits a signal that will be forwarded to \ref DigraphDisplayerCanvas to update the
  70.150 +  ///appropriate parts of digraph.
  70.151 +  ///\param itiesarc whether the changed property is arc property or node property
  70.152 +  ///\param prop id of property, see all_include.h
  70.153 +  ///\param mapname name of the recently selected map
  70.154 +  void propertyChange(bool itisarc, int prop, std::string mapname);
  70.155 +
  70.156 +  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
  70.157 +
  70.158 +  ///This function is called by \ref MapWin.
  70.159 +  ///\param itisarc whether the new map should be an arcmap or a nodemap.
  70.160 +  void popupNewMapWin(bool itisarc);
  70.161 +
  70.162 +  ///Returns the actually selected arcmap to visualize by the given property.
  70.163 +
  70.164 +  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
  70.165 +  ///\param prop property to inquire.
  70.166 +  std::string getActiveArcMap(int prop);
  70.167 +
  70.168 +  ///Returns the actually selected nodemap to visualize by the given property.
  70.169 +
  70.170 +  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
  70.171 +  ///\param prop property to inquire.
  70.172 +  std::string getActiveNodeMap(int prop);
  70.173 +
  70.174 +  ///Registers recently created arcmap in \ref MapWin.
  70.175 +
  70.176 +  ///After creation of new map \ref MapStorage emits a signal.
  70.177 +  ///This signal is bound to this callback function, that will call
  70.178 +  ///a function with the same name and same parameterin \ref MapWin.
  70.179 +  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
  70.180 +  ///\param mapname name of new map
  70.181 +  void registerNewArcMap(std::string mapname, MapValue::Type type);
  70.182 +
  70.183 +  ///Registers recently created nodemap in \ref MapWin.
  70.184 +
  70.185 +  ///After creation of new map \ref MapStorage emits a signal.
  70.186 +  ///This signal is bound to this callback function, that will call
  70.187 +  ///a function with the same name and same parameter in \ref MapWin.
  70.188 +  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
  70.189 +  ///\param mapname name of new map
  70.190 +  void registerNewNodeMap(std::string mapname, MapValue::Type type);
  70.191 +
  70.192 +  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
  70.193 +  
  70.194 +  ///See also
  70.195 +  ///\ref mapwin.
  70.196 +  void createMapWin(std::string);
  70.197 +
  70.198 +  ///Pops up and registrates the \ref DesignWin of \ref NoteBookTab.
  70.199 +  
  70.200 +  ///See also
  70.201 +  ///\ref mapwin.
  70.202 +  void createDesignWin(std::string);
  70.203 +
  70.204 +  ///Pops up a window, that can dump digraph to EPS
  70.205 +
  70.206 +  ///Different parameters can be set here.
  70.207 +  void createExportToEPSWin(std::string);
  70.208 +
  70.209 +  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
  70.210 +  
  70.211 +  ///See also
  70.212 +  ///\ref mapwin.
  70.213 +  void closeMapWin();
  70.214 +
  70.215 +  ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
  70.216 +  
  70.217 +  ///See also
  70.218 +  ///\ref designwin.
  70.219 +  bool closeDesignWin(GdkEventAny *);
  70.220 +
  70.221 +  ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
  70.222 +  
  70.223 +  ///See also
  70.224 +  ///\ref epswin.
  70.225 +  void closeEpsWin();
  70.226 +
  70.227 +  ///Sets node representation settings
  70.228 +  void setView(bool, bool, double, double);
  70.229 +
  70.230 +  ///Gets node representation settings
  70.231 +  void getView(bool &, bool &, double&, double&);
  70.232 +
  70.233 +  ///Let the digraph redesign, based on gravity and arc elasticity.
  70.234 +  void reDesignDigraph();
  70.235 +
  70.236 +  ///Lets Mapstorage export the digraph to EPS
  70.237 +  void exportDigraphToEPS(std::vector<bool>, std::string, std::string);
  70.238 +
  70.239 +  ///\ref MapWin calls this function when it updates the maplist in comboboxes.
  70.240 +  void active_maps_needed();
  70.241 +
  70.242 +private:
  70.243 +  ///Called when title of tab has changed
  70.244 +  void title_changed(std::string);
  70.245 +
  70.246 +  ///Signal connection from \ref MapStorage to \ref MapWin
  70.247 +
  70.248 +  ///If \ref MapWin is closed this connection has to be disconnected,
  70.249 +  ///therefore we have to store it.
  70.250 +  sigc::connection mapst2mapwin;
  70.251 +
  70.252 +  ///Signal connection from \ref MapStorage to \ref DesignWin
  70.253 +
  70.254 +  ///If \ref DesignWin is closed this connection has to be disconnected,
  70.255 +  ///therefore we have to store it.
  70.256 +  sigc::connection mapst2designwin;
  70.257 +};
  70.258 +
  70.259 +#endif //NBTAB_H
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/new_map_win.cc	Mon Jul 07 08:10:39 2008 -0500
    71.3 @@ -0,0 +1,565 @@
    71.4 +/* -*- C++ -*-
    71.5 + *
    71.6 + * This file is a part of LEMON, a generic C++ optimization library
    71.7 + *
    71.8 + * Copyright (C) 2003-2006
    71.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   71.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   71.11 + *
   71.12 + * Permission to use, modify and distribute this software is granted
   71.13 + * provided that this copyright notice appears in all copies. For
   71.14 + * precise terms see the accompanying LICENSE file.
   71.15 + *
   71.16 + * This software is provided "AS IS" with no warranty of any kind,
   71.17 + * express or implied, and with no claim as to its suitability for any
   71.18 + * purpose.
   71.19 + *
   71.20 + */
   71.21 +
   71.22 +#include <new_map_win.h>
   71.23 +#include <nbtab.h>
   71.24 +#include <mapstorage.h>
   71.25 +
   71.26 +bool NewMapWin::closeIfEscapeIsPressed(GdkEventKey* e)
   71.27 +{
   71.28 +  if(e->keyval==GDK_Escape)
   71.29 +  {
   71.30 +    hide();
   71.31 +  }
   71.32 +  return true;
   71.33 +}
   71.34 +
   71.35 +NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisarc, bool arcnode, MapType type):Gtk::Dialog(title, true, true),mytab(mw),node("Create NodeMap"),arc("Create ArcMap"),map_type(type)
   71.36 +{
   71.37 +  set_default_size(200, 50);
   71.38 +
   71.39 +  signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed));
   71.40 +
   71.41 +  Gtk::VBox * vbox=get_vbox();
   71.42 +
   71.43 +  //entries
   71.44 +  table=new Gtk::Table(5, 2, false);
   71.45 +
   71.46 +  label=new Gtk::Label;
   71.47 +  label->set_text("Name of new map:");
   71.48 +  name.set_text("");
   71.49 +
   71.50 +  (*table).attach(*label,0,1,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.51 +  (*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.52 +
   71.53 +  lblType.set_label("Element type:");
   71.54 +  if (map_type & NUM)
   71.55 +    cbType.append_text("Numeric");
   71.56 +  if (map_type & STR)
   71.57 +    cbType.append_text("String");
   71.58 +  cbType.set_active(0);
   71.59 +
   71.60 +  (*table).attach(lblType,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.61 +  (*table).attach(cbType, 1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.62 +
   71.63 +  label=new Gtk::Label;
   71.64 +  label->set_text("Default value in the map:");
   71.65 +  default_value.set_text("0");
   71.66 +
   71.67 +  (*table).attach(*label,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.68 +  (*table).attach(default_value,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.69 +
   71.70 +  //node vs. arc map selector
   71.71 +  Gtk::RadioButton::Group group = node.get_group();
   71.72 +  arc.set_group(group);
   71.73 +
   71.74 +  if(arcnode)
   71.75 +  {
   71.76 +    (*table).attach(node,0,1,3,4,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.77 +    (*table).attach(arc,1,2,3,4,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.78 +  }
   71.79 +  else
   71.80 +  {
   71.81 +    if(itisarc)
   71.82 +    {
   71.83 +      arc.set_active();
   71.84 +    }
   71.85 +    else
   71.86 +    {
   71.87 +      node.set_active();
   71.88 +    }
   71.89 +  }
   71.90 +
   71.91 +  (*table).attach(lblErrorMsg,0,2,4,5,Gtk::SHRINK,Gtk::SHRINK,10,3);
   71.92 +
   71.93 +  vbox->pack_start(*table);
   71.94 +
   71.95 +  //OK button
   71.96 +  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
   71.97 +
   71.98 +  show_all_children();
   71.99 +
  71.100 +}
  71.101 +
  71.102 +void NewMapWin::setErrorMsg(const Glib::ustring& msg)
  71.103 +{
  71.104 +  lblErrorMsg.set_markup("<i><small>" + msg + "</small></i>");
  71.105 +}
  71.106 +
  71.107 +std::vector<double>* NewMapWin::evaluate_expr(const std::string polishform, bool itisarc)
  71.108 +{
  71.109 +  MapStorage& ms = *mytab.mapstorage;
  71.110 +
  71.111 +  std::vector<double>* ret = new std::vector<double>;
  71.112 +  std::stack<double> polishstack;
  71.113 +
  71.114 +  if (itisarc)
  71.115 +  {
  71.116 +    for(ArcIt k(ms.digraph); k!=INVALID; ++k)
  71.117 +    {
  71.118 +      for(int i=0;i<(int)polishform.size();i++)
  71.119 +      {
  71.120 +        double op1=0, op2=0;
  71.121 +        bool operation=true;
  71.122 +        switch(polishform[i])
  71.123 +        {
  71.124 +          case '+':
  71.125 +          case '-':
  71.126 +          case '/':
  71.127 +          case '*':
  71.128 +            op1=polishstack.top();
  71.129 +            polishstack.pop();
  71.130 +            op2=polishstack.top();
  71.131 +            polishstack.pop();
  71.132 +            break;
  71.133 +          default:
  71.134 +            //substitute variable
  71.135 +            std::vector<std::string> maps = ms.getArcMapList(NUM);
  71.136 +            bool itisvar=(std::find(maps.begin(), maps.end(), ch2var[ polishform[i] ]) != maps.end());
  71.137 +            if(itisvar)
  71.138 +            {
  71.139 +              polishstack.push(ms.get(ch2var[ polishform[i] ], k));
  71.140 +            }
  71.141 +            else
  71.142 +            {
  71.143 +              polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  71.144 +            }
  71.145 +            operation=false;
  71.146 +            break;
  71.147 +        }
  71.148 +        if(operation)
  71.149 +        {
  71.150 +          double res;
  71.151 +          switch(polishform[i])
  71.152 +          {
  71.153 +            case '+':
  71.154 +              res=op1+op2;
  71.155 +              break;
  71.156 +            case '-':
  71.157 +              res=op2-op1;
  71.158 +              break;
  71.159 +            case '/':
  71.160 +              res=op2/op1;
  71.161 +              break;
  71.162 +            case '*':
  71.163 +              res=op1*op2;
  71.164 +              break;
  71.165 +            default:
  71.166 +              std::cout << "How could we get here?" << std::endl;
  71.167 +              break;
  71.168 +          }
  71.169 +          polishstack.push(res);
  71.170 +        }
  71.171 +      }//foreach letter in polishform
  71.172 +      ret->push_back(polishstack.top());
  71.173 +    }//foreach arc
  71.174 +  }
  71.175 +  else
  71.176 +  {
  71.177 +    for(NodeIt k(ms.digraph); k!=INVALID; ++k)
  71.178 +    {
  71.179 +      for(int i=0;i<(int)polishform.size();i++)
  71.180 +      {
  71.181 +        double op1=0, op2=0;
  71.182 +        bool operation=true;
  71.183 +        switch(polishform[i])
  71.184 +        {
  71.185 +          case '+':
  71.186 +          case '-':
  71.187 +          case '/':
  71.188 +          case '*':
  71.189 +            op1=polishstack.top();
  71.190 +            polishstack.pop();
  71.191 +            op2=polishstack.top();
  71.192 +            polishstack.pop();
  71.193 +            break;
  71.194 +          default:
  71.195 +            //substitute variable
  71.196 +            std::vector<std::string> maps = ms.getNodeMapList(NUM);
  71.197 +            bool itisvar=(std::find(maps.begin(), maps.end(), ch2var[ polishform[i] ]) != maps.end());
  71.198 +            if(itisvar)
  71.199 +            {
  71.200 +              polishstack.push(ms.get(ch2var[ polishform[i] ], k));
  71.201 +            }
  71.202 +            else
  71.203 +            {
  71.204 +              polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  71.205 +            }
  71.206 +            operation=false;
  71.207 +            break;
  71.208 +        }
  71.209 +        if(operation)
  71.210 +        {
  71.211 +          double res;
  71.212 +          switch(polishform[i])
  71.213 +          {
  71.214 +            case '+':
  71.215 +              res=op1+op2;
  71.216 +              break;
  71.217 +            case '-':
  71.218 +              res=op2-op1;
  71.219 +              break;
  71.220 +            case '/':
  71.221 +              res=op2/op1;
  71.222 +              break;
  71.223 +            case '*':
  71.224 +              res=op1*op2;
  71.225 +              break;
  71.226 +            default:
  71.227 +              std::cout << "How could we get here?" << std::endl;
  71.228 +              break;
  71.229 +          }
  71.230 +          polishstack.push(res);
  71.231 +        }
  71.232 +      }//foreach letter in polishform
  71.233 +      ret->push_back(polishstack.top());
  71.234 +    }//foreach arc
  71.235 +  }
  71.236 +  return ret;
  71.237 +}
  71.238 +
  71.239 +void NewMapWin::on_response(int response_id)
  71.240 +{
  71.241 +  MapStorage& ms = *mytab.mapstorage;
  71.242 +
  71.243 +  if(response_id==Gtk::RESPONSE_OK)
  71.244 +  {
  71.245 +    std::string map_name = name.get_text();
  71.246 +    std::string def_val = default_value.get_text();
  71.247 +
  71.248 +    if (map_name.empty())
  71.249 +    {
  71.250 +      setErrorMsg("No map name given.");
  71.251 +      return;
  71.252 +    }
  71.253 +
  71.254 +    // check whether the map already exists
  71.255 +    if (arc.get_active())
  71.256 +    {
  71.257 +      if (ms.arcMapExists(map_name))
  71.258 +      {
  71.259 +        setErrorMsg("Map '" + map_name + "' already exists.");
  71.260 +        return;
  71.261 +      }
  71.262 +    }
  71.263 +    else
  71.264 +    {
  71.265 +      if (ms.nodeMapExists(map_name))
  71.266 +      {
  71.267 +        setErrorMsg("Map '" + map_name + "' already exists.");
  71.268 +        return;
  71.269 +      }
  71.270 +    }
  71.271 +
  71.272 +    Glib::ustring text = cbType.get_active_text();
  71.273 +    if (text == "Numeric")
  71.274 +    {
  71.275 +      double d;
  71.276 +      char *endptr;
  71.277 +      d = strtod(def_val.c_str(), &endptr);
  71.278 +      if (def_val.c_str() + def_val.length() == endptr)
  71.279 +      {
  71.280 +        // the full string was a number
  71.281 +        if (arc.get_active())
  71.282 +          ms.createArcMap(map_name, MapValue::NUMERIC,
  71.283 +              MapValue(d));
  71.284 +        else
  71.285 +          ms.createNodeMap(map_name, MapValue::NUMERIC,
  71.286 +              MapValue(d));
  71.287 +      }
  71.288 +      else
  71.289 +      {
  71.290 +        // let't try to evaluate the string as an arithmetic expression
  71.291 +        std::string polishform =
  71.292 +          string2Polishform(def_val, arc.get_active());
  71.293 +        if (polishform.empty())
  71.294 +          return;
  71.295 +        std::vector<double>* values =
  71.296 +          evaluate_expr(polishform, arc.get_active());
  71.297 +        if (arc.get_active())
  71.298 +        {
  71.299 +          ms.createArcMap(map_name, MapValue::NUMERIC,
  71.300 +              MapValue(0.0));
  71.301 +          std::vector<double>::const_iterator vit = values->begin();
  71.302 +          for (ArcIt it(ms.digraph); it != INVALID; ++it)
  71.303 +          {
  71.304 +            ms.set(map_name, it, MapValue(*vit));
  71.305 +            ++vit;
  71.306 +          }
  71.307 +        }
  71.308 +        else
  71.309 +        {
  71.310 +          ms.createNodeMap(map_name, MapValue::NUMERIC,
  71.311 +              MapValue(0.0));
  71.312 +          std::vector<double>::const_iterator vit = values->begin();
  71.313 +          for (NodeIt it(ms.digraph); it != INVALID; ++it)
  71.314 +          {
  71.315 +            ms.set(map_name, it, MapValue(*vit));
  71.316 +            ++vit;
  71.317 +          }
  71.318 +        }
  71.319 +        delete values;
  71.320 +      }
  71.321 +    }
  71.322 +    else if (text == "String")
  71.323 +    {
  71.324 +      if (arc.get_active())
  71.325 +        ms.createArcMap(map_name, MapValue::STRING,
  71.326 +            MapValue(def_val));
  71.327 +      else
  71.328 +        ms.createNodeMap(map_name, MapValue::STRING,
  71.329 +            MapValue(def_val));
  71.330 +    }
  71.331 +
  71.332 +    name.set_text("");
  71.333 +    default_value.set_text("0");
  71.334 +    arc.show();
  71.335 +    node.show();
  71.336 +    hide();
  71.337 +  }
  71.338 +}
  71.339 +
  71.340 +
  71.341 +std::string NewMapWin::string2Polishform(std::string rawcommand, bool itisarc)
  71.342 +{
  71.343 +  bool valid_entry=true;
  71.344 +
  71.345 +  std::map<std::string, int> str2i;
  71.346 +
  71.347 +  std::string command;
  71.348 +
  71.349 +  std::string variable;
  71.350 +
  71.351 +  char index='a';
  71.352 +
  71.353 +  for(int i=0;(valid_entry&&(i<(int)rawcommand.size()));i++)
  71.354 +  {
  71.355 +    switch(rawcommand[i])
  71.356 +    {
  71.357 +      case '+':
  71.358 +      case '-':
  71.359 +      case '*':
  71.360 +      case '/':
  71.361 +      case ')':
  71.362 +      case '(':
  71.363 +        if(!variable.empty())
  71.364 +        {
  71.365 +          valid_entry=validVariable(variable, itisarc);
  71.366 +          ch2var[index]=variable;
  71.367 +          command+=index;
  71.368 +          index++;
  71.369 +          variable.erase(0,variable.size());	  
  71.370 +        }
  71.371 +        command+=rawcommand[i];
  71.372 +        break;
  71.373 +      default:
  71.374 +        variable+=rawcommand[i];
  71.375 +        break;
  71.376 +    }
  71.377 +  }
  71.378 +
  71.379 +  if(!variable.empty()&&valid_entry)
  71.380 +  {
  71.381 +    valid_entry=validVariable(variable, itisarc);
  71.382 +    ch2var[index]=variable;
  71.383 +    command+=index;
  71.384 +    index++;
  71.385 +    variable.erase(0,variable.size());	  
  71.386 +  }
  71.387 +
  71.388 +  if(valid_entry)
  71.389 +  {
  71.390 +    unsigned int pr=10000;
  71.391 +    bool prevmult=false;
  71.392 +    unsigned int prev_change=pr;
  71.393 +    unsigned int prev_br=pr;
  71.394 +    int counter=0;
  71.395 +    std::string comm_nobr="";
  71.396 +    std::vector<unsigned int> p;
  71.397 +    p.resize(counter+1);
  71.398 +
  71.399 +    //limits
  71.400 +    //6 brackets embedded
  71.401 +    //100 operation in a row from the same priority
  71.402 +
  71.403 +    for(int i=0;i<(int)command.size();i++)
  71.404 +    {
  71.405 +      bool put_in_string=true;
  71.406 +      switch(command[i])
  71.407 +      {
  71.408 +        case '(':
  71.409 +          pr=prev_br+10000;
  71.410 +          prev_br=pr;
  71.411 +          prevmult=false;
  71.412 +          put_in_string=false;
  71.413 +          break;
  71.414 +        case ')':
  71.415 +          pr=prev_br-10000;
  71.416 +          prev_br=pr;
  71.417 +          prevmult=false;
  71.418 +          put_in_string=false;
  71.419 +          break;
  71.420 +        case '+':
  71.421 +        case '-':
  71.422 +          if(prevmult)
  71.423 +          {
  71.424 +            pr=prev_change;
  71.425 +          }
  71.426 +          p[counter]=pr;
  71.427 +          pr-=100;
  71.428 +
  71.429 +          prevmult=false;
  71.430 +          break;
  71.431 +        case '/':
  71.432 +        case '*':
  71.433 +          if(!prevmult)
  71.434 +          {
  71.435 +            prev_change=pr;
  71.436 +            pr+=200;
  71.437 +            pr-=1;
  71.438 +          }
  71.439 +          p[counter]=pr;
  71.440 +          pr-=1;
  71.441 +          prevmult=true;
  71.442 +          break;
  71.443 +        default:
  71.444 +          p[counter]=65000;
  71.445 +          break;
  71.446 +      }
  71.447 +      if(put_in_string)
  71.448 +      {
  71.449 +        counter++;
  71.450 +        p.resize(counter+1);
  71.451 +        comm_nobr=comm_nobr+command[i];
  71.452 +      }
  71.453 +    }
  71.454 +
  71.455 +    tree_node * root=weightedString2Tree(comm_nobr, p, 0);
  71.456 +
  71.457 +    std::string polishform=postOrder(root);
  71.458 +
  71.459 +    deleteTree(root);
  71.460 +
  71.461 +    return polishform;
  71.462 +  }
  71.463 +  return "";
  71.464 +}
  71.465 +
  71.466 +void NewMapWin::deleteTree(NewMapWin::tree_node * node)
  71.467 +{
  71.468 +  if(node->left_child!=NULL)
  71.469 +  {
  71.470 +    deleteTree(node->left_child);
  71.471 +  }
  71.472 +  if(node->right_child!=NULL)
  71.473 +  {
  71.474 +    deleteTree(node->right_child);
  71.475 +  }
  71.476 +  delete node;
  71.477 +}
  71.478 +
  71.479 +NewMapWin::tree_node * NewMapWin::weightedString2Tree(std::string to_tree, std::vector<unsigned int> & p, int offset)
  71.480 +{
  71.481 +  unsigned int min=p[offset];
  71.482 +  int minplace=0;
  71.483 +  for(int i=0;i<(int)to_tree.size();i++)
  71.484 +  {
  71.485 +    if(min>p[offset+i])
  71.486 +    {
  71.487 +      min=p[offset+i];
  71.488 +      minplace=i;
  71.489 +    }
  71.490 +  }
  71.491 +  tree_node * act_node=new tree_node;
  71.492 +  act_node->ch=to_tree[minplace];
  71.493 +  if(to_tree.size()>=3)
  71.494 +  {
  71.495 +    act_node->left_child=weightedString2Tree(to_tree.substr(0,minplace), p, offset);
  71.496 +    act_node->right_child=weightedString2Tree(to_tree.substr(minplace+1,to_tree.size()-minplace-1), p, offset+minplace+1);
  71.497 +  }
  71.498 +  else
  71.499 +  {
  71.500 +    act_node->left_child=NULL;
  71.501 +    act_node->right_child=NULL;
  71.502 +  }
  71.503 +  return act_node;
  71.504 +}
  71.505 +
  71.506 +std::string NewMapWin::postOrder(tree_node * subtree)
  71.507 +{
  71.508 +  std::string subtree_to_string;
  71.509 +  if(subtree->left_child)
  71.510 +  {
  71.511 +    subtree_to_string=postOrder(subtree->left_child);
  71.512 +  }
  71.513 +  if(subtree->right_child)
  71.514 +  {
  71.515 +    subtree_to_string=subtree_to_string+postOrder(subtree->right_child);
  71.516 +  }
  71.517 +  subtree_to_string=subtree_to_string+subtree->ch;
  71.518 +  return subtree_to_string;
  71.519 +}
  71.520 +
  71.521 +bool NewMapWin::validVariable(std::string variable, bool itisarc)
  71.522 +{
  71.523 +  MapStorage& ms = *mytab.mapstorage;
  71.524 +
  71.525 +  bool cancel;
  71.526 +  //is it mapname?
  71.527 +  if(itisarc)
  71.528 +  {
  71.529 +    std::vector<std::string> arc_maps =
  71.530 +      ms.getArcMapList(NUM);
  71.531 +    cancel=(std::find(arc_maps.begin(), arc_maps.end(), variable)==arc_maps.end());
  71.532 +  }
  71.533 +  else
  71.534 +  {
  71.535 +    std::vector<std::string> node_maps =
  71.536 +      ms.getNodeMapList(NUM);
  71.537 +    cancel=(std::find(node_maps.begin(), node_maps.end(), variable)==node_maps.end());
  71.538 +  }
  71.539 +  //maybe it is number
  71.540 +  int point_num=0;
  71.541 +  if(cancel)
  71.542 +  {
  71.543 +    cancel=false;
  71.544 +    for(int j=0;(!cancel)&&(j<(int)variable.size());j++)
  71.545 +    {
  71.546 +      if(((variable[j]<'0')||(variable[j]>'9'))&&(variable[j]!='.'))
  71.547 +      {
  71.548 +        cancel=true;
  71.549 +      }
  71.550 +      else
  71.551 +      {
  71.552 +        if(variable[j]=='.')
  71.553 +        {
  71.554 +          point_num++;
  71.555 +          if(point_num>1)
  71.556 +          {
  71.557 +            cancel=true;
  71.558 +          }
  71.559 +        }
  71.560 +      }
  71.561 +    }
  71.562 +  }
  71.563 +  if(cancel)
  71.564 +  {
  71.565 +    return false;
  71.566 +  }
  71.567 +  return true;
  71.568 +}
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/new_map_win.h	Mon Jul 07 08:10:39 2008 -0500
    72.3 @@ -0,0 +1,160 @@
    72.4 +/* -*- C++ -*-
    72.5 + *
    72.6 + * This file is a part of LEMON, a generic C++ optimization library
    72.7 + *
    72.8 + * Copyright (C) 2003-2006
    72.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   72.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   72.11 + *
   72.12 + * Permission to use, modify and distribute this software is granted
   72.13 + * provided that this copyright notice appears in all copies. For
   72.14 + * precise terms see the accompanying LICENSE file.
   72.15 + *
   72.16 + * This software is provided "AS IS" with no warranty of any kind,
   72.17 + * express or implied, and with no claim as to its suitability for any
   72.18 + * purpose.
   72.19 + *
   72.20 + */
   72.21 +
   72.22 +#ifndef NEWMAPWIN_H
   72.23 +#define NEWMAPWIN_H
   72.24 +
   72.25 +#include <all_include.h>
   72.26 +#include <libgnomecanvasmm.h>
   72.27 +#include <libgnomecanvasmm/polygon.h>
   72.28 +#include <stack>
   72.29 +
   72.30 +class NoteBookTab;
   72.31 +
   72.32 +///Digraphical interface for node/arc map creation.
   72.33 +
   72.34 +///This class is responsible for creating a window,
   72.35 +///on which the parameters of a new map can be set.
   72.36 +class NewMapWin : public Gtk::Dialog
   72.37 +{
   72.38 +  ///The \ref NoteBookTab in which the new map has to be placed.
   72.39 +  NoteBookTab & mytab;
   72.40 +
   72.41 +  MapType map_type;
   72.42 +  Gtk::Label lblType;
   72.43 +  Gtk::ComboBoxText cbType;
   72.44 +
   72.45 +  Gtk::Label lblErrorMsg;
   72.46 +  void setErrorMsg(const Glib::ustring& msg);
   72.47 +
   72.48 +  std::vector<double>* evaluate_expr(const std::string polishform, bool itisarc);
   72.49 +
   72.50 +public:
   72.51 +
   72.52 +  ///Struct to be able to evaluate expressions.
   72.53 +
   72.54 +  ///Initial values of map elements can be given
   72.55 +  ///by numbers or by expressions. From expressions
   72.56 +  ///we build first a tree according to the priorities
   72.57 +  ///of operations in the expression. This is the data
   72.58 +  ///structure
   72.59 +  ///that can store one tree element.
   72.60 +  struct tree_node
   72.61 +  {
   72.62 +    ///Character stored in this tree element
   72.63 +    char ch;
   72.64 +    ///Left child of tree element.
   72.65 +    tree_node * left_child;
   72.66 +    ///Right child of tree element.
   72.67 +    tree_node * right_child;
   72.68 +  };
   72.69 +  
   72.70 +  ///Constructor of NewMapWin.
   72.71 +
   72.72 +  ///It creates the widgets shown in
   72.73 +  ///NewMapWin.
   72.74 +  NewMapWin(const std::string& title, NoteBookTab &, bool itisarc=true, bool arcnode=true, MapType type = ALL);
   72.75 +
   72.76 +  ///Callback function for OK button. It creates the map.
   72.77 +  
   72.78 +  ///This function determines whether the input is correct:
   72.79 +  ///the name of new map must not be already used, the expression
   72.80 +  ///that gives tha initial values of map elements has to be valid.
   72.81 +  ///If input is correct it creates and registrates the new map
   72.82 +  ///to the correct place. (\ref mytab)
   72.83 +  virtual void on_response(int response_id);
   72.84 +
   72.85 +  ///Close window if Esc key pressed.
   72.86 +  virtual bool closeIfEscapeIsPressed(GdkEventKey*);
   72.87 +
   72.88 +  ///Function that creates a tree from an appropriately manipulated string.
   72.89 +
   72.90 +  ///Tree is builded according to priorities of operations in expression given by string.
   72.91 +  ///Priorities are indicated in a vector that contains weights for each operation.
   72.92 +  ///\param to_tree string to build tree from
   72.93 +  ///\param weights weights (priorities)
   72.94 +  ///\param offset this function call is recursive. This parameter tells us,
   72.95 +  ///with which part of the string do we have to deal with.
   72.96 +  tree_node * weightedString2Tree(std::string to_tree, std::vector<unsigned int> & weights, int offset);
   72.97 +
   72.98 +  ///Function that creates a string from a tree by postorder reading.
   72.99 +
  72.100 +  ///This is the last step of creating polishform
  72.101 +  ///from a given expression string.
  72.102 +  ///\param root the root of the tree to read through
  72.103 +  std::string postOrder(tree_node * root);
  72.104 +
  72.105 +  ///From the given expression it creates expression given in polish form.
  72.106 +
  72.107 +  ///First it substitutes variables and numbers in the given expression.
  72.108 +  ///The substitutions will be one character long local variables.
  72.109 +  ///The substituted-substitution pair is registrated in \ref ch2var.
  72.110 +  ///After that it gives weights fo each character in substituted expression.
  72.111 +  ///Weights are calculated according to the priority of operations in expression.
  72.112 +  ///Then it creates tree (\ref tree_node) from the weighted string. (\ref weightedString2Tree)
  72.113 +  ///\param to_polish the string to turn into polish_form
  72.114 +  ///\param itisarc do we have to create an arcmap or a nodemap.
  72.115 +  ///It is important, because variables are maps and if expression
  72.116 +  ///citates a map that does not exists the expression is not valid.
  72.117 +  ///But to determine, whether the map exists we have to know where
  72.118 +  ///to search for it. And of course for a new arcmap only arcmaps can be serve with values. 
  72.119 +  std::string string2Polishform(std::string to_polish, bool itisarc);
  72.120 +
  72.121 +  ///Returns whether a string can be used as value in an expression.
  72.122 +
  72.123 +  ///The given string has to be either a mapname or a number. If it is a mapname
  72.124 +  ///we have to know whether it is an arcmap or a nodemap.
  72.125 +  ///\param variable the string about the function has to determine whether it is usable in expressions
  72.126 +  ///\param itisarc should the mapname be between arcmaps, or nodemaps
  72.127 +  bool validVariable(std::string variable, bool itisarc);
  72.128 +
  72.129 +  ///Deletes the whole tree created for translating string to polishform.
  72.130 + 
  72.131 +  ///\param root
  72.132 +  ///root of the tree
  72.133 +  void deleteTree(tree_node * root);
  72.134 +
  72.135 +  ///Dictionary of substitutions in expression.
  72.136 +
  72.137 +  ///Variables and numbers are substituted with one character long variables in expressions.
  72.138 +  ///This is the dictionary.
  72.139 +  std::map<char, std::string> ch2var;
  72.140 +
  72.141 +  ///Entry which gives us the name of new map.
  72.142 +  Gtk::Entry name;
  72.143 +
  72.144 +  ///Entry which gives us the initial values of elements of new map.
  72.145 +
  72.146 +  ///Initial value can be a number or an expression after that the
  72.147 +  ///initial value for each map element can be calculated.
  72.148 +  Gtk::Entry default_value;
  72.149 +
  72.150 +  ///GTK Designing object.
  72.151 +  Gtk::Table * table;
  72.152 +
  72.153 +  ///Information holder in window.
  72.154 +  Gtk::Label * label;
  72.155 +
  72.156 +  ///If selected, nodemap will be created.
  72.157 +  Gtk::RadioButton node;
  72.158 +
  72.159 +  ///If selected, arcmap will be created.
  72.160 +  Gtk::RadioButton arc;
  72.161 +};
  72.162 +
  72.163 +#endif //NEWMAPWIN_H
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/po/LINGUAS	Mon Jul 07 08:10:39 2008 -0500
    73.3 @@ -0,0 +1,1 @@
    73.4 +hu
    74.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.2 +++ b/po/Makevars	Mon Jul 07 08:10:39 2008 -0500
    74.3 @@ -0,0 +1,41 @@
    74.4 +# Makefile variables for PO directory in any package using GNU gettext.
    74.5 +
    74.6 +# Usually the message domain is the same as the package name.
    74.7 +DOMAIN = $(PACKAGE)
    74.8 +
    74.9 +# These two variables depend on the location of this directory.
   74.10 +subdir = po
   74.11 +top_builddir = ..
   74.12 +
   74.13 +# These options get passed to xgettext.
   74.14 +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
   74.15 +
   74.16 +# This is the copyright holder that gets inserted into the header of the
   74.17 +# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
   74.18 +# package.  (Note that the msgstr strings, extracted from the package's
   74.19 +# sources, belong to the copyright holder of the package.)  Translators are
   74.20 +# expected to transfer the copyright for their translations to this person
   74.21 +# or entity, or to disclaim their copyright.  The empty string stands for
   74.22 +# the public domain; in this case the translators are expected to disclaim
   74.23 +# their copyright.
   74.24 +COPYRIGHT_HOLDER = Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   74.25 +
   74.26 +# This is the email address or URL to which the translators shall report
   74.27 +# bugs in the untranslated strings:
   74.28 +# - Strings which are not entire sentences, see the maintainer guidelines
   74.29 +#   in the GNU gettext documentation, section 'Preparing Strings'.
   74.30 +# - Strings which use unclear terms or require additional context to be
   74.31 +#   understood.
   74.32 +# - Strings which make invalid assumptions about notation of date, time or
   74.33 +#   money.
   74.34 +# - Pluralisation problems.
   74.35 +# - Incorrect English spelling.
   74.36 +# - Incorrect formatting.
   74.37 +# It can be your email address, or a mailing list address where translators
   74.38 +# can write to without being subscribed, or the URL of a web page through
   74.39 +# which the translators can contact you.
   74.40 +MSGID_BUGS_ADDRESS = $(PACKAGE_BUGREPORT)
   74.41 +
   74.42 +# This is the list of locale categories, beyond LC_MESSAGES, for which the
   74.43 +# message catalogs shall be used.  It is usually empty.
   74.44 +EXTRA_LOCALE_CATEGORIES =
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/po/POTFILES.in	Mon Jul 07 08:10:39 2008 -0500
    75.3 @@ -0,0 +1,35 @@
    75.4 +# List of source files which contain translatable strings.
    75.5 +algobox.cc
    75.6 +algobox.h
    75.7 +algowin.cc
    75.8 +algowin.h
    75.9 +all_include.h
   75.10 +gdc-broken_edge.cc
   75.11 +gettext.h
   75.12 +graph_displayer_canvas.cc
   75.13 +graph_displayer_canvas-edge.cc
   75.14 +graph_displayer_canvas-event.cc
   75.15 +graph_displayer_canvas.h
   75.16 +graph_displayer_canvas-node.cc
   75.17 +graph_displayer_canvas-zoom.cc
   75.18 +graph-displayer.cc
   75.19 +gui_reader.cc
   75.20 +gui_reader.h
   75.21 +gui_writer.cc
   75.22 +gui_writer.h
   75.23 +kruskalbox.cc
   75.24 +kruskalbox.h
   75.25 +main_win.cc
   75.26 +main_win.h
   75.27 +mapselector.cc
   75.28 +mapselector.h
   75.29 +mapstorage.cc
   75.30 +mapstorage.h
   75.31 +map_win.cc
   75.32 +map_win.h
   75.33 +nbtab.cc
   75.34 +nbtab.h
   75.35 +new_map_win.cc
   75.36 +new_map_win.h
   75.37 +xml.h
   75.38 +xymap.h
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/po/glemon.pot	Mon Jul 07 08:10:39 2008 -0500
    76.3 @@ -0,0 +1,89 @@
    76.4 +# SOME DESCRIPTIVE TITLE.
    76.5 +# Copyright (C) YEAR Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    76.6 +# This file is distributed under the same license as the PACKAGE package.
    76.7 +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
    76.8 +#
    76.9 +#, fuzzy
   76.10 +msgid ""
   76.11 +msgstr ""
   76.12 +"Project-Id-Version: PACKAGE VERSION\n"
   76.13 +"Report-Msgid-Bugs-To: etik-ol@cs.elte.hu\n"
   76.14 +"POT-Creation-Date: 2006-04-14 20:37+0200\n"
   76.15 +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
   76.16 +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
   76.17 +"Language-Team: LANGUAGE <LL@li.org>\n"
   76.18 +"MIME-Version: 1.0\n"
   76.19 +"Content-Type: text/plain; charset=CHARSET\n"
   76.20 +"Content-Transfer-Encoding: 8bit\n"
   76.21 +
   76.22 +#: main_win.cc:80
   76.23 +msgid "_File"
   76.24 +msgstr ""
   76.25 +
   76.26 +#: main_win.cc:85
   76.27 +msgid "Clear Tab"
   76.28 +msgstr ""
   76.29 +
   76.30 +#: main_win.cc:96
   76.31 +msgid "_View"
   76.32 +msgstr ""
   76.33 +
   76.34 +#: main_win.cc:106
   76.35 +msgid "_Show"
   76.36 +msgstr ""
   76.37 +
   76.38 +#: main_win.cc:107
   76.39 +msgid "_Maps"
   76.40 +msgstr ""
   76.41 +
   76.42 +#: main_win.cc:110
   76.43 +msgid "_Algorithms"
   76.44 +msgstr ""
   76.45 +
   76.46 +#: main_win.cc:111
   76.47 +msgid "_General"
   76.48 +msgstr ""
   76.49 +
   76.50 +#: main_win.cc:113
   76.51 +msgid "_Kruskal"
   76.52 +msgstr ""
   76.53 +
   76.54 +#: main_win.cc:117
   76.55 +msgid "Move"
   76.56 +msgstr ""
   76.57 +
   76.58 +#: main_win.cc:119
   76.59 +msgid "Create node"
   76.60 +msgstr ""
   76.61 +
   76.62 +#: main_win.cc:121
   76.63 +msgid "Create edge"
   76.64 +msgstr ""
   76.65 +
   76.66 +#: main_win.cc:123
   76.67 +msgid "Delete"
   76.68 +msgstr ""
   76.69 +
   76.70 +#: main_win.cc:126
   76.71 +msgid "Edit edge map"
   76.72 +msgstr ""
   76.73 +
   76.74 +#: main_win.cc:128
   76.75 +msgid "Edit node map"
   76.76 +msgstr ""
   76.77 +
   76.78 +#: main_win.cc:259
   76.79 +msgid "unsaved file"
   76.80 +msgstr ""
   76.81 +
   76.82 +#: main_win.cc:269
   76.83 +msgid "<b>Save changes before closing?</b>"
   76.84 +msgstr ""
   76.85 +
   76.86 +#: main_win.cc:271
   76.87 +msgid "Close file _without Saving"
   76.88 +msgstr ""
   76.89 +
   76.90 +#: main_win.cc:458 main_win.cc:487
   76.91 +msgid "Create New Map - "
   76.92 +msgstr ""
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/po/hu.po	Mon Jul 07 08:10:39 2008 -0500
    77.3 @@ -0,0 +1,89 @@
    77.4 +# Hungarian translations for LEMON package.
    77.5 +# Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77.6 +# This file is distributed under the same license as the LEMON package.
    77.7 +# Ladanyi Akos <ladanyi@tmit.bme.hu>, 2006.
    77.8 +#
    77.9 +msgid ""
   77.10 +msgstr ""
   77.11 +"Project-Id-Version: gLEMON svn-head\n"
   77.12 +"Report-Msgid-Bugs-To: etik-ol@cs.elte.hu\n"
   77.13 +"POT-Creation-Date: 2006-04-14 20:37+0200\n"
   77.14 +"PO-Revision-Date: 2006-03-22 15:55+0100\n"
   77.15 +"Last-Translator: Ladanyi Akos <ladanyi@tmit.bme.hu>\n"
   77.16 +"Language-Team: Hungarian <translation-team-hu@lists.sourceforge.net>\n"
   77.17 +"MIME-Version: 1.0\n"
   77.18 +"Content-Type: text/plain; charset=UTF-8\n"
   77.19 +"Content-Transfer-Encoding: 8bit\n"
   77.20 +"Plural-Forms: nplurals=1; plural=0;\n"
   77.21 +
   77.22 +#: main_win.cc:80
   77.23 +msgid "_File"
   77.24 +msgstr "_Fájl"
   77.25 +
   77.26 +#: main_win.cc:85
   77.27 +msgid "Clear Tab"
   77.28 +msgstr "Lap törlése"
   77.29 +
   77.30 +#: main_win.cc:96
   77.31 +msgid "_View"
   77.32 +msgstr "_Nézet"
   77.33 +
   77.34 +#: main_win.cc:106
   77.35 +msgid "_Show"
   77.36 +msgstr "_Mutat"
   77.37 +
   77.38 +#: main_win.cc:107
   77.39 +msgid "_Maps"
   77.40 +msgstr "_Mapek"
   77.41 +
   77.42 +#: main_win.cc:110
   77.43 +msgid "_Algorithms"
   77.44 +msgstr "_Algoritmusok"
   77.45 +
   77.46 +#: main_win.cc:111
   77.47 +msgid "_General"
   77.48 +msgstr "_Általános"
   77.49 +
   77.50 +#: main_win.cc:113
   77.51 +msgid "_Kruskal"
   77.52 +msgstr "_Kruskal"
   77.53 +
   77.54 +#: main_win.cc:117
   77.55 +msgid "Move"
   77.56 +msgstr "Mozgat"
   77.57 +
   77.58 +#: main_win.cc:119
   77.59 +msgid "Create node"
   77.60 +msgstr "Csúcs létrehozása"
   77.61 +
   77.62 +#: main_win.cc:121
   77.63 +msgid "Create edge"
   77.64 +msgstr "Él létrehozása"
   77.65 +
   77.66 +#: main_win.cc:123
   77.67 +msgid "Delete"
   77.68 +msgstr "Törlés"
   77.69 +
   77.70 +#: main_win.cc:126
   77.71 +msgid "Edit edge map"
   77.72 +msgstr "Él map szerkesztése"
   77.73 +
   77.74 +#: main_win.cc:128
   77.75 +msgid "Edit node map"
   77.76 +msgstr "Csúcs map szerkesztése"
   77.77 +
   77.78 +#: main_win.cc:259
   77.79 +msgid "unsaved file"
   77.80 +msgstr "nem mentett fájl"
   77.81 +
   77.82 +#: main_win.cc:269
   77.83 +msgid "<b>Save changes before closing?</b>"
   77.84 +msgstr "Menti a változásokat mielőtt bezárja?"
   77.85 +
   77.86 +#: main_win.cc:271
   77.87 +msgid "Close file _without Saving"
   77.88 +msgstr "Bezárás mentés _nékül"
   77.89 +
   77.90 +#: main_win.cc:458 main_win.cc:487
   77.91 +msgid "Create New Map - "
   77.92 +msgstr "Új map létrehozása - "
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/save_details_dialog.cc	Mon Jul 07 08:10:39 2008 -0500
    78.3 @@ -0,0 +1,16 @@
    78.4 +#include "save_details_dialog.h"
    78.5 +#include <gtkmm/stock.h>
    78.6 +
    78.7 +SaveDetailsDialog::SaveDetailsDialog(MapStorage *ms) :
    78.8 +  Gtk::Dialog("Save Details", true),
    78.9 +  SaveDetails(ms)
   78.10 +{
   78.11 +  set_size_request(400, -1);
   78.12 +
   78.13 +  Gtk::VBox* pVBox = get_vbox();
   78.14 +  pVBox->pack_start(SaveDetails, Gtk::PACK_SHRINK);
   78.15 +
   78.16 +  add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
   78.17 +
   78.18 +  show_all_children();
   78.19 +}
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/save_details_dialog.h	Mon Jul 07 08:10:39 2008 -0500
    79.3 @@ -0,0 +1,15 @@
    79.4 +#ifndef SAVE_DETAILS_DIALOG
    79.5 +#define SAVE_DETAILS_DIALOG
    79.6 +
    79.7 +#include <gtkmm/dialog.h>
    79.8 +#include "save_details_widget.h"
    79.9 +
   79.10 +class SaveDetailsDialog : public Gtk::Dialog
   79.11 +{
   79.12 +  private:
   79.13 +    SaveDetailsWidget SaveDetails;
   79.14 +  public:
   79.15 +    SaveDetailsDialog(MapStorage*);
   79.16 +};
   79.17 +
   79.18 +#endif
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/save_details_widget.cc	Mon Jul 07 08:10:39 2008 -0500
    80.3 @@ -0,0 +1,616 @@
    80.4 +#include "save_details_widget.h"
    80.5 +#include "mapstorage.h"
    80.6 +
    80.7 +SaveDetailsWidget::SaveDetailsWidget(MapStorage* ms) :
    80.8 +  pMapStorage(ms)
    80.9 +{
   80.10 +  Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook);
   80.11 +  pack_start(*nb, Gtk::PACK_EXPAND_WIDGET);
   80.12 +
   80.13 +  nb->set_tab_pos(Gtk::POS_TOP);
   80.14 +
   80.15 +  Gtk::VBox* vblueMaps = Gtk::manage(new Gtk::VBox(false, 18));
   80.16 +  vblueMaps->set_border_width(12);
   80.17 +
   80.18 +  Gtk::VBox* vbArcMaps = Gtk::manage(new Gtk::VBox(false, 18));
   80.19 +  vbArcMaps->set_border_width(12);
   80.20 +
   80.21 +  Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18));
   80.22 +  vbSpecMaps->set_border_width(12);
   80.23 +
   80.24 +  Gtk::VBox* vbGuiSect = Gtk::manage(new Gtk::VBox(false, 18));
   80.25 +  vbGuiSect->set_border_width(12);
   80.26 +
   80.27 +  nb->append_page(*vbSpecMaps, "Special Maps");
   80.28 +  nb->append_page(*vblueMaps, "Node Maps");
   80.29 +  nb->append_page(*vbArcMaps, "Arc Maps");
   80.30 +  nb->append_page(*vbGuiSect, "GUI Section");
   80.31 +
   80.32 +  // child widgets of vbSpecMaps
   80.33 +
   80.34 +  {
   80.35 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   80.36 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   80.37 +
   80.38 +    Gtk::Label* lblNodeCoordMap =
   80.39 +      Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>"));
   80.40 +    lblNodeCoordMap->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   80.41 +    lblNodeCoordMap->set_use_markup();
   80.42 +    box1->pack_start(*lblNodeCoordMap, Gtk::PACK_SHRINK);
   80.43 +
   80.44 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   80.45 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   80.46 +
   80.47 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   80.48 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   80.49 +
   80.50 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
   80.51 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
   80.52 +
   80.53 +    rblueCoordGuiSection.set_label("Save to GUI section");
   80.54 +    rblueCoordNodesetSection.set_label("Save to Nodeset section");
   80.55 +    Gtk::RadioButtonGroup group = rblueCoordGuiSection.get_group();
   80.56 +    rblueCoordNodesetSection.set_group(group);
   80.57 +
   80.58 +    box3->pack_start(rblueCoordGuiSection, Gtk::PACK_SHRINK);
   80.59 +    box3->pack_start(rblueCoordNodesetSection, Gtk::PACK_SHRINK);
   80.60 +
   80.61 +    Gtk::HBox* box4 = Gtk::manage(new Gtk::HBox);
   80.62 +    box3->pack_start(*box4, Gtk::PACK_SHRINK);
   80.63 +
   80.64 +    Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
   80.65 +    box4->pack_start(*fill2, Gtk::PACK_SHRINK);
   80.66 +
   80.67 +    Gtk::Table* table1 = Gtk::manage(new Gtk::Table(3, 2));
   80.68 +    box4->pack_start(*table1, Gtk::PACK_SHRINK);
   80.69 +
   80.70 +    rblueCoordOneMap.set_label("As one map");
   80.71 +    rblueCoordTwoMaps.set_label("As two maps");
   80.72 +    group = rblueCoordOneMap.get_group();
   80.73 +    rblueCoordTwoMaps.set_group(group);
   80.74 +
   80.75 +    table1->attach(rblueCoordOneMap, 0, 1, 0, 1);
   80.76 +    table1->attach(rblueCoordTwoMaps, 0, 1, 1, 2);
   80.77 +    table1->attach(entNodeCoordsOneMap, 1, 2, 0, 1);
   80.78 +    table1->attach(entNodeCoordsTwoMaps1, 1, 2, 1, 2);
   80.79 +    table1->attach(entNodeCoordsTwoMaps2, 1, 2, 2, 3);
   80.80 +
   80.81 +    switch (pMapStorage->getNodeCoordsSaveDest())
   80.82 +    {
   80.83 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
   80.84 +        rblueCoordGuiSection.set_active();
   80.85 +        rblueCoordOneMap.set_sensitive(false);
   80.86 +        rblueCoordTwoMaps.set_sensitive(false);
   80.87 +        entNodeCoordsOneMap.set_sensitive(false);
   80.88 +        entNodeCoordsTwoMaps1.set_sensitive(false);
   80.89 +        entNodeCoordsTwoMaps2.set_sensitive(false);
   80.90 +        break;
   80.91 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
   80.92 +        rblueCoordNodesetSection.set_active();
   80.93 +        rblueCoordOneMap.set_sensitive(true);
   80.94 +        rblueCoordTwoMaps.set_sensitive(true);
   80.95 +        switch (pMapStorage->getNodeCoordsSaveMapNum())
   80.96 +        {
   80.97 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
   80.98 +            rblueCoordOneMap.set_active();
   80.99 +            entNodeCoordsOneMap.set_sensitive(true);
  80.100 +            entNodeCoordsTwoMaps1.set_sensitive(false);
  80.101 +            entNodeCoordsTwoMaps2.set_sensitive(false);
  80.102 +            break;
  80.103 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  80.104 +            rblueCoordTwoMaps.set_active();
  80.105 +            entNodeCoordsOneMap.set_sensitive(false);
  80.106 +            entNodeCoordsTwoMaps1.set_sensitive(true);
  80.107 +            entNodeCoordsTwoMaps2.set_sensitive(true);
  80.108 +            break;
  80.109 +        }
  80.110 +        break;
  80.111 +    }
  80.112 +
  80.113 +    entNodeCoordsOneMap.set_text(pMapStorage->getNodeCoordsOneMapName());
  80.114 +    entNodeCoordsTwoMaps1.set_text(pMapStorage->getNodeCoordsTwoMaps1Name());
  80.115 +    entNodeCoordsTwoMaps2.set_text(pMapStorage->getNodeCoordsTwoMaps2Name());
  80.116 +
  80.117 +    entNodeCoordsOneMap.signal_changed().connect(
  80.118 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsOneMapName));
  80.119 +    entNodeCoordsTwoMaps1.signal_changed().connect(
  80.120 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsTwoMaps1Name));
  80.121 +    entNodeCoordsTwoMaps2.signal_changed().connect(
  80.122 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsTwoMaps2Name));
  80.123 +
  80.124 +    rblueCoordGuiSection.signal_toggled().connect(
  80.125 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordSaveDestChanged));
  80.126 +    rblueCoordNodesetSection.signal_toggled().connect(
  80.127 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordSaveDestChanged));
  80.128 +    rblueCoordOneMap.signal_toggled().connect(
  80.129 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordMapNumChanged));
  80.130 +    rblueCoordTwoMaps.signal_toggled().connect(
  80.131 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordMapNumChanged));
  80.132 +  }
  80.133 +
  80.134 +  {
  80.135 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  80.136 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  80.137 +
  80.138 +    Gtk::Label* lblArrowCoordMap =
  80.139 +      Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>"));
  80.140 +    lblArrowCoordMap->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  80.141 +    lblArrowCoordMap->set_use_markup();
  80.142 +    box1->pack_start(*lblArrowCoordMap, Gtk::PACK_SHRINK);
  80.143 +
  80.144 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  80.145 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  80.146 +
  80.147 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  80.148 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  80.149 +
  80.150 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
  80.151 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
  80.152 +
  80.153 +    rbArrowCoordGuiSection.set_label("Save to GUI section");
  80.154 +    rbArrowCoordArcsetSection.set_label("Save to Arcset section");
  80.155 +    Gtk::RadioButtonGroup group = rbArrowCoordGuiSection.get_group();
  80.156 +    rbArrowCoordArcsetSection.set_group(group);
  80.157 +
  80.158 +    box3->pack_start(rbArrowCoordGuiSection, Gtk::PACK_SHRINK);
  80.159 +    box3->pack_start(rbArrowCoordArcsetSection, Gtk::PACK_SHRINK);
  80.160 +
  80.161 +    Gtk::HBox* box4 = Gtk::manage(new Gtk::HBox);
  80.162 +    box3->pack_start(*box4, Gtk::PACK_SHRINK);
  80.163 +
  80.164 +    Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
  80.165 +    box4->pack_start(*fill2, Gtk::PACK_SHRINK);
  80.166 +
  80.167 +    Gtk::Table* table1 = Gtk::manage(new Gtk::Table(3, 2));
  80.168 +    box4->pack_start(*table1, Gtk::PACK_SHRINK);
  80.169 +
  80.170 +    rbArrowCoordOneMap.set_label("As one map");
  80.171 +    rbArrowCoordTwoMaps.set_label("As two maps");
  80.172 +    group = rbArrowCoordOneMap.get_group();
  80.173 +    rbArrowCoordTwoMaps.set_group(group);
  80.174 +
  80.175 +    table1->attach(rbArrowCoordOneMap, 0, 1, 0, 1);
  80.176 +    table1->attach(rbArrowCoordTwoMaps, 0, 1, 1, 2);
  80.177 +    table1->attach(entArrowCoordsOneMap, 1, 2, 0, 1);
  80.178 +    table1->attach(entArrowCoordsTwoMaps1, 1, 2, 1, 2);
  80.179 +    table1->attach(entArrowCoordsTwoMaps2, 1, 2, 2, 3);
  80.180 +
  80.181 +    switch (pMapStorage->getArrowCoordsSaveDest())
  80.182 +    {
  80.183 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  80.184 +        rbArrowCoordGuiSection.set_active();
  80.185 +        rbArrowCoordOneMap.set_sensitive(false);
  80.186 +        rbArrowCoordTwoMaps.set_sensitive(false);
  80.187 +        entArrowCoordsOneMap.set_sensitive(false);
  80.188 +        entArrowCoordsTwoMaps1.set_sensitive(false);
  80.189 +        entArrowCoordsTwoMaps2.set_sensitive(false);
  80.190 +        break;
  80.191 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  80.192 +        rbArrowCoordArcsetSection.set_active();
  80.193 +        rbArrowCoordOneMap.set_sensitive(true);
  80.194 +        rbArrowCoordTwoMaps.set_sensitive(true);
  80.195 +        switch (pMapStorage->getArrowCoordsSaveMapNum())
  80.196 +        {
  80.197 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  80.198 +            rbArrowCoordOneMap.set_active();
  80.199 +            entArrowCoordsOneMap.set_sensitive(true);
  80.200 +            entArrowCoordsTwoMaps1.set_sensitive(false);
  80.201 +            entArrowCoordsTwoMaps2.set_sensitive(false);
  80.202 +            break;
  80.203 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  80.204 +            rbArrowCoordTwoMaps.set_active();
  80.205 +            entArrowCoordsOneMap.set_sensitive(false);
  80.206 +            entArrowCoordsTwoMaps1.set_sensitive(true);
  80.207 +            entArrowCoordsTwoMaps2.set_sensitive(true);
  80.208 +            break;
  80.209 +        }
  80.210 +        break;
  80.211 +    }
  80.212 +
  80.213 +    entArrowCoordsOneMap.set_text(pMapStorage->getArrowCoordsOneMapName());
  80.214 +    entArrowCoordsTwoMaps1.set_text(pMapStorage->getArrowCoordsTwoMaps1Name());
  80.215 +    entArrowCoordsTwoMaps2.set_text(pMapStorage->getArrowCoordsTwoMaps2Name());
  80.216 +
  80.217 +    entArrowCoordsOneMap.signal_changed().connect(
  80.218 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsOneMapName));
  80.219 +    entArrowCoordsTwoMaps1.signal_changed().connect(
  80.220 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsTwoMaps1Name));
  80.221 +    entArrowCoordsTwoMaps2.signal_changed().connect(
  80.222 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsTwoMaps2Name));
  80.223 +
  80.224 +    rbArrowCoordGuiSection.signal_toggled().connect(
  80.225 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordSaveDestChanged));
  80.226 +    rbArrowCoordArcsetSection.signal_toggled().connect(
  80.227 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordSaveDestChanged));
  80.228 +    rbArrowCoordOneMap.signal_toggled().connect(
  80.229 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordMapNumChanged));
  80.230 +    rbArrowCoordTwoMaps.signal_toggled().connect(
  80.231 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordMapNumChanged));
  80.232 +  }
  80.233 +
  80.234 +  // child widgets of vbGuiSect
  80.235 +
  80.236 +  {
  80.237 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  80.238 +    vbGuiSect->pack_start(*box1, Gtk::PACK_SHRINK);
  80.239 +
  80.240 +    Gtk::Label* lblGuiSectionSave =
  80.241 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  80.242 +    lblGuiSectionSave->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  80.243 +    lblGuiSectionSave->set_use_markup();
  80.244 +    box1->pack_start(*lblGuiSectionSave, Gtk::PACK_SHRINK);
  80.245 +
  80.246 +    rbLgfFile.set_label("Lgf file");
  80.247 +    rbConfFile.set_label("Conf file");
  80.248 +
  80.249 +    Gtk::RadioButtonGroup group = rbLgfFile.get_group();
  80.250 +    rbConfFile.set_group(group);
  80.251 +
  80.252 +    switch (pMapStorage->getGUIDataSaveLocation())
  80.253 +    {
  80.254 +      case MapStorage::LGF_FILE:
  80.255 +        rbLgfFile.set_active();
  80.256 +        break;
  80.257 +      case MapStorage::CONF_FILE:
  80.258 +        rbConfFile.set_active();
  80.259 +        break;
  80.260 +    }
  80.261 +
  80.262 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  80.263 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  80.264 +
  80.265 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  80.266 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  80.267 +
  80.268 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
  80.269 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
  80.270 +
  80.271 +    box3->pack_start(rbLgfFile, Gtk::PACK_SHRINK);
  80.272 +    box3->pack_start(rbConfFile, Gtk::PACK_SHRINK);
  80.273 +
  80.274 +    rbLgfFile.signal_toggled().connect(
  80.275 +        sigc::mem_fun(*this, &SaveDetailsWidget::onGuiSectSaveDestChanged));
  80.276 +    rbConfFile.signal_toggled().connect(
  80.277 +        sigc::mem_fun(*this, &SaveDetailsWidget::onGuiSectSaveDestChanged));
  80.278 +  }
  80.279 +
  80.280 +  // child widgets of vblueMaps
  80.281 +
  80.282 +  {
  80.283 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  80.284 +    vblueMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  80.285 +
  80.286 +    Gtk::Label* label1 =
  80.287 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  80.288 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  80.289 +    label1->set_use_markup();
  80.290 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  80.291 +
  80.292 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  80.293 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  80.294 +
  80.295 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  80.296 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  80.297 +
  80.298 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  80.299 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  80.300 +
  80.301 +    Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow);
  80.302 +    frame->add(*swNodeMaps);
  80.303 +
  80.304 +    swNodeMaps->add(twNodeMaps);
  80.305 +
  80.306 +    refNodeMapStore = Gtk::ListStore::create(NodeMapColumns);
  80.307 +
  80.308 +    std::vector<std::string> node_maps = pMapStorage->getNodeMapList();
  80.309 +    for (std::vector<std::string>::const_iterator it = node_maps.begin();
  80.310 +        it != node_maps.end(); ++it)
  80.311 +    {
  80.312 +      Gtk::TreeModel::Row row = *(refNodeMapStore->append());
  80.313 +      row[NodeMapColumns.colName] = *it;
  80.314 +      switch (pMapStorage->getNodeMapSaveDest(*it))
  80.315 +      {
  80.316 +        case MapStorage::GUI_SECT:
  80.317 +          row[NodeMapColumns.colSaveToMainSect] = false;
  80.318 +          row[NodeMapColumns.colSaveToGuiSect] = true;
  80.319 +          break;
  80.320 +        case MapStorage::NESET_SECT:
  80.321 +          row[NodeMapColumns.colSaveToMainSect] = true;
  80.322 +          row[NodeMapColumns.colSaveToGuiSect] = false;
  80.323 +          break;
  80.324 +        case MapStorage::DONT_SAVE:
  80.325 +          row[NodeMapColumns.colSaveToMainSect] = false;
  80.326 +          row[NodeMapColumns.colSaveToGuiSect] = false;
  80.327 +          break;
  80.328 +      }
  80.329 +    }
  80.330 +
  80.331 +    twNodeMaps.set_model(refNodeMapStore);
  80.332 +    twNodeMaps.append_column("Name", NodeMapColumns.colName);
  80.333 +    twNodeMaps.append_column_editable("Nodeset section",
  80.334 +        NodeMapColumns.colSaveToMainSect);
  80.335 +    twNodeMaps.append_column_editable("GUI section",
  80.336 +        NodeMapColumns.colSaveToGuiSect);
  80.337 +
  80.338 +    swNodeMaps->set_size_request(-1, 200);
  80.339 +    swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  80.340 +
  80.341 +    refNodeMapStore->signal_row_changed().connect(
  80.342 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeMapRowChanged));
  80.343 +  }
  80.344 +
  80.345 +  // child widgets of vbArcMaps
  80.346 +
  80.347 +  {
  80.348 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  80.349 +    vbArcMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  80.350 +
  80.351 +    Gtk::Label* label1 =
  80.352 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  80.353 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  80.354 +    label1->set_use_markup();
  80.355 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  80.356 +
  80.357 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  80.358 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  80.359 +
  80.360 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  80.361 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  80.362 +
  80.363 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  80.364 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  80.365 +
  80.366 +    Gtk::ScrolledWindow* swArcMaps = Gtk::manage(new Gtk::ScrolledWindow);
  80.367 +    frame->add(*swArcMaps);
  80.368 +
  80.369 +    swArcMaps->add(twArcMaps);
  80.370 +
  80.371 +    refArcMapStore = Gtk::ListStore::create(ArcMapColumns);
  80.372 +
  80.373 +    std::vector<std::string> arc_maps = pMapStorage->getArcMapList();
  80.374 +    for (std::vector<std::string>::const_iterator it = arc_maps.begin();
  80.375 +        it != arc_maps.end(); ++it)
  80.376 +    {
  80.377 +      Gtk::TreeModel::Row row = *(refArcMapStore->append());
  80.378 +      row[ArcMapColumns.colName] = *it;
  80.379 +      switch (pMapStorage->getArcMapSaveDest(*it))
  80.380 +      {
  80.381 +        case MapStorage::GUI_SECT:
  80.382 +          row[ArcMapColumns.colSaveToMainSect] = false;
  80.383 +          row[ArcMapColumns.colSaveToGuiSect] = true;
  80.384 +          break;
  80.385 +        case MapStorage::NESET_SECT:
  80.386 +          row[ArcMapColumns.colSaveToMainSect] = true;
  80.387 +          row[ArcMapColumns.colSaveToGuiSect] = false;
  80.388 +          break;
  80.389 +        case MapStorage::DONT_SAVE:
  80.390 +          row[ArcMapColumns.colSaveToMainSect] = false;
  80.391 +          row[ArcMapColumns.colSaveToGuiSect] = false;
  80.392 +          break;
  80.393 +      }
  80.394 +    }
  80.395 +
  80.396 +    twArcMaps.set_model(refArcMapStore);
  80.397 +    twArcMaps.append_column("Name", ArcMapColumns.colName);
  80.398 +    twArcMaps.append_column_editable("Arcset section",
  80.399 +        ArcMapColumns.colSaveToMainSect);
  80.400 +    twArcMaps.append_column_editable("GUI section",
  80.401 +        ArcMapColumns.colSaveToGuiSect);
  80.402 +
  80.403 +    swArcMaps->set_size_request(-1, 200);
  80.404 +    swArcMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  80.405 +
  80.406 +    refArcMapStore->signal_row_changed().connect(
  80.407 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArcMapRowChanged));
  80.408 +  }
  80.409 +
  80.410 +  show_all_children();
  80.411 +}
  80.412 +
  80.413 +void SaveDetailsWidget::onGuiSectSaveDestChanged()
  80.414 +{
  80.415 +  if (rbLgfFile.get_active())
  80.416 +  {
  80.417 +    pMapStorage->setGUIDataSaveLocation(MapStorage::LGF_FILE);
  80.418 +  }
  80.419 +  else if (rbConfFile.get_active())
  80.420 +  {
  80.421 +    pMapStorage->setGUIDataSaveLocation(MapStorage::CONF_FILE);
  80.422 +  }
  80.423 +}
  80.424 +
  80.425 +void SaveDetailsWidget::onArcMapRowChanged(const Gtk::TreeModel::Path& path,
  80.426 +    const Gtk::TreeModel::iterator& iter)
  80.427 +{
  80.428 +  Gtk::TreeModel::Row row = *iter;
  80.429 +  Glib::ustring map_name = row[ArcMapColumns.colName];
  80.430 +  if (row[ArcMapColumns.colSaveToMainSect] &&
  80.431 +      row[ArcMapColumns.colSaveToGuiSect])
  80.432 +  {
  80.433 +    if (pMapStorage->getArcMapSaveDest(map_name) == MapStorage::NESET_SECT)
  80.434 +    {
  80.435 +      pMapStorage->setArcMapSaveDest(map_name, MapStorage::GUI_SECT);
  80.436 +      row[ArcMapColumns.colSaveToMainSect] = false;
  80.437 +    }
  80.438 +    else
  80.439 +    {
  80.440 +      pMapStorage->setArcMapSaveDest(map_name, MapStorage::NESET_SECT);
  80.441 +      row[ArcMapColumns.colSaveToGuiSect] = false;
  80.442 +    }
  80.443 +  }
  80.444 +  else if (row[ArcMapColumns.colSaveToMainSect])
  80.445 +  {
  80.446 +    pMapStorage->setArcMapSaveDest(map_name, MapStorage::NESET_SECT);
  80.447 +  }
  80.448 +  else if (row[ArcMapColumns.colSaveToGuiSect])
  80.449 +  {
  80.450 +    pMapStorage->setArcMapSaveDest(map_name, MapStorage::GUI_SECT);
  80.451 +  }
  80.452 +  else
  80.453 +  {
  80.454 +    pMapStorage->setArcMapSaveDest(map_name, MapStorage::DONT_SAVE);
  80.455 +  }
  80.456 +}
  80.457 +
  80.458 +void SaveDetailsWidget::onNodeMapRowChanged(const Gtk::TreeModel::Path& path,
  80.459 +    const Gtk::TreeModel::iterator& iter)
  80.460 +{
  80.461 +  Gtk::TreeModel::Row row = *iter;
  80.462 +  Glib::ustring map_name = row[NodeMapColumns.colName];
  80.463 +  if (row[NodeMapColumns.colSaveToMainSect] &&
  80.464 +      row[NodeMapColumns.colSaveToGuiSect])
  80.465 +  {
  80.466 +    if (pMapStorage->getNodeMapSaveDest(map_name) == MapStorage::NESET_SECT)
  80.467 +    {
  80.468 +      pMapStorage->setNodeMapSaveDest(map_name, MapStorage::GUI_SECT);
  80.469 +      row[NodeMapColumns.colSaveToMainSect] = false;
  80.470 +    }
  80.471 +    else
  80.472 +    {
  80.473 +      pMapStorage->setNodeMapSaveDest(map_name, MapStorage::NESET_SECT);
  80.474 +      row[NodeMapColumns.colSaveToGuiSect] = false;
  80.475 +    }
  80.476 +  }
  80.477 +  else if (row[NodeMapColumns.colSaveToMainSect])
  80.478 +  {
  80.479 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::NESET_SECT);
  80.480 +  }
  80.481 +  else if (row[NodeMapColumns.colSaveToGuiSect])
  80.482 +  {
  80.483 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::GUI_SECT);
  80.484 +  }
  80.485 +  else
  80.486 +  {
  80.487 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::DONT_SAVE);
  80.488 +  }
  80.489 +}
  80.490 +
  80.491 +void SaveDetailsWidget::onNodeCoordSaveDestChanged()
  80.492 +{
  80.493 +  if (rblueCoordGuiSection.get_active())
  80.494 +  {
  80.495 +    pMapStorage->setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::GUI_SECT);
  80.496 +    rblueCoordOneMap.set_sensitive(false);
  80.497 +    rblueCoordTwoMaps.set_sensitive(false);
  80.498 +    entNodeCoordsOneMap.set_sensitive(false);
  80.499 +    entNodeCoordsTwoMaps1.set_sensitive(false);
  80.500 +    entNodeCoordsTwoMaps2.set_sensitive(false);
  80.501 +  }
  80.502 +  else if (rblueCoordNodesetSection.get_active())
  80.503 +  {
  80.504 +    pMapStorage->setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::NESET_SECT);
  80.505 +    rblueCoordOneMap.set_sensitive(true);
  80.506 +    rblueCoordTwoMaps.set_sensitive(true);
  80.507 +    switch (pMapStorage->getNodeCoordsSaveMapNum())
  80.508 +    {
  80.509 +      case MapStorage::SpecMapSaveOpts::ONE_MAP:
  80.510 +        entNodeCoordsOneMap.set_sensitive(true);
  80.511 +        entNodeCoordsTwoMaps1.set_sensitive(false);
  80.512 +        entNodeCoordsTwoMaps2.set_sensitive(false);
  80.513 +        break;
  80.514 +      case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  80.515 +        entNodeCoordsOneMap.set_sensitive(false);
  80.516 +        entNodeCoordsTwoMaps1.set_sensitive(true);
  80.517 +        entNodeCoordsTwoMaps2.set_sensitive(true);
  80.518 +        break;
  80.519 +    }
  80.520 +  }
  80.521 +}
  80.522 +
  80.523 +void SaveDetailsWidget::onNodeCoordMapNumChanged()
  80.524 +{
  80.525 +  if (rblueCoordOneMap.get_active())
  80.526 +  {
  80.527 +    pMapStorage->setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::ONE_MAP);
  80.528 +    entNodeCoordsOneMap.set_sensitive(true);
  80.529 +    entNodeCoordsTwoMaps1.set_sensitive(false);
  80.530 +    entNodeCoordsTwoMaps2.set_sensitive(false);
  80.531 +  }
  80.532 +  else if (rblueCoordTwoMaps.get_active())
  80.533 +  {
  80.534 +    pMapStorage->setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::TWO_MAPS);
  80.535 +    entNodeCoordsOneMap.set_sensitive(false);
  80.536 +    entNodeCoordsTwoMaps1.set_sensitive(true);
  80.537 +    entNodeCoordsTwoMaps2.set_sensitive(true);
  80.538 +  }
  80.539 +}
  80.540 +
  80.541 +void SaveDetailsWidget::onNodeCoordsOneMapName()
  80.542 +{
  80.543 +  pMapStorage->setNodeCoordsOneMapName(entNodeCoordsOneMap.get_text());
  80.544 +}
  80.545 +void SaveDetailsWidget::onNodeCoordsTwoMaps1Name()
  80.546 +{
  80.547 +  pMapStorage->setNodeCoordsTwoMaps1Name(entNodeCoordsTwoMaps1.get_text());
  80.548 +}
  80.549 +void SaveDetailsWidget::onNodeCoordsTwoMaps2Name()
  80.550 +{
  80.551 +  pMapStorage->setNodeCoordsTwoMaps2Name(entNodeCoordsTwoMaps2.get_text());
  80.552 +}
  80.553 +
  80.554 +void SaveDetailsWidget::onArrowCoordSaveDestChanged()
  80.555 +{
  80.556 +  if (rbArrowCoordGuiSection.get_active())
  80.557 +  {
  80.558 +    pMapStorage->setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::GUI_SECT);
  80.559 +    rbArrowCoordOneMap.set_sensitive(false);
  80.560 +    rbArrowCoordTwoMaps.set_sensitive(false);
  80.561 +    entArrowCoordsOneMap.set_sensitive(false);
  80.562 +    entArrowCoordsTwoMaps1.set_sensitive(false);
  80.563 +    entArrowCoordsTwoMaps2.set_sensitive(false);
  80.564 +  }
  80.565 +  else if (rbArrowCoordArcsetSection.get_active())
  80.566 +  {
  80.567 +    pMapStorage->setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::NESET_SECT);
  80.568 +    rbArrowCoordOneMap.set_sensitive(true);
  80.569 +    rbArrowCoordTwoMaps.set_sensitive(true);
  80.570 +    switch (pMapStorage->getArrowCoordsSaveMapNum())
  80.571 +    {
  80.572 +      case MapStorage::SpecMapSaveOpts::ONE_MAP:
  80.573 +        entArrowCoordsOneMap.set_sensitive(true);
  80.574 +        entArrowCoordsTwoMaps1.set_sensitive(false);
  80.575 +        entArrowCoordsTwoMaps2.set_sensitive(false);
  80.576 +        break;
  80.577 +      case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  80.578 +        entArrowCoordsOneMap.set_sensitive(false);
  80.579 +        entArrowCoordsTwoMaps1.set_sensitive(true);
  80.580 +        entArrowCoordsTwoMaps2.set_sensitive(true);
  80.581 +        break;
  80.582 +    }
  80.583 +  }
  80.584 +}
  80.585 +
  80.586 +void SaveDetailsWidget::onArrowCoordMapNumChanged()
  80.587 +{
  80.588 +  if (rbArrowCoordOneMap.get_active())
  80.589 +  {
  80.590 +    pMapStorage->setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::ONE_MAP);
  80.591 +    entArrowCoordsOneMap.set_sensitive(true);
  80.592 +    entArrowCoordsTwoMaps1.set_sensitive(false);
  80.593 +    entArrowCoordsTwoMaps2.set_sensitive(false);
  80.594 +  }
  80.595 +  else if (rbArrowCoordTwoMaps.get_active())
  80.596 +  {
  80.597 +    pMapStorage->setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::TWO_MAPS);
  80.598 +    entArrowCoordsOneMap.set_sensitive(false);
  80.599 +    entArrowCoordsTwoMaps1.set_sensitive(true);
  80.600 +    entArrowCoordsTwoMaps2.set_sensitive(true);
  80.601 +  }
  80.602 +}
  80.603 +
  80.604 +void SaveDetailsWidget::onArrowCoordsOneMapName()
  80.605 +{
  80.606 +  pMapStorage->setArrowCoordsOneMapName(entArrowCoordsOneMap.get_text());
  80.607 +}
  80.608 +void SaveDetailsWidget::onArrowCoordsTwoMaps1Name()
  80.609 +{
  80.610 +  pMapStorage->setArrowCoordsTwoMaps1Name(entArrowCoordsTwoMaps1.get_text());
  80.611 +}
  80.612 +void SaveDetailsWidget::onArrowCoordsTwoMaps2Name()
  80.613 +{
  80.614 +  pMapStorage->setArrowCoordsTwoMaps2Name(entArrowCoordsTwoMaps2.get_text());
  80.615 +}
  80.616 +
  80.617 +SaveDetailsWidget::~SaveDetailsWidget()
  80.618 +{
  80.619 +}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/save_details_widget.h	Mon Jul 07 08:10:39 2008 -0500
    81.3 @@ -0,0 +1,87 @@
    81.4 +#ifndef SAVE_DETAILS_WIDGET
    81.5 +#define SAVE_DETAILS_WIDGET
    81.6 +
    81.7 +#include <gtkmm/entry.h>
    81.8 +#include <gtkmm/box.h>
    81.9 +#include <gtkmm/radiobutton.h>
   81.10 +#include <gtkmm/label.h>
   81.11 +#include <gtkmm/notebook.h>
   81.12 +#include <gtkmm/treemodel.h>
   81.13 +#include <gtkmm/liststore.h>
   81.14 +#include <gtkmm/treeview.h>
   81.15 +#include <gtkmm/scrolledwindow.h>
   81.16 +
   81.17 +class MapStorage;
   81.18 +
   81.19 +class SaveDetailsWidget : public Gtk::VBox
   81.20 +{
   81.21 +  public:
   81.22 +    struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
   81.23 +    {
   81.24 +      MapModelColumns()
   81.25 +      {
   81.26 +        add(colName);
   81.27 +        add(colSaveToMainSect);
   81.28 +        add(colSaveToGuiSect);
   81.29 +      }
   81.30 +      Gtk::TreeModelColumn<Glib::ustring> colName;
   81.31 +      Gtk::TreeModelColumn<bool> colSaveToMainSect;
   81.32 +      Gtk::TreeModelColumn<bool> colSaveToGuiSect;
   81.33 +    };
   81.34 +  private:
   81.35 +    Gtk::RadioButton rbLgfFile;
   81.36 +    Gtk::RadioButton rbConfFile;
   81.37 +
   81.38 +    Gtk::TreeView twNodeMaps;
   81.39 +    Gtk::TreeView twArcMaps;
   81.40 +
   81.41 +    MapModelColumns NodeMapColumns;
   81.42 +    MapModelColumns ArcMapColumns;
   81.43 +
   81.44 +    Glib::RefPtr<Gtk::ListStore> refNodeMapStore;
   81.45 +    Glib::RefPtr<Gtk::ListStore> refArcMapStore;
   81.46 +
   81.47 +    Gtk::RadioButton rblueCoordGuiSection;
   81.48 +    Gtk::RadioButton rblueCoordNodesetSection;
   81.49 +    Gtk::RadioButton rblueCoordOneMap;
   81.50 +    Gtk::RadioButton rblueCoordTwoMaps;
   81.51 +    Gtk::Entry entNodeCoordsOneMap;
   81.52 +    Gtk::Entry entNodeCoordsTwoMaps1;
   81.53 +    Gtk::Entry entNodeCoordsTwoMaps2;
   81.54 +
   81.55 +    Gtk::RadioButton rbArrowCoordGuiSection;
   81.56 +    Gtk::RadioButton rbArrowCoordArcsetSection;
   81.57 +    Gtk::RadioButton rbArrowCoordOneMap;
   81.58 +    Gtk::RadioButton rbArrowCoordTwoMaps;
   81.59 +    Gtk::Entry entArrowCoordsOneMap;
   81.60 +    Gtk::Entry entArrowCoordsTwoMaps1;
   81.61 +    Gtk::Entry entArrowCoordsTwoMaps2;
   81.62 +
   81.63 +    MapStorage* pMapStorage;
   81.64 +
   81.65 +    void onGuiSectSaveDestChanged();
   81.66 +
   81.67 +    void onNodeCoordSaveDestChanged();
   81.68 +    void onNodeCoordMapNumChanged();
   81.69 +
   81.70 +    void onNodeCoordsOneMapName();
   81.71 +    void onNodeCoordsTwoMaps1Name();
   81.72 +    void onNodeCoordsTwoMaps2Name();
   81.73 +
   81.74 +    void onArrowCoordSaveDestChanged();
   81.75 +    void onArrowCoordMapNumChanged();
   81.76 +
   81.77 +    void onArrowCoordsOneMapName();
   81.78 +    void onArrowCoordsTwoMaps1Name();
   81.79 +    void onArrowCoordsTwoMaps2Name();
   81.80 +
   81.81 +    void onArcMapRowChanged(const Gtk::TreeModel::Path& path,
   81.82 +        const Gtk::TreeModel::iterator& iter);
   81.83 +    void onNodeMapRowChanged(const Gtk::TreeModel::Path& path,
   81.84 +        const Gtk::TreeModel::iterator& iter);
   81.85 +  public:
   81.86 +    SaveDetailsWidget(MapStorage* ms);
   81.87 +    ~SaveDetailsWidget();
   81.88 +};
   81.89 +
   81.90 +#endif
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/xml.h	Mon Jul 07 08:10:39 2008 -0500
    82.3 @@ -0,0 +1,448 @@
    82.4 +/* -*- C++ -*-
    82.5 + *
    82.6 + * This file is a part of LEMON, a generic C++ optimization library
    82.7 + *
    82.8 + * Copyright (C) 2003-2006
    82.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   82.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   82.11 + *
   82.12 + * Permission to use, modify and distribute this software is granted
   82.13 + * provided that this copyright notice appears in all copies. For
   82.14 + * precise terms see the accompanying LICENSE file.
   82.15 + *
   82.16 + * This software is provided "AS IS" with no warranty of any kind,
   82.17 + * express or implied, and with no claim as to its suitability for any
   82.18 + * purpose.
   82.19 + *
   82.20 + */
   82.21 +
   82.22 +#ifndef GLEMON_XML_H
   82.23 +#define GLEMON_XML_H
   82.24 +
   82.25 +#include <iostream>
   82.26 +#include <string>
   82.27 +#include <vector>
   82.28 +#include <list>
   82.29 +#include <map>
   82.30 +#include <lemon/error.h>
   82.31 +#include <lemon/dim2.h>
   82.32 +
   82.33 +namespace lemon {
   82.34 +
   82.35 +  class XmlIo 
   82.36 +  {
   82.37 +    bool _writeMode;
   82.38 +  public:
   82.39 +    ///Check if XmlIo is in write mode.
   82.40 +    bool write() { return _writeMode;}
   82.41 +    ///Check if XmlIo is in read mode.
   82.42 +    bool read() { return !_writeMode;}
   82.43 +
   82.44 +    std::ostream& os;
   82.45 +    int level;
   82.46 +    
   82.47 +  protected:
   82.48 +    void indent(int level) {
   82.49 +      os << std::endl;
   82.50 +      for(int i=0;i<level;i++) os << ' ';
   82.51 +    }
   82.52 +    void tag(const std::string &_tag) {
   82.53 +      os << '<' << _tag << '>';
   82.54 +    }
   82.55 +    void etag(const std::string &_tag) {
   82.56 +      os << "</" << _tag << '>';
   82.57 +    }
   82.58 +    void itag(const std::string &_tag) { indent();tag(_tag); }
   82.59 +    void ietag(const std::string &_tag) { indent();etag(_tag); }
   82.60 +
   82.61 +    void beginTag(const std::string &_tag) {
   82.62 +      itag(_tag);
   82.63 +      level++;
   82.64 +    }
   82.65 +    void endTag(const std::string &_tag) {
   82.66 +      level--;
   82.67 +      ietag(_tag);
   82.68 +    }
   82.69 +
   82.70 +  public:
   82.71 +    ///Indent the line according to its level.
   82.72 +
   82.73 +    ///\warning It can only be used in write mode.
   82.74 +    ///
   82.75 +    void indent()
   82.76 +    {
   82.77 +      if(write())
   82.78 +	if(level>=0) indent(level);
   82.79 +	else level=0;
   82.80 +      else throw LogicError();	
   82.81 +    }
   82.82 +  
   82.83 +    ///Read/write a tag
   82.84 +  
   82.85 +    ///Read/write a tag.
   82.86 +    ///In write mode it does not start a new line.
   82.87 +    class ContTag
   82.88 +    {
   82.89 +      XmlIo &ix;
   82.90 +      const std::string _tag;
   82.91 +    public:
   82.92 +      ///\e
   82.93 +  
   82.94 +      ///\e
   82.95 +      ///
   82.96 +      ContTag(XmlIo &_ix,const std::string &_t) :
   82.97 +	ix(_ix), _tag(_t)
   82.98 +      {
   82.99 +	if(ix.write()) ix.tag(_tag);
  82.100 +	else ix.useTag(_tag);
  82.101 +      }
  82.102 +      ~ContTag() { 
  82.103 +	if(ix.write()) ix.etag(_tag);
  82.104 +	else if(!std::uncaught_exception()) ix.useTag('/'+_tag);      
  82.105 +      }
  82.106 +    };
  82.107 +
  82.108 +    ///Read/write a tag
  82.109 +  
  82.110 +    ///Read/write a tag.
  82.111 +    ///The whole \<foo\> ... \</foo\> will be placed in a single line.
  82.112 +    class LineTag
  82.113 +    {
  82.114 +      XmlIo &ix;
  82.115 +      const std::string _tag;
  82.116 +    public:
  82.117 +      ///\e
  82.118 +    
  82.119 +      ///\e
  82.120 +      ///
  82.121 +      LineTag(XmlIo &_ix,const std::string &_t) :
  82.122 +	ix(_ix), _tag(_t)
  82.123 +      {
  82.124 +	if(ix.write()) ix.itag(_tag);
  82.125 +	else ix.useTag(_tag);
  82.126 +      }
  82.127 +      ~LineTag() { 
  82.128 +	if(ix.write()) ix.etag(_tag);
  82.129 +	else if(!std::uncaught_exception()) ix.useTag('/'+_tag);
  82.130 +      }
  82.131 +    };
  82.132 +
  82.133 +    ///Read/write a tag
  82.134 +  
  82.135 +    ///Read/write a tag.
  82.136 +    ///
  82.137 +    class Tag
  82.138 +    {
  82.139 +      XmlIo &ix;
  82.140 +      const std::string _tag;
  82.141 +    public:
  82.142 +      ///\e
  82.143 +  
  82.144 +      ///\e
  82.145 +      ///
  82.146 +      Tag(XmlIo &_ix,const std::string &_t) :
  82.147 +	ix(_ix), _tag(_t)
  82.148 +      {
  82.149 +	if(ix.write()) ix.beginTag(_tag);
  82.150 +	else ix.useTag(_tag);
  82.151 +      }
  82.152 +      ~Tag() {
  82.153 +	if(ix.write()) ix.endTag(_tag);
  82.154 +	else if(!std::uncaught_exception()) ix.useTag('/'+_tag);
  82.155 +      }
  82.156 +    };
  82.157 +
  82.158 +  private:
  82.159 +    std::istream& is;
  82.160 +    std::string next_tag;
  82.161 +    int line_number;
  82.162 +
  82.163 +    void skipWhiteSpaces()
  82.164 +    {
  82.165 +      if(write()) throw LogicError();
  82.166 +      {
  82.167 +	char c;
  82.168 +	while (is.get(c) && std::isspace(c,is.getloc()))
  82.169 +	  if(c=='\n') line_number++;
  82.170 +	is.unget();
  82.171 +      }
  82.172 +    }
  82.173 +  protected:
  82.174 +    /// Use the next tag.
  82.175 +
  82.176 +    ///\e
  82.177 +    ///
  82.178 +    void useTag() {next_tag.clear();}
  82.179 +  
  82.180 +    ///Use the next tag and check if it is equal with \c _tag
  82.181 +  
  82.182 +    ///\e
  82.183 +    ///
  82.184 +    void useTag(const std::string &_tag) {
  82.185 +      if(nextTag()==_tag) useTag();
  82.186 +      else throw DataFormatError("",line_number,"Unexpected token name");
  82.187 +    }
  82.188 +  public:
  82.189 +    ///Return the next tag (if a tag follows on the stream).
  82.190 +  
  82.191 +    ///\warning It can only be used in read mode.
  82.192 +    ///
  82.193 +    const std::string &nextTag() 
  82.194 +    {
  82.195 +      if(write()) throw LogicError();
  82.196 +      else if(next_tag.empty()) {
  82.197 +	char c;
  82.198 +	skipWhiteSpaces();
  82.199 +	if(!is.get(c) || c!='<')
  82.200 +	  throw DataFormatError("",line_number,"Bad format");
  82.201 +	next_tag.clear();
  82.202 +	while (is.get(c) && c!='>') next_tag.push_back(c);
  82.203 +	if(c!='>')
  82.204 +	  throw DataFormatError("",line_number,"Bad format");
  82.205 +      }
  82.206 +      return next_tag;
  82.207 +    }
  82.208 +
  82.209 +    /**********************************************************************/
  82.210 +
  82.211 +
  82.212 +    ///\e
  82.213 +  
  82.214 +    ///\e
  82.215 +    ///
  82.216 +    XmlIo(std::ostream& _os) : _writeMode(true), os(_os),
  82.217 +			       level(-1),
  82.218 +			       is(std::cin) {}
  82.219 +    ///\e
  82.220 +    ///
  82.221 +    XmlIo(std::istream& _is) : _writeMode(false),
  82.222 +			       os(std::cout), is(_is),
  82.223 +			       line_number(1) {}
  82.224 +
  82.225 +    ~XmlIo() { if(write()) os<< std::endl; }
  82.226 +  
  82.227 +
  82.228 +
  82.229 +    XmlIo &operator()(const int &v) 
  82.230 +    { 
  82.231 +      if(write()) os << v;
  82.232 +      else {
  82.233 +	skipWhiteSpaces();
  82.234 +	if(!(is >> const_cast<int &>(v))) 
  82.235 +	  throw DataFormatError("",line_number,"Not an 'int'");
  82.236 +      }
  82.237 +      return *this;
  82.238 +    }
  82.239 +    XmlIo &operator()(const double &v) 
  82.240 +    {
  82.241 +      if(write()) os << v;
  82.242 +      else {
  82.243 +	skipWhiteSpaces();
  82.244 +	if(!(is >> const_cast<double &>(v))) 
  82.245 +	  throw DataFormatError("",line_number,"Not an 'double'");
  82.246 +      }
  82.247 +      return *this;
  82.248 +    }
  82.249 +    XmlIo &operator()(const std::string &v)
  82.250 +    {
  82.251 +      if(write())
  82.252 +	for(std::string::const_iterator i=v.begin();i!=v.end();++i)
  82.253 +	  switch(*i) {
  82.254 +	  case '\\':
  82.255 +	    os << "\\\\";
  82.256 +	    break;
  82.257 +	  case '<':
  82.258 +	    os << "\\<";
  82.259 +	    break;
  82.260 +	  case '&':
  82.261 +	    os << "\\&";
  82.262 +	    break;
  82.263 +	  case '\n':
  82.264 +	    os << "\\n";
  82.265 +	    break;
  82.266 +	  default:
  82.267 +	    os<<*i;
  82.268 +	    break;
  82.269 +	  }
  82.270 +      else {
  82.271 +	std::string &w = const_cast<std::string &>(v);
  82.272 +	w.clear();
  82.273 +	char c;
  82.274 +	while (is.get(c) && c!='<')
  82.275 +	  if(c=='\\')
  82.276 +	    if(!is.get(c))
  82.277 +	      throw DataFormatError("",line_number,"Bad string");
  82.278 +	    else switch(c) {
  82.279 +	    case 'n':
  82.280 +	      w.push_back('\n');
  82.281 +	      break;
  82.282 +	    default:
  82.283 +	      w.push_back(c);
  82.284 +	      break;
  82.285 +	    }
  82.286 +	  else {
  82.287 +	    if(c=='\n') line_number++;
  82.288 +	    w.push_back(c);
  82.289 +	  }
  82.290 +	if(c!='<')
  82.291 +	  throw DataFormatError("",line_number,"Unexpected eof");
  82.292 +	is.unget();
  82.293 +      }
  82.294 +      return *this;
  82.295 +    }
  82.296 +
  82.297 +
  82.298 +    XmlIo &operator()(const std::string &_tag,const int &v) 
  82.299 +    { 
  82.300 +      LineTag t(*this,_tag);
  82.301 +      (*this)(v);
  82.302 +      return *this;
  82.303 +    }
  82.304 +    XmlIo &operator()(const std::string &_tag,const double &v) 
  82.305 +    {
  82.306 +      LineTag t(*this,_tag);
  82.307 +      (*this)(v);
  82.308 +      return *this;
  82.309 +    }
  82.310 +    XmlIo &operator()(const std::string &_tag,const std::string &v)
  82.311 +    {
  82.312 +      LineTag t(*this,_tag);
  82.313 +      (*this)(v);
  82.314 +      return *this;
  82.315 +    }
  82.316 +    ///\e
  82.317 +  
  82.318 +    ///\e
  82.319 +    ///
  82.320 +    template<class V>
  82.321 +    XmlIo &operator()(const std::string &_tag,const V &v)
  82.322 +    {
  82.323 +      Tag t(*this,_tag);
  82.324 +      xml(*this,const_cast<V &>(v));
  82.325 +      return *this;
  82.326 +    }
  82.327 +    ///\e
  82.328 +  
  82.329 +    ///\e
  82.330 +    ///
  82.331 +    template<class V>
  82.332 +    XmlIo &operator()(const V &v)
  82.333 +    {
  82.334 +      xml(*this,const_cast<V &>(v));
  82.335 +      return *this;
  82.336 +    }
  82.337 +    };
  82.338 +
  82.339 +  //////////////////////////////////////////////////////////////////////
  82.340 +  //////////////////////////////////////////////////////////////////////
  82.341 +
  82.342 +  ///\e
  82.343 +  
  82.344 +  ///\relates XmlIo
  82.345 +  ///
  82.346 +  template<class A>
  82.347 +  void xml(XmlIo &x,std::auto_ptr<A> &v)
  82.348 +  {
  82.349 +    if(x.write()) v=new A;
  82.350 +    x(*v);
  82.351 +  }
  82.352 +  
  82.353 +  ///\e
  82.354 +  
  82.355 +  ///\relates XmlIo
  82.356 +  ///
  82.357 +  template<class A,class B>
  82.358 +  void xml(XmlIo &x,std::pair<A,B> &v)
  82.359 +  {
  82.360 +    x("first",v.first);
  82.361 +    x("second",v.second);
  82.362 +  }
  82.363 +
  82.364 +  ///\e
  82.365 +  
  82.366 +  ///\relates XmlIo
  82.367 +  ///
  82.368 +  template<class T>
  82.369 +  void xml(XmlIo &x,std::list<T> &v)
  82.370 +  {
  82.371 +    if(x.write())
  82.372 +      for(typename std::list<T>::const_iterator it=v.begin();
  82.373 +	  it!=v.end();++it) x("item",*it);
  82.374 +    else while(x.nextTag()=="item")
  82.375 +      {
  82.376 +	v.push_back(T());
  82.377 +	x("item",v.back());
  82.378 +      }
  82.379 +  }
  82.380 +  ///\e
  82.381 +  
  82.382 +  ///\relates XmlIo
  82.383 +  ///
  82.384 +  template<class T>
  82.385 +  void xml(XmlIo &x,std::vector<T> &v)
  82.386 +  {
  82.387 +    if(x.write())
  82.388 +      for(typename std::vector<T>::const_iterator it=v.begin();
  82.389 +	  it!=v.end();++it) x("item",*it);
  82.390 +    else while(x.nextTag()=="item")
  82.391 +      {
  82.392 +	v.push_back(T());
  82.393 +	x("item",v.back());      
  82.394 +      }
  82.395 +  }
  82.396 +
  82.397 +  ///\e
  82.398 +  
  82.399 +  ///\relates XmlIo
  82.400 +  ///
  82.401 +  template<class K,class V>
  82.402 +  void xml(XmlIo &x,std::map<K,V> &v)
  82.403 +  {
  82.404 +    if(x.write()) 
  82.405 +      for(typename std::map<K,V>::const_iterator it=v.begin();
  82.406 +	  it!=v.end();++it) x("item",*it);
  82.407 +    else while(x.nextTag()=="item")
  82.408 +      {
  82.409 +	typename std::map<K,V>::value_type it;
  82.410 +	x("item",it);
  82.411 +	v.insert(it);
  82.412 +      }
  82.413 +  }
  82.414 +
  82.415 +  ///\e
  82.416 +  
  82.417 +  ///\relates XmlIo
  82.418 +  ///
  82.419 +  template<class T>
  82.420 +  void xml(XmlIo &x,lemon::dim2::Point<T> &v)
  82.421 +  {
  82.422 +    { XmlIo::LineTag t(x,"x"); x(v.x); }
  82.423 +    { XmlIo::ContTag t(x,"y"); x(v.y); }
  82.424 +  }
  82.425 +
  82.426 +  ///\e
  82.427 +  
  82.428 +  ///\relates XmlIo
  82.429 +  ///
  82.430 +  template<class T>
  82.431 +  void xml(XmlIo &x,lemon::dim2::BoundingBox<T> &v)
  82.432 +  {
  82.433 +    if(x.write()) {
  82.434 +      if(!v.empty()) {
  82.435 +	x("point",v.bottomLeft());
  82.436 +	if(v.bottomLeft()!=v.topRight()) x("point",v.topRight());
  82.437 +      }
  82.438 +    }
  82.439 +    else {
  82.440 +      v.clear();
  82.441 +      while(x.nextTag()=="point") {
  82.442 +	lemon::dim2::Point<T> co;
  82.443 +	x("point",co);
  82.444 +	v.add(co);
  82.445 +      }
  82.446 +    }
  82.447 +  }
  82.448 +  
  82.449 +}
  82.450 +
  82.451 +#endif
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/xymap.h	Mon Jul 07 08:10:39 2008 -0500
    83.3 @@ -0,0 +1,50 @@
    83.4 +/* -*- C++ -*-
    83.5 + *
    83.6 + * This file is a part of LEMON, a generic C++ optimization library
    83.7 + *
    83.8 + * Copyright (C) 2003-2006
    83.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   83.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   83.11 + *
   83.12 + * Permission to use, modify and distribute this software is granted
   83.13 + * provided that this copyright notice appears in all copies. For
   83.14 + * precise terms see the accompanying LICENSE file.
   83.15 + *
   83.16 + * This software is provided "AS IS" with no warranty of any kind,
   83.17 + * express or implied, and with no claim as to its suitability for any
   83.18 + * purpose.
   83.19 + *
   83.20 + */
   83.21 +
   83.22 +#ifndef XYMAP_H
   83.23 +#define XYMAP_H
   83.24 +
   83.25 +#include <lemon/list_graph.h>
   83.26 +#include <lemon/dim2.h>
   83.27 +
   83.28 +template<class M>
   83.29 +class XYMap
   83.30 +{
   83.31 +  private:
   83.32 +    M *xmap, *ymap;
   83.33 +
   83.34 +  public:
   83.35 +    typedef typename M::Key Key;
   83.36 +    typedef lemon::dim2::Point<typename M::Value> Value;
   83.37 +    XYMap() {}
   83.38 +    XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
   83.39 +    void setXMap(M &_xmap) { xmap = &_xmap; }
   83.40 +    void setYMap(M &_ymap) { ymap = &_ymap; }
   83.41 +    Value operator[](Key k) const
   83.42 +    {
   83.43 +      Value v(xmap->operator[](k), ymap->operator[](k));
   83.44 +      return v;
   83.45 +    }
   83.46 +    void set(Key k, Value v)
   83.47 +    {
   83.48 +      xmap->set(k, v.x);
   83.49 +      ymap->set(k, v.y);
   83.50 +    }
   83.51 +};
   83.52 +
   83.53 +#endif