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