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