main_win.h
author hegyi
Fri, 13 Oct 2006 13:53:44 +0000
changeset 163 443bc769b344
parent 157 7e6ad28aeb9e
child 174 95872af46fc4
permissions -rw-r--r--
Dijkstra in GUI - and the body...
     1 // -*- C++ -*- //
     2 
     3 #ifndef MAIN_WIN_H
     4 #define MAIN_WIN_H
     5 
     6 #include "all_include.h"
     7 #include "algowin.h"
     8 #include "map_win.h"
     9 #include "new_map_win.h"
    10 #include "nbtab.h"
    11 #include <libgnomecanvasmm.h>
    12 #include <libgnomecanvasmm/polygon.h>
    13 
    14 
    15 ///This class is the main window of GUI.
    16 
    17 ///It has menus, and a notebook. Notebook has different pages,
    18 ///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which graphs can be drawn.
    19 ///To manage creation and close of tabs and tabswitching is the task of MainWin.
    20 class MainWin : public Gtk::Window
    21 {
    22   ///Container in which the menus and the notebook is.
    23   //Gtk::VBox vbox;
    24   Gtk::Table table;
    25   Gtk::Table table2;
    26 
    27   ///Container in which the toolbar and the node parametrizer is.
    28   Gtk::HBox hbox;
    29 
    30   ///Should nodes be autoscaled or not?
    31   Gtk::CheckButton * auto_scale;
    32 
    33   ///Should node size track zoom factor?
    34   Gtk::CheckButton * zoom_track;
    35 
    36   ///Minimum and maximum node radius entry
    37   Gtk::SpinButton * radius_size, * edge_width;
    38 
    39   ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
    40   Gtk::Notebook notebook;
    41 
    42   ///The tool selected to manipulate graph.
    43 
    44   ///It has to be stored, because in case of tabswitching
    45   ///the correct tool has to be set for the actual graph.
    46   int active_tool;
    47 
    48   ///The number of active tab in the notebook.
    49   int active_tab;
    50 
    51   ///Vector of existing tabs in the notebook.
    52   std::vector<NoteBookTab *> tabs;
    53 
    54   ///Vector of the name of tabs.
    55 
    56   ///All \ref NoteBookTab has a name that is stored here. The index of the name
    57   ///is the same as the index of the \ref NoteBookTab in \ref tabs.
    58   std::vector<std::string> tabnames;
    59 
    60   ///Counter of occurence of the same file names.
    61 
    62   ///If a file is opened more than once we have to score
    63   ///the occurences to let the titles on tabs different.
    64   ///If more than one occurence is present, from the second
    65   ///one near the filename the number of the occurence appear.
    66   std::map<std::string, int> strinst;
    67 
    68   ///Set of opened \ref AlgoWin s.
    69 
    70   ///More than one \refAlgoWin can be opened. We have to
    71   ///communicate with them in case of new \ref NoteBookTab creation,
    72   ///\ref NoteBookTab close, or map change. Therefore we have to score
    73   ///their occurences.
    74   std::set< AlgoWin* > aws;
    75 
    76 public:
    77   
    78   ///Constructor of the \ref MainWin.
    79 
    80   ///It creates the menus, the toolbar and the notebook in which
    81   ///\ref NoteBookTab s take place. \ref NoteBookTab s are the
    82   ///holder of the canvases on which the graphs are drawn.
    83   MainWin();
    84 
    85   ///Sets title of tabs.
    86 
    87   ///It alse registrates it in \ref tabnames. If more than one
    88   ///occurence is in the notebook of the same file it has to
    89   ///extend tabname with the number of occurence.
    90   void set_tabtitle(std::string);
    91 
    92   ///ActionGroup for menu
    93   Glib::RefPtr<Gtk::ActionGroup> ag;
    94 
    95   ///UIManager for menu
    96   Glib::RefPtr<Gtk::UIManager> uim;
    97 
    98   ///Creates a new \ref NoteBookTab and opens the given file.
    99 
   100   ///It is called only with command line parameters at stratup.
   101   void readFile(const std::string &);
   102 
   103   ///Tooltips
   104   Gtk::Tooltips tooltips;
   105 
   106   //Call-backs of buttons
   107 
   108   ///Callback for 'FileNew' action.
   109   virtual void newFile();
   110   ///Callback for 'FileOpen' action.
   111   virtual void openFile();
   112   ///Callback for 'FileSave' action.
   113   virtual void saveFile();
   114   ///Callback for 'FileSaveAs' action.
   115   virtual void saveFileAs();
   116   ///Callback for 'Close' action.
   117   virtual void close();
   118 
   119   //Toolbar
   120 
   121   ///Callback for 'zoomIn' action.
   122 
   123   ///It calls the appropriate function in
   124   ///\ref GraphDisplayerCanvas
   125   virtual void zoomIn();
   126   ///Callback for 'zoomOut' action.
   127 
   128   ///It calls the appropriate function in
   129   ///\ref GraphDisplayerCanvas
   130   virtual void zoomOut();
   131   ///Callback for 'zoomFit' action.
   132 
   133   ///It calls the appropriate function in
   134   ///\ref GraphDisplayerCanvas
   135   virtual void zoomFit();
   136   ///Callback for 'zoom100' action.
   137 
   138   ///It calls the appropriate function in
   139   ///\ref GraphDisplayerCanvas
   140   virtual void zoom100();
   141 
   142   ///Callback for Show Maps menupoint.
   143 
   144   ///It calls the appropriate function in
   145   ///\ref NoteBookTab
   146   virtual void createMapWin();
   147 
   148   ///Callback for Show Design menupoint.
   149 
   150   ///It calls the appropriate function in
   151   ///\ref NoteBookTab
   152   virtual void createDesignWin();
   153 
   154   ///Pops up an Algorithm window.
   155 
   156   ///It not only creates but registrates the newly created \ref AlgoWin.
   157   ///It is necessary, because in case of changement between tabs or maps
   158   ///we have to communicate with it. Signals are also have to be connected
   159   ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration).
   160   ///\param algo type of the algorithm to run.
   161   virtual void createAlgoWin(int algo);
   162 
   163   ///Deregisters AlgoWin
   164 
   165   ///This is the function connected to the closing signal of \ref AlgoWin.
   166   ///It only deletes the sender \ref AlgoWin from \ref aws. This function
   167   ///is called only by the closing \ref AlgoWin itself.
   168   ///\param aw the \ref AlgoWin to delete.
   169   virtual void deRegisterAlgoWin(AlgoWin * aw);
   170 
   171   ///Updates list of tabs in all of the \ref AlgoWin
   172 
   173   ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin
   174   ///have to be updated. That is why we score all the opened \ref AlgoWin.
   175   ///During update \ref tabnames will be passed to each \ref AlgoWin.
   176   virtual void updateAlgoWinTabs();
   177 
   178   ///Refresh list of maps in the AlgoWin that requested it.
   179 
   180   ///In an \ref AlgoWin there is a ComboBoxText, in which
   181   ///a \ref NoteBookTab can be chosen that contains the graph and the maps,
   182   ///on which we would like to run algorithms. If we change the
   183   ///tab the available maps also have to be updated, because
   184   ///in the different tabs different maps are available. Therefore
   185   ///on tab change the \ref AlgoWin emits a signal that contains itself
   186   ///so that the appropriate maps can be sent to it. For the sake of simplicity
   187   ///the program answers this call with the mapstorage of the newly selected tab.
   188   ///\param aw the caller \ref AlgoWin
   189   ///\param tabname the newly selected tab in the \ref AlgoWin
   190   virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname);
   191 
   192   ///Registrates the new graph-editor tool in hand.
   193 
   194   ///The editor-tool in hand is global, it is the same for all tab
   195   ///at the same time. Therefore the active tool has to be scored here (\ref active_tool).
   196   ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool
   197   ///to the correct value.
   198   ///\param tool the newly selected graph-editor tool (See all_include.h)
   199   virtual void changeEditorialTool(int tool);
   200 
   201   ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin
   202 
   203   ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created.
   204   ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal.
   205   ///It sends the caller \ref NoteBookTab and whether an edgemap or a nodemap should be created.
   206   ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its
   207   ///correct place.
   208   ///\param nbt the caller tab
   209   ///\param itisedge true if edgemap has to be created, false if nodemap
   210   virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge);
   211 
   212   ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin
   213 
   214   ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up. 
   215   ///It emits a signal in this case. This function is bound to that signal.
   216   ///The signal contains the name of \ref NoteBookTab in which the new map has to be
   217   ///placed and whether the new map is an edgemap or a nodemap.
   218   ///\ref tabname the tab in which the new map has to be placed
   219   ///\ref itisedge true if the new map will be edge map, false if it will be nodemap
   220   virtual void createNewMapWinTabString(std::string tabname, bool itisedge);
   221 
   222   ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed.
   223 
   224   ///In this case a general \ref NewMapWin will be popped up. This means that
   225   ///both edge and nodemap can be created by it. The new map will be placed in
   226   ///\MapStorage of the actual selected \ref NoteBookTab.
   227   virtual void createNewMapWin();
   228 
   229   //Notebook handlers
   230   ///Callback for 'FileNewTab' action.
   231   virtual void newTab();
   232 
   233   ///Callback for 'FileCloseTab' action.
   234 
   235   ///It closes the actual \ref NoteBookTab and registrates this event:
   236   ///data is shifted to the correct places in vectors.
   237   virtual void closeTab();
   238 
   239   ///Tabswitching handler
   240 
   241   ///Sets the variables that have to store the actual state, and it
   242   ///updates the title of window to the actually selected \ref NoteBookTab.
   243   virtual void onChangeTab(GtkNotebookPage*, guint);
   244 
   245   virtual void nodeViewChanged();
   246 
   247   virtual void reDesignGraph();
   248 };
   249 
   250 #endif //MAIN_WIN_H