1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/main_win.h Mon Jul 07 08:10:39 2008 -0500
1.3 @@ -0,0 +1,273 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2006
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#ifndef MAIN_WIN_H
1.23 +#define MAIN_WIN_H
1.24 +
1.25 +#include "all_include.h"
1.26 +#include <libgnomecanvasmm.h>
1.27 +#include <libgnomecanvasmm/polygon.h>
1.28 +#include <set>
1.29 +
1.30 +class AlgoWin;
1.31 +class NoteBookTab;
1.32 +
1.33 +///This class is the main window of GUI.
1.34 +
1.35 +///It has menus, and a notebook. Notebook has different pages,
1.36 +///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which digraphs can be drawn.
1.37 +///To manage creation and close of tabs and tabswitching is the task of MainWin.
1.38 +class MainWin : public Gtk::Window
1.39 +{
1.40 + ///Container in which the menus and the notebook is.
1.41 + //Gtk::VBox vbox;
1.42 + Gtk::Table table;
1.43 + Gtk::Table table2;
1.44 +
1.45 + ///Container in which the toolbar and the node parametrizer is.
1.46 + Gtk::HBox hbox;
1.47 +
1.48 + ///Should nodes be autoscaled or not?
1.49 + Gtk::CheckButton * auto_scale;
1.50 +
1.51 + ///Should node size track zoom factor?
1.52 + Gtk::CheckButton * zoom_track;
1.53 +
1.54 + ///Minimum and maximum node radius entry
1.55 + Gtk::SpinButton * radius_size, * arc_width;
1.56 +
1.57 + ///The notebook that has tabs (\ref NoteBookTab) with different digraphs.
1.58 + Gtk::Notebook notebook;
1.59 +
1.60 + ///The tool selected to manipulate digraph.
1.61 +
1.62 + ///It has to be stored, because in case of tabswitching
1.63 + ///the correct tool has to be set for the actual digraph.
1.64 + int active_tool;
1.65 +
1.66 + ///The number of active tab in the notebook.
1.67 + int active_tab;
1.68 +
1.69 + ///Vector of existing tabs in the notebook.
1.70 + std::vector<NoteBookTab *> tabs;
1.71 +
1.72 + ///Vector of the name of tabs.
1.73 +
1.74 + ///All \ref NoteBookTab has a name that is stored here. The index of the name
1.75 + ///is the same as the index of the \ref NoteBookTab in \ref tabs.
1.76 + std::vector<std::string> tabnames;
1.77 +
1.78 + ///Counter of occurence of the same file names.
1.79 +
1.80 + ///If a file is opened more than once we have to score
1.81 + ///the occurences to let the titles on tabs different.
1.82 + ///If more than one occurence is present, from the second
1.83 + ///one near the filename the number of the occurence appear.
1.84 + std::map<std::string, int> strinst;
1.85 +
1.86 + ///Set of opened \ref AlgoWin s.
1.87 +
1.88 + ///More than one \refAlgoWin can be opened. We have to
1.89 + ///communicate with them in case of new \ref NoteBookTab creation,
1.90 + ///\ref NoteBookTab close, or map change. Therefore we have to score
1.91 + ///their occurences.
1.92 + std::set< AlgoWin* > aws;
1.93 +
1.94 +public:
1.95 +
1.96 + ///Constructor of the \ref MainWin.
1.97 +
1.98 + ///It creates the menus, the toolbar and the notebook in which
1.99 + ///\ref NoteBookTab s take place. \ref NoteBookTab s are the
1.100 + ///holder of the canvases on which the digraphs are drawn.
1.101 + MainWin();
1.102 +
1.103 + ~MainWin();
1.104 + ///Sets title of tabs.
1.105 +
1.106 + ///It alse registrates it in \ref tabnames. If more than one
1.107 + ///occurence is in the notebook of the same file it has to
1.108 + ///extend tabname with the number of occurence.
1.109 + void set_tabtitle(std::string);
1.110 +
1.111 + ///ActionGroup for menu
1.112 + Glib::RefPtr<Gtk::ActionGroup> ag;
1.113 +
1.114 + ///UIManager for menu
1.115 + Glib::RefPtr<Gtk::UIManager> uim;
1.116 +
1.117 + ///Creates a new \ref NoteBookTab and opens the given file.
1.118 +
1.119 + ///It is called only with command line parameters at stratup.
1.120 + void readFile(const std::string &);
1.121 +
1.122 + ///Tooltips
1.123 + Gtk::Tooltips * tooltips;
1.124 +
1.125 + //Call-backs of buttons
1.126 +
1.127 + ///Callback for 'FileNew' action.
1.128 + virtual void newFile();
1.129 + ///Callback for 'FileOpen' action.
1.130 + virtual void openFile();
1.131 + ///Callback for 'FileSave' action.
1.132 + virtual void saveFile();
1.133 + ///Callback for 'FileSaveAs' action.
1.134 + virtual void saveFileAs();
1.135 + ///Callback for 'Close' action.
1.136 + virtual void close();
1.137 +
1.138 + //Toolbar
1.139 +
1.140 + ///Callback for 'zoomIn' action.
1.141 +
1.142 + ///It calls the appropriate function in
1.143 + ///\ref DigraphDisplayerCanvas
1.144 + virtual void zoomIn();
1.145 + ///Callback for 'zoomOut' action.
1.146 +
1.147 + ///It calls the appropriate function in
1.148 + ///\ref DigraphDisplayerCanvas
1.149 + virtual void zoomOut();
1.150 + ///Callback for 'zoomFit' action.
1.151 +
1.152 + ///It calls the appropriate function in
1.153 + ///\ref DigraphDisplayerCanvas
1.154 + virtual void zoomFit();
1.155 + ///Callback for 'zoom100' action.
1.156 +
1.157 + ///It calls the appropriate function in
1.158 + ///\ref DigraphDisplayerCanvas
1.159 + virtual void zoom100();
1.160 +
1.161 + ///Callback for Show Maps menupoint.
1.162 +
1.163 + ///It calls the appropriate function in
1.164 + ///\ref NoteBookTab
1.165 + virtual void createMapWin();
1.166 +
1.167 + ///Callback for Show Design menupoint.
1.168 +
1.169 + ///It calls the appropriate function in
1.170 + ///\ref NoteBookTab
1.171 + virtual void createDesignWin();
1.172 +
1.173 + ///Pops up an Algorithm window.
1.174 +
1.175 + ///It not only creates but registrates the newly created \ref AlgoWin.
1.176 + ///It is necessary, because in case of changement between tabs or maps
1.177 + ///we have to communicate with it. Signals are also have to be connected
1.178 + ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration).
1.179 + ///\param algo type of the algorithm to run.
1.180 + virtual void createAlgoWin(int algo);
1.181 +
1.182 + ///Deregisters AlgoWin
1.183 +
1.184 + ///This is the function connected to the closing signal of \ref AlgoWin.
1.185 + ///It only deletes the sender \ref AlgoWin from \ref aws. This function
1.186 + ///is called only by the closing \ref AlgoWin itself.
1.187 + ///\param aw the \ref AlgoWin to delete.
1.188 + virtual void deRegisterAlgoWin(AlgoWin * aw);
1.189 +
1.190 + ///Updates list of tabs in all of the \ref AlgoWin
1.191 +
1.192 + ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin
1.193 + ///have to be updated. That is why we score all the opened \ref AlgoWin.
1.194 + ///During update \ref tabnames will be passed to each \ref AlgoWin.
1.195 + virtual void updateAlgoWinTabs();
1.196 +
1.197 + ///Refresh list of maps in the AlgoWin that requested it.
1.198 +
1.199 + ///In an \ref AlgoWin there is a ComboBoxText, in which
1.200 + ///a \ref NoteBookTab can be chosen that contains the digraph and the maps,
1.201 + ///on which we would like to run algorithms. If we change the
1.202 + ///tab the available maps also have to be updated, because
1.203 + ///in the different tabs different maps are available. Therefore
1.204 + ///on tab change the \ref AlgoWin emits a signal that contains itself
1.205 + ///so that the appropriate maps can be sent to it. For the sake of simplicity
1.206 + ///the program answers this call with the mapstorage of the newly selected tab.
1.207 + ///\param aw the caller \ref AlgoWin
1.208 + ///\param tabname the newly selected tab in the \ref AlgoWin
1.209 + virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname);
1.210 +
1.211 + ///Registrates the new digraph-editor tool in hand.
1.212 +
1.213 + ///The editor-tool in hand is global, it is the same for all tab
1.214 + ///at the same time. Therefore the active tool has to be scored here (\ref active_tool).
1.215 + ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool
1.216 + ///to the correct value.
1.217 + ///\param tool the newly selected digraph-editor tool (See all_include.h)
1.218 + virtual void changeEditorialTool(int tool);
1.219 +
1.220 + ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin
1.221 +
1.222 + ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created.
1.223 + ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal.
1.224 + ///It sends the caller \ref NoteBookTab and whether an arcmap or a nodemap should be created.
1.225 + ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its
1.226 + ///correct place.
1.227 + ///\param nbt the caller tab
1.228 + ///\param itisarc true if arcmap has to be created, false if nodemap
1.229 + virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisarc);
1.230 +
1.231 + ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin
1.232 +
1.233 + ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up.
1.234 + ///It emits a signal in this case. This function is bound to that signal.
1.235 + ///The signal contains the name of \ref NoteBookTab in which the new map has to be
1.236 + ///placed and whether the new map is an arcmap or a nodemap.
1.237 + ///\ref tabname the tab in which the new map has to be placed
1.238 + ///\ref itisarc true if the new map will be arc map, false if it will be nodemap
1.239 + virtual void createNewMapWinTabString(std::string tabname, bool itisarc);
1.240 +
1.241 + ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed.
1.242 +
1.243 + ///In this case a general \ref NewMapWin will be popped up. This means that
1.244 + ///both arc and nodemap can be created by it. The new map will be placed in
1.245 + ///\MapStorage of the actual selected \ref NoteBookTab.
1.246 + virtual void createNewMapWin();
1.247 +
1.248 + //Notebook handlers
1.249 + ///Callback for 'FileNewTab' action.
1.250 + virtual void newTab();
1.251 +
1.252 + ///Callback for 'FileCloseTab' action.
1.253 +
1.254 + ///It closes the actual \ref NoteBookTab and registrates this event:
1.255 + ///data is shifted to the correct places in vectors.
1.256 + virtual void closeTab();
1.257 +
1.258 + ///Tabswitching handler
1.259 +
1.260 + ///Sets the variables that have to store the actual state, and it
1.261 + ///updates the title of window to the actually selected \ref NoteBookTab.
1.262 + virtual void onChangeTab(GtkNotebookPage*, guint);
1.263 +
1.264 + virtual void nodeViewChanged();
1.265 +
1.266 + virtual void reDesignDigraph();
1.267 +
1.268 + /// Pops up a SaveDetailsDialog.
1.269 + void createSaveDetailsDialog();
1.270 +
1.271 + virtual void exportToEPS();
1.272 +
1.273 + void createBackgroundChooser();
1.274 +};
1.275 +
1.276 +#endif //MAIN_WIN_H