File: openoptionswindow.h

package info (click to toggle)
aoflagger 3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,688 kB
  • sloc: cpp: 83,116; python: 10,187; sh: 260; makefile: 178
file content (98 lines) | stat: -rw-r--r-- 2,661 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef GUI_QUALITY__OPEN_OPTIONS_WINDOW_H
#define GUI_QUALITY__OPEN_OPTIONS_WINDOW_H

#include <string>
#include <vector>

#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/entry.h>
#include <gtkmm/window.h>

class OpenOptionsWindow : public Gtk::Window {
 public:
  OpenOptionsWindow()
      : _downsampleTimeButton("Lower time resolution (faster plots)"),
        _downsampleFreqButton("Lower frequency resolution (faster plots)"),
        _correctHistograms("Correct histograms for frequence response"),
        _cancelButton("_Cancel", true),
        _openButton("_Open", true) {
    _timeBox.pack_start(_downsampleTimeButton);
    _downsampleTimeButton.set_active(true);

    _timeBox.pack_start(_timeDownsampleEntry);
    _timeDownsampleEntry.set_text("1000");

    _box.pack_start(_timeBox);

    _freqBox.pack_start(_downsampleFreqButton);
    _downsampleFreqButton.set_active(true);

    _freqBox.pack_start(_freqDownsampleEntry);
    _freqDownsampleEntry.set_text("1000");

    _box.pack_start(_freqBox);

    _box.pack_start(_correctHistograms);

    _buttonBox.pack_start(_cancelButton);

    _buttonBox.pack_start(_openButton);
    _openButton.signal_clicked().connect(
        sigc::mem_fun(*this, &OpenOptionsWindow::onOpen));

    _box.pack_start(_buttonBox);

    add(_box);
    _box.show_all();
  }

  ~OpenOptionsWindow() {}

  void ShowForFile(const std::vector<std::string>& files) {
    _files = files;
    present();
  }

  void ShowForFile(const std::string& filename) {
    _files.clear();
    _files.push_back(filename);
    present();
  }

  sigc::signal<void, const std::vector<std::string>&, bool, bool, size_t,
               size_t, bool>&
  SignalOpen() {
    return _signalOpen;
  }

 private:
  void onOpen() {
    hide();
    size_t timeRes = atol(_timeDownsampleEntry.get_text().c_str());
    size_t freqRes = atol(_freqDownsampleEntry.get_text().c_str());
    _signalOpen.emit(_files, _downsampleTimeButton.get_active(),
                     _downsampleFreqButton.get_active(), timeRes, freqRes,
                     _correctHistograms.get_active());
    _files.clear();
  }

  Gtk::VBox _box;
  Gtk::HBox _timeBox;
  Gtk::CheckButton _downsampleTimeButton;
  Gtk::Entry _timeDownsampleEntry;
  Gtk::HBox _freqBox;
  Gtk::CheckButton _downsampleFreqButton;
  Gtk::Entry _freqDownsampleEntry;
  Gtk::CheckButton _correctHistograms;
  Gtk::ButtonBox _buttonBox;
  Gtk::Button _cancelButton, _openButton;
  sigc::signal<void, const std::vector<std::string>&, bool, bool, size_t,
               size_t, bool>
      _signalOpen;

  std::vector<std::string> _files;
};

#endif