algowin.h
author hegyi
Tue, 27 Feb 2007 17:23:55 +0000
changeset 192 9d7489e8921e
parent 125 e8bf8bbcf75a
child 194 6b2b718420eb
permissions -rw-r--r--
Forgot the meat.
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
class AlgoWin;
hegyi@103
    23
hegyi@103
    24
#include <all_include.h>
hegyi@109
    25
//#include <mapstorage.h>
hegyi@103
    26
#include <algobox.h>
hegyi@103
    27
#include <libgnomecanvasmm.h>
hegyi@103
    28
#include <libgnomecanvasmm/polygon.h>
hegyi@103
    29
hegyi@109
    30
class MapStorage;
hegyi@109
    31
hegyi@125
    32
///Algorithm identifiers.
hegyi@106
    33
enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
hegyi@103
    34
hegyi@125
    35
///Window displaying graphical interface for different algorithms.
hegyi@125
    36
hegyi@125
    37
///This class displays a graphical interface to set up
hegyi@125
    38
///and run different algorithms. Different algorithms need
hegyi@125
    39
///different inputs, running methods, etc. Therefore
hegyi@125
    40
///class \ref AlgoWin is only a holder of a base class, the so
hegyi@125
    41
///called AlgoBox. \ref AlgoBox is the ancestor of other
hegyi@125
    42
///classes. These child classes realize interfaces of different
hegyi@125
    43
///algorithms, but as their common ancestor is \ref AlgoBox
hegyi@125
    44
///the interface of them is the same. \ref AlgoWin communicates
hegyi@125
    45
///with these classes through this common interface. But it the
hegyi@125
    46
///real object to be placed in \ref AlgoWin depends on the algorithm
hegyi@125
    47
///which the \ref AlgoWin actually has to display. It gets the
hegyi@125
    48
///id of algorithm to display at initialization, and therefore it is
hegyi@125
    49
///able to place in itself the requested child of \ref AlgoBox
hegyi@125
    50
/// visualizing the appropriate algorithm.
hegyi@106
    51
class AlgoWin : public Gtk::Window
hegyi@103
    52
{
hegyi@103
    53
private:
hegyi@125
    54
  ///Algorithm specific part of \ref AlgoWin
hegyi@103
    55
  AlgoBox * ab;
hegyi@125
    56
hegyi@125
    57
  ///Run button.
hegyi@125
    58
hegyi@125
    59
  ///If pressed, algorithm should run.
hegyi@125
    60
  ///That is why common ancestor of different
hegyi@125
    61
  ///algorithm realizer classes have to be. In case of
hegyi@125
    62
  ///pressing run button a common method can be called.
hegyi@106
    63
  Gtk::Button * runbutton;
hegyi@125
    64
hegyi@125
    65
  ///Close button. If pressed, \ref AlgoWin should close.
hegyi@106
    66
  Gtk::Button * closebutton;
hegyi@103
    67
hegyi@103
    68
protected:
hegyi@125
    69
  ///Signal emitted upon close of window
hegyi@125
    70
hegyi@125
    71
  ///It is necessary, because \ref MainWin have to
hegyi@125
    72
  ///score the opened \ref AlgoWin s, to be able to communicate
hegyi@125
    73
  ///with them: let them know about changement in tabs, maps, etc.
hegyi@125
    74
  ///If \ref AlgoWin is closed, \ref MainWin has to deregistrate it.
hegyi@125
    75
  ///Therefore signal contains address of emitter \ref AlgoWin.
hegyi@125
    76
  sigc::signal<void, AlgoWin *> signal_closed;
hegyi@125
    77
hegyi@125
    78
  ///Signal indicating that informatino on certain maplist is required.
hegyi@125
    79
hegyi@125
    80
  ///It is just a forwarded signal from \ref AlgoBox, benefit of common ancestor
hegyi@125
    81
  ///algorithm class. User can select the graph (the holder \ref NoteBookTab) on
hegyi@125
    82
  ///which the algorithm should run. But different graphs (\ref NoteBookTab) have
hegyi@125
    83
  ///different maps. If selected tab changes this signal is emitted by \ref AlgoBox,
hegyi@125
    84
  ///caught and reemitted by \ref AlgoWin.
hegyi@125
    85
  ///
hegyi@125
    86
  ///Signal contains the address of \ref AlgoWin to let \ref MainWin know
hegyi@125
    87
  ///where should the information needed forwarded, and the name of
hegyi@125
    88
  ///\ref NoteBookTab, of which maps are inquired.
hegyi@125
    89
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
hegyi@125
    90
hegyi@125
    91
  ///Signal that indicates that a \ref NewMapWin should be popped up.
hegyi@125
    92
hegyi@125
    93
  ///This is a forwarded signal. If \ref AlgoBox emits a signal
hegyi@125
    94
  ///to let a \ref NewMapWin pop up, |ref AlgoWin catch and reemit it.
hegyi@125
    95
  ///
hegyi@125
    96
  ///Signal contains the name of \ref NoteBookTab, in which the new map
hegyi@125
    97
  ///should be created and a boolean that indicates whether an edge or a
hegyi@125
    98
  ///nodemap should be created.
hegyi@125
    99
  sigc::signal<void, std::string, bool> signal_newmapwin_need;
hegyi@103
   100
hegyi@103
   101
public:
hegyi@125
   102
  ///Close window if escape key is pressed.
hegyi@106
   103
  bool closeIfEscapeIsPressed(GdkEventKey* e);
hegyi@103
   104
hegyi@125
   105
  ///Returns \ref signal_closed to be bindable somewhere.
hegyi@106
   106
  sigc::signal<void, AlgoWin *> signal_closing();
hegyi@125
   107
hegyi@125
   108
  ///Returns \ref signal_maplist_need to be bindable somewhere.
hegyi@106
   109
  sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
hegyi@103
   110
hegyi@125
   111
  ///Returns \ref signal_newmapwin_need to be bindable somewhere.
hegyi@125
   112
  sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
hegyi@125
   113
hegyi@125
   114
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates changement in selection of tabs.
hegyi@106
   115
  void emit_tab_change(std::string);
hegyi@125
   116
hegyi@125
   117
  ///Forwards signal emitted by \ref AlgoBox, in which it indicates need for \ref NewMapWin.
hegyi@114
   118
  void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);};
hegyi@103
   119
hegyi@125
   120
  ///Constructor
hegyi@106
   121
hegyi@125
   122
  ///It builds the window according to the information provided
hegyi@125
   123
  ///by the creator. It needs the identifier of the algorithm
hegyi@125
   124
  ///to visualize, and a list of name of \ref NoteBookTab s that can
hegyi@125
   125
  ///be found in \ref MainWin.
hegyi@125
   126
  ///\param algoid identifier of algorithm to show
hegyi@125
   127
  ///\param tablist list of tabs in \ref MainWin
hegyi@125
   128
  AlgoWin(int algoid, std::vector<std::string> tablist);
hegyi@125
   129
hegyi@125
   130
  ///Forwards list of \ref NoteBookTabs toward \ref AlgoBox
hegyi@125
   131
hegyi@125
   132
  ///In case of changement in tabs in \ref MainWin
hegyi@125
   133
  ///\ref MainWin automatically updates tablist in
hegyi@125
   134
  ///\ref AlgoWin s.
hegyi@106
   135
  void update_tablist(std::vector<std::string> tabnames);
hegyi@125
   136
hegyi@125
   137
  ///Forwards list of requested maps toward \ref AlgoBox
hegyi@125
   138
hegyi@125
   139
  ///Upon catching the signal in which \ref AlgoBox requests
hegyi@125
   140
  ///list of maps \ref MainWin responds
hegyi@125
   141
  ///through this function.
hegyi@109
   142
  void update_maplist(MapStorage *);
hegyi@106
   143
hegyi@125
   144
  ///Called when window is closing.
hegyi@125
   145
hegyi@125
   146
  ///\ref AlgoWin has to be deregistrated in \ref MainWin
hegyi@125
   147
  ///thereforeit emits signal \ref signal_closed.
hegyi@106
   148
  void on_hide();
hegyi@103
   149
};
hegyi@103
   150
#endif //ALGOWIN_H