-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.h
60 lines (46 loc) · 1.58 KB
/
frontend.h
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
// by wuwbobo2021 <https://github.com/wuwbobo2021>, <[email protected]>
// If you have found bugs in this program, please pull an issue, or contact me.
// Licensed under LGPL version 2.1.
#ifndef SIMPLE_CAIRO_PLOT_FRONTEND_H
#define SIMPLE_CAIRO_PLOT_FRONTEND_H
#include <simple-cairo-plot/recorder.h>
#include <gtkmm/window.h>
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/button.h>
#include <gtkmm/checkbutton.h>
namespace SimpleCairoPlot
{
class Frontend: public sigc::trackable
{
std::vector<VariablePtr> ptrs; unsigned int buf_size;
Recorder* rec;
std::thread* thread_gtk = NULL;
Glib::Dispatcher* dispatcher_quit = NULL;
Gtk::Window* volatile window = NULL;
Gtk::FileChooserDialog* file_dialog;
Gtk::Button* button_start_stop;
#ifdef _WIN32
volatile bool flag_open = true, flag_destruct = false;
void thread_loop();
#endif
void create_window();
void create_file_dialog();
void app_run();
void on_buffers_full();
void on_button_start_stop_clicked();
void on_button_open_clicked();
void on_button_save_clicked();
public:
std::string title = "Recorder";
Frontend(); void init(std::vector<VariablePtr>& ptrs, unsigned int buf_size);
Frontend(std::vector<VariablePtr>& ptrs, unsigned int buf_size);
Frontend(const Frontend&) = delete;
Frontend& operator=(const Frontend&) = delete;
virtual ~Frontend();
void open(); //create a new thread to run the frontend
Recorder& recorder() const; //notice: don't keep the returned reference when closing the frontend
void run(); //run in current thread or join the existing frontend thread, blocks
void close();
};
}
#endif