algowin.h
author Peter Hegyi <hegyi@tmit.bme.hu>
Wed, 13 Aug 2008 17:24:25 +0100
changeset 6 3a44a2bb6da8
permissions -rw-r--r--
Remove lemon/graph_utils.h include.
hegyi@1
     1
/* -*- C++ -*-
hegyi@1
     2
 *
hegyi@1
     3
 * This file is a part of LEMON, a generic C++ optimization library
hegyi@1
     4
 *
hegyi@1
     5
 * Copyright (C) 2003-2006
hegyi@1
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
hegyi@1
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
hegyi@1
     8
 *
hegyi@1
     9
 * Permission to use, modify and distribute this software is granted
hegyi@1
    10
 * provided that this copyright notice appears in all copies. For
hegyi@1
    11
 * precise terms see the accompanying LICENSE file.
hegyi@1
    12
 *
hegyi@1
    13
 * This software is provided "AS IS" with no warranty of any kind,
hegyi@1
    14
 * express or implied, and with no claim as to its suitability for any
hegyi@1
    15
 * purpose.
hegyi@1
    16
 *
hegyi@1
    17
 */
hegyi@1
    18
hegyi@1
    19
#ifndef ALGOWIN_H
hegyi@1
    20
#define ALGOWIN_H
hegyi@1
    21
hegyi@1
    22
#include <all_include.h>
hegyi@1
    23
#include <libgnomecanvasmm.h>
hegyi@1
    24
#include <libgnomecanvasmm/polygon.h>
hegyi@1
    25
hegyi@1
    26
class AlgoBox;
hegyi@1
    27
class MapStorage;
hegyi@1
    28
hegyi@1
    29
///Algorithm identifiers.
hegyi@1
    30
enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
hegyi@1
    31
hegyi@1
    32
///Window displaying digraphical interface for different algorithms.
hegyi@1
    33
hegyi@1
    34
///This class displays a digraphical interface to set up
hegyi@1
    35
///and run different algorithms. Different algorithms need
hegyi@1
    36
///different inputs, running methods, etc. Therefore
hegyi@1
    37
///class \ref AlgoWin is only a holder of a base class, the so
hegyi@1
    38
///called AlgoBox. \ref AlgoBox is the ancestor of other
hegyi@1
    39
///classes. These child classes realize interfaces of different
hegyi@1
    40
///algorithms, but as their common ancestor is \ref AlgoBox
hegyi@1
    41
///the interface of them is the same. \ref AlgoWin communicates
hegyi@1
    42
///with these classes through this common interface. But it the
hegyi@1
    43
///real object to be placed in \ref AlgoWin depends on the algorithm
hegyi@1
    44
///which the \ref AlgoWin actually has to display. It gets the
hegyi@1
    45
///id of algorithm to display at initialization, and therefore it is
hegyi@1
    46
///able to place in itself the requested child of \ref AlgoBox
hegyi@1
    47
/// visualizing the appropriate algorithm.
hegyi@1
    48
class AlgoWin : public Gtk::Window
hegyi@1
    49
{
hegyi@1
    50
private:
hegyi@1
    51
  ///Algorithm specific part of \ref AlgoWin
hegyi@1
    52
  AlgoBox * ab;
hegyi@1
    53
hegyi@1
    54
  ///Run button.
hegyi@1
    55
hegyi@1
    56
  ///If pressed, algorithm should run.
hegyi@1
    57
  ///That is why common ancestor of different
hegyi@1
    58
  ///algorithm realizer classes have to be. In case of
hegyi@1
    59
  ///pressing run button a common method can be called.
hegyi@1
    60
  Gtk::Button * runbutton;
hegyi@1
    61
hegyi@1
    62
  ///Close button. If pressed, \ref AlgoWin should close.
hegyi@1
    63
  Gtk::Button * closebutton;
hegyi@1
    64
hegyi@1
    65
protected:
hegyi@1
    66
  ///Signal emitted upon close of window
hegyi@1
    67
hegyi@1
    68
  ///It is necessary, because \ref MainWin have to
hegyi@1
    69
  ///score the opened \ref AlgoWin s, to be able to communicate
hegyi@1
    70
  ///with them: let them know about changement in tabs, maps, etc.
hegyi@1
    71
  ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it.
hegyi@1
    72
  ///Therefore signal contains address of emitter \ref AlgoWin.
hegyi@1
    73
  sigc::signal<void, AlgoWin *> signal_closed;
hegyi@1
    74
hegyi@1
    75
  ///Signal indicating that informatino on certain maplist is required.
hegyi@1
    76
hegyi@1
    77
  ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor
hegyi@1
    78
  ///algorithm class. User can select the digraph (the holder \ref NoteBookTab) on
hegyi@1
    79
  ///which the algorithm should run. But different digraphs (\ref NoteBookTab) have
hegyi@1
    80
  ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox,
hegyi@1
    81
  ///caught and reemitted by \ref AlgoWin.
hegyi@1
    82
  ///
hegyi@1
    83
  ///Signal contains the address of \ref AlgoWin to let \ref MainWin know
hegyi@1
    84
  ///where should the information needed forwarded, and the name of
hegyi@1
    85
  ///\ref NoteBookTab, of which maps are inquired.
hegyi@1
    86
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
hegyi@1
    87
hegyi@1
    88
  ///Signal that indicates that a \ref NewMapWin should be popped up.
hegyi@1
    89
hegyi@1
    90
  ///This is a forwarded signal. If \ref AlgoBox emits a signal
hegyi@1
    91
  ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it.
hegyi@1
    92
  ///
hegyi@1
    93
  ///Signal contains the name of \ref NoteBookTab, in which the new map
hegyi@1
    94
  ///should be created and a boolean that indicates whether an arc or a
hegyi@1
    95
  ///nodemap should be created.
hegyi@1
    96
  sigc::signal<void, std::string, bool> signal_newmapwin_need;
hegyi@1
    97
hegyi@1
    98
public:
hegyi@1
    99
  ///Close window if escape key is pressed.
hegyi@1
   100
  bool closeIfEscapeIsPressed(GdkEventKey* e);
hegyi@1
   101
hegyi@1
   102
  ///Returns \ref signal_closed to be bindable somewhere.
hegyi@1
   103
  sigc::signal<void, AlgoWin *> signal_closing();
hegyi@1
   104
hegyi@1
   105
  ///Returns \ref signal_maplist_need to be bindable somewhere.
hegyi@1
   106
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
hegyi@1
   107
hegyi@1
   108
  ///Returns \ref signal_newmapwin_need to be bindable somewhere.
hegyi@1
   109
  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
hegyi@1
   110
hegyi@1
   111
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs.
hegyi@1
   112
  void emit_tab_change(std::string);
hegyi@1
   113
hegyi@1
   114
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin.
hegyi@1
   115
  void emit_new_map_signal(std::string tabname, bool itisarc){signal_newmapwin_need.emit(tabname, itisarc);};
hegyi@1
   116
hegyi@1
   117
  ///Constructor
hegyi@1
   118
hegyi@1
   119
  ///It builds the window according to the information provided
hegyi@1
   120
  ///by the creator. It needs the identifier of the algorithm
hegyi@1
   121
  ///to visualize, and a list of name of \ref NoteBookTab s that can
hegyi@1
   122
  ///be found in \ref MainWin.
hegyi@1
   123
  ///\param algoid identifier of algorithm to show
hegyi@1
   124
  ///\param tablist list of tabs in \ref MainWin
hegyi@1
   125
  AlgoWin(int algoid, std::vector<std::string> tablist);
hegyi@1
   126
hegyi@1
   127
  ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox
hegyi@1
   128
hegyi@1
   129
  ///In case of changement in tabs in \ref MainWin
hegyi@1
   130
  ///\ref MainWin automatically updates tablist in
hegyi@1
   131
  ///\ref AlgoWin s.
hegyi@1
   132
  void update_tablist(std::vector<std::string> tabnames);
hegyi@1
   133
hegyi@1
   134
  ///Forwards list of requested maps toward \ref AlgoBox
hegyi@1
   135
hegyi@1
   136
  ///Upon catching the signal in which \ref AlgoBox requests
hegyi@1
   137
  ///list of maps \ref MainWin responds
hegyi@1
   138
  ///through this function.
hegyi@1
   139
  void update_maplist(MapStorage *);
hegyi@1
   140
hegyi@1
   141
  ///Called when window is closing.
hegyi@1
   142
hegyi@1
   143
  ///\ref AlgoWin has to be deregistrated in \ref MainWin
hegyi@1
   144
  ///thereforeit emits signal \ref signal_closed.
hegyi@1
   145
  void on_hide();
hegyi@1
   146
};
hegyi@1
   147
#endif //ALGOWIN_H