SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
PlotTreeView.h
Go to the documentation of this file.
1
2#ifndef PLOTTREEVIEW_H
3#define PLOTTREEVIEW_H
4
5#include <gtkmm.h>
6#include <numeric>
7#include <vector>
8#include <iomanip>
9#include <iostream>
10#include "TreeColumns.h"
11#include "plotter.hpp"
12#include "config.h"
13#include "SBBHostCore.h"
14#include "SBBUtils.h"
15#include "spectra.h"
16//#include "FiltFilt.h"
17
18#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
19#ifndef OS_WIN
20#define OS_WIN
21#endif
22#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNUC__) || defined(__GNUG__) || defined(unix) || defined(__unix) || defined(__unix__)
23#ifndef OS_LINUX
24#define OS_LINUX
25#endif
26#else
27#error OS not supported
28#endif
29
30#ifdef OS_LINUX
31#define printf_s printf
32#endif
33
42class PlotTreeView : public Gtk::TreeView {
43public:
50 PlotTreeView(Gtk::ApplicationWindow* win, SBBHostCore *core);
51
55 virtual ~PlotTreeView();
56
57 //functions
63 void set_sampleGraph(CGraph::CairoGraph* graph);
64
71 void set_fftGraph(CGraph::CairoGraph* mag, CGraph::CairoGraph* ph);
72
73 //add more set_graph here, like set_psdGraph, set_frfGraph
74
80 void append_row();
81
86
92 void update_logname(int id, std::string name);
93
98 std::vector<Gtk::TreeModel::iterator> get_selected(int type);
99
101
102protected:
103 Gtk::ApplicationWindow* p_win = nullptr;
104 CGraph::CairoGraph* p_samplegraph = nullptr;
105 CGraph::CairoGraph* p_magfftgraph = nullptr;
106 CGraph::CairoGraph* p_phfftgraph = nullptr;
107 Glib::RefPtr<Gtk::TreeStore> p_TreeModel = nullptr;
108 Glib::RefPtr<Gtk::TreeSelection> p_TreeSelection = nullptr;
109 SBBHostCore* p_core = nullptr;
110 Glib::RefPtr<Gtk::Builder> p_builder;
111 Glib::RefPtr<Gio::SimpleActionGroup> p_signalActionGroup;
112 Glib::RefPtr<Gio::SimpleActionGroup> p_logActionGroup;
113 Glib::RefPtr<Gio::SimpleAction> p_lineTypeAction;
114 std::unique_ptr<Gtk::PopoverMenu> p_signal_popOverMenu = nullptr;
115 std::unique_ptr<Gtk::PopoverMenu> p_log_popOverMenu = nullptr;
116 std::unique_ptr<Gtk::ColorChooserDialog> p_colorChooser;
117 Gtk::TreeView::Column name_col;
118 Gtk::CellRendererText name_render;
119
120private:
126 bool check_new_name(std::string name);
127
132
140 void on_popover_button_pressed(int n_press, double x, double y);
141
146
151
152 //void on_menu_saveas(); //not used
153
158
162 void on_menu_set_linetype(int type);
163
169 void on_color_chooser_response(int id_response);
170
176 void name_col_on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeModel::const_iterator& iter);
177
184 void name_render_on_edited(const Glib::ustring& path_string, const Glib::ustring& new_text);
185
191 void name_render_on_editing_started(Gtk::CellEditable* cell_editable, const Glib::ustring& path_string);
192
193};
194
195#endif
A class for the plot tree view.
Definition: PlotTreeView.h:42
Glib::RefPtr< Gtk::TreeSelection > p_TreeSelection
Gtk::TreeSelection pointer for the tree view selection.
Definition: PlotTreeView.h:108
void append_row()
Append rows.
void set_sampleGraph(CGraph::CairoGraph *graph)
Set the sample-domain graph pointer.
void update_logname(int id, std::string name)
Update the log name shown.
Glib::RefPtr< Gio::SimpleActionGroup > p_logActionGroup
Gio::SimpleActionGroup pointer for simple actions in the log popover menu.
Definition: PlotTreeView.h:112
void on_color_chooser_response(int id_response)
Callback for the color chooser response.
CGraph::CairoGraph * p_samplegraph
CGraph::CairoGraph pointer to the sample-domain graph.
Definition: PlotTreeView.h:104
Glib::RefPtr< Gtk::TreeStore > p_TreeModel
Gtk::TreeStore pointer for the tree view model.
Definition: PlotTreeView.h:107
void set_fftGraph(CGraph::CairoGraph *mag, CGraph::CairoGraph *ph)
Set the spectra graph pointer.
void on_menu_save()
Callback for save logs.
void on_menu_delete()
Callback for delete logs.
std::unique_ptr< Gtk::PopoverMenu > p_signal_popOverMenu
Gtk::PopoverMenu pointer for the signal popover menu.
Definition: PlotTreeView.h:114
PlotTreeView(Gtk::ApplicationWindow *win, SBBHostCore *core)
Constructor.
void name_render_on_editing_started(Gtk::CellEditable *cell_editable, const Glib::ustring &path_string)
Callback for name column start editing.
Glib::RefPtr< Gtk::Builder > p_builder
Gtk::Builder pointer to read the popover menu from the XML file.
Definition: PlotTreeView.h:110
std::unique_ptr< Gtk::ColorChooserDialog > p_colorChooser
Gtk::ColorChooserDialog pointer for the color chooser dialog.
Definition: PlotTreeView.h:116
Glib::RefPtr< Gio::SimpleAction > p_lineTypeAction
Gio::SimpleActionGroup pointer for line-type action in the signal popover menu.
Definition: PlotTreeView.h:113
CGraph::CairoGraph * p_magfftgraph
CGraph::CairoGraph pointer to the magnitude-spectra graph.
Definition: PlotTreeView.h:105
CGraph::CairoGraph * p_phfftgraph
CGraph::CairoGraph pointer to the phase-spectra graph.
Definition: PlotTreeView.h:106
std::unique_ptr< Gtk::PopoverMenu > p_log_popOverMenu
Gtk::PopoverMenu pointer for the log popover menu.
Definition: PlotTreeView.h:115
std::vector< Gtk::TreeModel::iterator > get_selected(int type)
Get the selected log(s) or signal(s).
Gtk::TreeView::Column name_col
Gtk::TreeView::Column object for the editable name column.
Definition: PlotTreeView.h:117
virtual ~PlotTreeView()
Destructor.
void on_popover_button_pressed(int n_press, double x, double y)
Callback for popover item pressed.
Glib::RefPtr< Gio::SimpleActionGroup > p_signalActionGroup
Gio::SimpleActionGroup pointer for simple actions in the signal popover menu.
Definition: PlotTreeView.h:111
void on_menu_set_color()
Callback for the set color.
void create_column()
Create the column(s).
bool check_new_name(std::string name)
Check a new name.
void name_col_on_cell_data(Gtk::CellRenderer *renderer, const Gtk::TreeModel::const_iterator &iter)
Callback for setting the name cell.
TreeColumns * p_treeColumns
TreeColumns pointer for the format of the tree view column(s).
Definition: PlotTreeView.h:100
void name_render_on_edited(const Glib::ustring &path_string, const Glib::ustring &new_text)
Callback for name column edited.
void on_plot_tree_selected()
Callback for the tree view selected.
Gtk::CellRendererText name_render
Gtk::CellRendererText object for the editable name column.
Definition: PlotTreeView.h:118
void on_menu_set_linetype(int type)
Callback for the set linetype.
SBBHostCore * p_core
SBBHostCore pointer to the SBB Host core object.
Definition: PlotTreeView.h:109
Gtk::ApplicationWindow * p_win
Gtk::ApplicationWindow pointer to the application main window.
Definition: PlotTreeView.h:103
A class for the core of the SBB Host application.
Definition: SBBHostCore.h:46
A class for column definition in Gtk::TreeView.
Definition: TreeColumns.h:25
A configuration file for the source code.