hegyi@1: /* -*- C++ -*- hegyi@1: * hegyi@1: * This file is a part of LEMON, a generic C++ optimization library hegyi@1: * hegyi@1: * Copyright (C) 2003-2006 hegyi@1: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport hegyi@1: * (Egervary Research Group on Combinatorial Optimization, EGRES). hegyi@1: * hegyi@1: * Permission to use, modify and distribute this software is granted hegyi@1: * provided that this copyright notice appears in all copies. For hegyi@1: * precise terms see the accompanying LICENSE file. hegyi@1: * hegyi@1: * This software is provided "AS IS" with no warranty of any kind, hegyi@1: * express or implied, and with no claim as to its suitability for any hegyi@1: * purpose. hegyi@1: * hegyi@1: */ hegyi@1: hegyi@1: #ifndef MAIN_WIN_H hegyi@1: #define MAIN_WIN_H hegyi@1: hegyi@1: #include "all_include.h" hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: class AlgoWin; hegyi@1: class NoteBookTab; hegyi@1: hegyi@1: ///This class is the main window of GUI. hegyi@1: hegyi@1: ///It has menus, and a notebook. Notebook has different pages, hegyi@1: ///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which digraphs can be drawn. hegyi@1: ///To manage creation and close of tabs and tabswitching is the task of MainWin. hegyi@1: class MainWin : public Gtk::Window hegyi@1: { hegyi@1: ///Container in which the menus and the notebook is. hegyi@1: //Gtk::VBox vbox; hegyi@1: Gtk::Table table; hegyi@1: Gtk::Table table2; hegyi@1: hegyi@1: ///Container in which the toolbar and the node parametrizer is. hegyi@1: Gtk::HBox hbox; hegyi@1: hegyi@1: ///Should nodes be autoscaled or not? hegyi@1: Gtk::CheckButton * auto_scale; hegyi@1: hegyi@1: ///Should node size track zoom factor? hegyi@1: Gtk::CheckButton * zoom_track; hegyi@1: hegyi@1: ///Minimum and maximum node radius entry hegyi@1: Gtk::SpinButton * radius_size, * arc_width; hegyi@1: hegyi@1: ///The notebook that has tabs (\ref NoteBookTab) with different digraphs. hegyi@1: Gtk::Notebook notebook; hegyi@1: hegyi@1: ///The tool selected to manipulate digraph. hegyi@1: hegyi@1: ///It has to be stored, because in case of tabswitching hegyi@1: ///the correct tool has to be set for the actual digraph. hegyi@1: int active_tool; hegyi@1: hegyi@1: ///The number of active tab in the notebook. hegyi@1: int active_tab; hegyi@1: hegyi@1: ///Vector of existing tabs in the notebook. hegyi@1: std::vector tabs; hegyi@1: hegyi@1: ///Vector of the name of tabs. hegyi@1: hegyi@1: ///All \ref NoteBookTab has a name that is stored here. The index of the name hegyi@1: ///is the same as the index of the \ref NoteBookTab in \ref tabs. hegyi@1: std::vector tabnames; hegyi@1: hegyi@1: ///Counter of occurence of the same file names. hegyi@1: hegyi@1: ///If a file is opened more than once we have to score hegyi@1: ///the occurences to let the titles on tabs different. hegyi@1: ///If more than one occurence is present, from the second hegyi@1: ///one near the filename the number of the occurence appear. hegyi@1: std::map strinst; hegyi@1: hegyi@1: ///Set of opened \ref AlgoWin s. hegyi@1: hegyi@1: ///More than one \refAlgoWin can be opened. We have to hegyi@1: ///communicate with them in case of new \ref NoteBookTab creation, hegyi@1: ///\ref NoteBookTab close, or map change. Therefore we have to score hegyi@1: ///their occurences. hegyi@1: std::set< AlgoWin* > aws; hegyi@1: hegyi@1: public: hegyi@1: hegyi@1: ///Constructor of the \ref MainWin. hegyi@1: hegyi@1: ///It creates the menus, the toolbar and the notebook in which hegyi@1: ///\ref NoteBookTab s take place. \ref NoteBookTab s are the hegyi@1: ///holder of the canvases on which the digraphs are drawn. hegyi@1: MainWin(); hegyi@1: hegyi@1: ~MainWin(); hegyi@1: ///Sets title of tabs. hegyi@1: hegyi@1: ///It alse registrates it in \ref tabnames. If more than one hegyi@1: ///occurence is in the notebook of the same file it has to hegyi@1: ///extend tabname with the number of occurence. hegyi@1: void set_tabtitle(std::string); hegyi@1: hegyi@1: ///ActionGroup for menu hegyi@1: Glib::RefPtr ag; hegyi@1: hegyi@1: ///UIManager for menu hegyi@1: Glib::RefPtr uim; hegyi@1: hegyi@1: ///Creates a new \ref NoteBookTab and opens the given file. hegyi@1: hegyi@1: ///It is called only with command line parameters at stratup. hegyi@1: void readFile(const std::string &); hegyi@1: hegyi@1: ///Tooltips hegyi@1: Gtk::Tooltips * tooltips; hegyi@1: hegyi@1: //Call-backs of buttons hegyi@1: hegyi@1: ///Callback for 'FileNew' action. hegyi@1: virtual void newFile(); hegyi@1: ///Callback for 'FileOpen' action. hegyi@1: virtual void openFile(); hegyi@1: ///Callback for 'FileSave' action. hegyi@1: virtual void saveFile(); hegyi@1: ///Callback for 'FileSaveAs' action. hegyi@1: virtual void saveFileAs(); hegyi@1: ///Callback for 'Close' action. hegyi@1: virtual void close(); hegyi@1: hegyi@1: //Toolbar hegyi@1: hegyi@1: ///Callback for 'zoomIn' action. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref DigraphDisplayerCanvas hegyi@1: virtual void zoomIn(); hegyi@1: ///Callback for 'zoomOut' action. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref DigraphDisplayerCanvas hegyi@1: virtual void zoomOut(); hegyi@1: ///Callback for 'zoomFit' action. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref DigraphDisplayerCanvas hegyi@1: virtual void zoomFit(); hegyi@1: ///Callback for 'zoom100' action. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref DigraphDisplayerCanvas hegyi@1: virtual void zoom100(); hegyi@1: hegyi@1: ///Callback for Show Maps menupoint. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref NoteBookTab hegyi@1: virtual void createMapWin(); hegyi@1: hegyi@1: ///Callback for Show Design menupoint. hegyi@1: hegyi@1: ///It calls the appropriate function in hegyi@1: ///\ref NoteBookTab hegyi@1: virtual void createDesignWin(); hegyi@1: hegyi@1: ///Pops up an Algorithm window. hegyi@1: hegyi@1: ///It not only creates but registrates the newly created \ref AlgoWin. hegyi@1: ///It is necessary, because in case of changement between tabs or maps hegyi@1: ///we have to communicate with it. Signals are also have to be connected hegyi@1: ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration). hegyi@1: ///\param algo type of the algorithm to run. hegyi@1: virtual void createAlgoWin(int algo); hegyi@1: hegyi@1: ///Deregisters AlgoWin hegyi@1: hegyi@1: ///This is the function connected to the closing signal of \ref AlgoWin. hegyi@1: ///It only deletes the sender \ref AlgoWin from \ref aws. This function hegyi@1: ///is called only by the closing \ref AlgoWin itself. hegyi@1: ///\param aw the \ref AlgoWin to delete. hegyi@1: virtual void deRegisterAlgoWin(AlgoWin * aw); hegyi@1: hegyi@1: ///Updates list of tabs in all of the \ref AlgoWin hegyi@1: hegyi@1: ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin hegyi@1: ///have to be updated. That is why we score all the opened \ref AlgoWin. hegyi@1: ///During update \ref tabnames will be passed to each \ref AlgoWin. hegyi@1: virtual void updateAlgoWinTabs(); hegyi@1: hegyi@1: ///Refresh list of maps in the AlgoWin that requested it. hegyi@1: hegyi@1: ///In an \ref AlgoWin there is a ComboBoxText, in which hegyi@1: ///a \ref NoteBookTab can be chosen that contains the digraph and the maps, hegyi@1: ///on which we would like to run algorithms. If we change the hegyi@1: ///tab the available maps also have to be updated, because hegyi@1: ///in the different tabs different maps are available. Therefore hegyi@1: ///on tab change the \ref AlgoWin emits a signal that contains itself hegyi@1: ///so that the appropriate maps can be sent to it. For the sake of simplicity hegyi@1: ///the program answers this call with the mapstorage of the newly selected tab. hegyi@1: ///\param aw the caller \ref AlgoWin hegyi@1: ///\param tabname the newly selected tab in the \ref AlgoWin hegyi@1: virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname); hegyi@1: hegyi@1: ///Registrates the new digraph-editor tool in hand. hegyi@1: hegyi@1: ///The editor-tool in hand is global, it is the same for all tab hegyi@1: ///at the same time. Therefore the active tool has to be scored here (\ref active_tool). hegyi@1: ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool hegyi@1: ///to the correct value. hegyi@1: ///\param tool the newly selected digraph-editor tool (See all_include.h) hegyi@1: virtual void changeEditorialTool(int tool); hegyi@1: hegyi@1: ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin hegyi@1: hegyi@1: ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created. hegyi@1: ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal. hegyi@1: ///It sends the caller \ref NoteBookTab and whether an arcmap or a nodemap should be created. hegyi@1: ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its hegyi@1: ///correct place. hegyi@1: ///\param nbt the caller tab hegyi@1: ///\param itisarc true if arcmap has to be created, false if nodemap hegyi@1: virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisarc); hegyi@1: hegyi@1: ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin hegyi@1: hegyi@1: ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up. hegyi@1: ///It emits a signal in this case. This function is bound to that signal. hegyi@1: ///The signal contains the name of \ref NoteBookTab in which the new map has to be hegyi@1: ///placed and whether the new map is an arcmap or a nodemap. hegyi@1: ///\ref tabname the tab in which the new map has to be placed hegyi@1: ///\ref itisarc true if the new map will be arc map, false if it will be nodemap hegyi@1: virtual void createNewMapWinTabString(std::string tabname, bool itisarc); hegyi@1: hegyi@1: ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed. hegyi@1: hegyi@1: ///In this case a general \ref NewMapWin will be popped up. This means that hegyi@1: ///both arc and nodemap can be created by it. The new map will be placed in hegyi@1: ///\MapStorage of the actual selected \ref NoteBookTab. hegyi@1: virtual void createNewMapWin(); hegyi@1: hegyi@1: //Notebook handlers hegyi@1: ///Callback for 'FileNewTab' action. hegyi@1: virtual void newTab(); hegyi@1: hegyi@1: ///Callback for 'FileCloseTab' action. hegyi@1: hegyi@1: ///It closes the actual \ref NoteBookTab and registrates this event: hegyi@1: ///data is shifted to the correct places in vectors. hegyi@1: virtual void closeTab(); hegyi@1: hegyi@1: ///Tabswitching handler hegyi@1: hegyi@1: ///Sets the variables that have to store the actual state, and it hegyi@1: ///updates the title of window to the actually selected \ref NoteBookTab. hegyi@1: virtual void onChangeTab(GtkNotebookPage*, guint); hegyi@1: hegyi@1: virtual void nodeViewChanged(); hegyi@1: hegyi@1: virtual void reDesignDigraph(); hegyi@1: hegyi@1: /// Pops up a SaveDetailsDialog. hegyi@1: void createSaveDetailsDialog(); hegyi@1: hegyi@1: virtual void exportToEPS(); hegyi@1: hegyi@1: void createBackgroundChooser(); hegyi@1: }; hegyi@1: hegyi@1: #endif //MAIN_WIN_H