SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
PlotTreeView Class Reference

A class for the plot tree view. More...

#include <PlotTreeView.h>

Inheritance diagram for PlotTreeView:

Public Member Functions

 PlotTreeView (Gtk::ApplicationWindow *win, SBBHostCore *core)
 Constructor. More...
 
virtual ~PlotTreeView ()
 Destructor. More...
 
void set_sampleGraph (CGraph::CairoGraph *graph)
 Set the sample-domain graph pointer. More...
 
void set_fftGraph (CGraph::CairoGraph *mag, CGraph::CairoGraph *ph)
 Set the spectra graph pointer. More...
 
void append_row ()
 Append rows. More...
 
void create_column ()
 Create the column(s). More...
 
void update_logname (int id, std::string name)
 Update the log name shown. More...
 
std::vector< Gtk::TreeModel::iterator > get_selected (int type)
 Get the selected log(s) or signal(s). More...
 

Public Attributes

TreeColumnsp_treeColumns = nullptr
 TreeColumns pointer for the format of the tree view column(s). More...
 

Protected Attributes

Gtk::ApplicationWindow * p_win = nullptr
 Gtk::ApplicationWindow pointer to the application main window. More...
 
CGraph::CairoGraph * p_samplegraph = nullptr
 CGraph::CairoGraph pointer to the sample-domain graph. More...
 
CGraph::CairoGraph * p_magfftgraph = nullptr
 CGraph::CairoGraph pointer to the magnitude-spectra graph. More...
 
CGraph::CairoGraph * p_phfftgraph = nullptr
 CGraph::CairoGraph pointer to the phase-spectra graph. More...
 
Glib::RefPtr< Gtk::TreeStore > p_TreeModel = nullptr
 Gtk::TreeStore pointer for the tree view model. More...
 
Glib::RefPtr< Gtk::TreeSelection > p_TreeSelection = nullptr
 Gtk::TreeSelection pointer for the tree view selection. More...
 
SBBHostCorep_core = nullptr
 SBBHostCore pointer to the SBB Host core object. More...
 
Glib::RefPtr< Gtk::Builder > p_builder
 Gtk::Builder pointer to read the popover menu from the XML file. More...
 
Glib::RefPtr< Gio::SimpleActionGroup > p_signalActionGroup
 Gio::SimpleActionGroup pointer for simple actions in the signal popover menu. More...
 
Glib::RefPtr< Gio::SimpleActionGroup > p_logActionGroup
 Gio::SimpleActionGroup pointer for simple actions in the log popover menu. More...
 
Glib::RefPtr< Gio::SimpleAction > p_lineTypeAction
 Gio::SimpleActionGroup pointer for line-type action in the signal popover menu. More...
 
std::unique_ptr< Gtk::PopoverMenu > p_signal_popOverMenu = nullptr
 Gtk::PopoverMenu pointer for the signal popover menu. More...
 
std::unique_ptr< Gtk::PopoverMenu > p_log_popOverMenu = nullptr
 Gtk::PopoverMenu pointer for the log popover menu. More...
 
std::unique_ptr< Gtk::ColorChooserDialog > p_colorChooser
 Gtk::ColorChooserDialog pointer for the color chooser dialog. More...
 
Gtk::TreeView::Column name_col
 Gtk::TreeView::Column object for the editable name column. More...
 
Gtk::CellRendererText name_render
 Gtk::CellRendererText object for the editable name column. More...
 

Private Member Functions

bool check_new_name (std::string name)
 Check a new name. More...
 
void on_plot_tree_selected ()
 Callback for the tree view selected. More...
 
void on_popover_button_pressed (int n_press, double x, double y)
 Callback for popover item pressed. More...
 
void on_menu_delete ()
 Callback for delete logs. More...
 
void on_menu_save ()
 Callback for save logs. More...
 
void on_menu_set_color ()
 Callback for the set color. More...
 
void on_menu_set_linetype (int type)
 Callback for the set linetype. More...
 
void on_color_chooser_response (int id_response)
 Callback for the color chooser response. More...
 
void name_col_on_cell_data (Gtk::CellRenderer *renderer, const Gtk::TreeModel::const_iterator &iter)
 Callback for setting the name cell. More...
 
void name_render_on_edited (const Glib::ustring &path_string, const Glib::ustring &new_text)
 Callback for name column edited. More...
 
void name_render_on_editing_started (Gtk::CellEditable *cell_editable, const Glib::ustring &path_string)
 Callback for name column start editing. More...
 

Detailed Description

A class for the plot tree view.

Class for the tree view in the plot tab, extending the Gtk::TreeView class and allowing selection of log-signal combinations to be shown in the graph. Class used in SBBHostApp.

See also
SBBHostApp
Author
Stefano Lovato
Date
2022

Constructor & Destructor Documentation

◆ PlotTreeView()

PlotTreeView::PlotTreeView ( Gtk::ApplicationWindow *  win,
SBBHostCore core 
)

Constructor.

Default constructor.

Parameters
winThe pointer to the main window of SBBHostApp.
coreThe pointer to the SBBHostCore object.
See also
SBBHostApp SBBHostCore

◆ ~PlotTreeView()

virtual PlotTreeView::~PlotTreeView ( )
virtual

Destructor.

Default destructor.

Member Function Documentation

◆ append_row()

void PlotTreeView::append_row ( )

Append rows.

Function to append the row for the last log, as well as the child rows for all the necessary signals. It automatically find the last log from the SBBHostCore object.

See also
SBBHostCore

◆ check_new_name()

bool PlotTreeView::check_new_name ( std::string  name)
private

Check a new name.

Function to check a new user-defined name for a log. It avoids invalid char (see INVALID_CHARS in config.h).

Parameters
nameThe name as a string.
Returns
true if the name is ok, false otherwise.

◆ create_column()

void PlotTreeView::create_column ( )

Create the column(s).

Function to create the column(s) in the tree view.

◆ get_selected()

std::vector< Gtk::TreeModel::iterator > PlotTreeView::get_selected ( int  type)

Get the selected log(s) or signal(s).

Function to get the selected log(s) or signal(s) in the tree view.

Returns
A std::vector containing the selected log(s) or signal(s), represented by a Gtk::TreeModel::iterator.

◆ name_col_on_cell_data()

void PlotTreeView::name_col_on_cell_data ( Gtk::CellRenderer *  renderer,
const Gtk::TreeModel::const_iterator &  iter 
)
private

Callback for setting the name cell.

Callback function called to set the value in the name cell according to its renderer.

Parameters
rendererThe Gtk::CellRenderer pointer to the renderer object.
iterThe Gtk::TreeModel::const_iterator.

◆ name_render_on_edited()

void PlotTreeView::name_render_on_edited ( const Glib::ustring &  path_string,
const Glib::ustring &  new_text 
)
private

Callback for name column edited.

Callback function called when the editing of the name cell finisched, in order to set the name of the cell. Only for log-type cells (name is editable only from those cells).

Parameters
path_stringThe path identifying the edited cell.
new_textThe new name used for the edited cell.

◆ name_render_on_editing_started()

void PlotTreeView::name_render_on_editing_started ( Gtk::CellEditable *  cell_editable,
const Glib::ustring &  path_string 
)
private

Callback for name column start editing.

Callback function called when starting to edit a name column cell. It avoids editing in the case of signal-type cells.

Parameters
cell_editableThe pointer to the Gtk::CellEditable object.
path_stringThe path identifying the edited cell.

◆ on_color_chooser_response()

void PlotTreeView::on_color_chooser_response ( int  id_response)
private

Callback for the color chooser response.

Callback function called when exiting from the color chooser dialog.

See also
Gtk::ColorChooserDialog
Parameters
id_responseThe response ID.

◆ on_menu_delete()

void PlotTreeView::on_menu_delete ( )
private

Callback for delete logs.

Callback function called when selecting the 'Delete' button in the log popover menu.

◆ on_menu_save()

void PlotTreeView::on_menu_save ( )
private

Callback for save logs.

Callback function called when selecting the 'Save' button in the log popover menu.

◆ on_menu_set_color()

void PlotTreeView::on_menu_set_color ( )
private

Callback for the set color.

Callback function called when selecting the 'Set color' button in the signal popover menu.

◆ on_menu_set_linetype()

void PlotTreeView::on_menu_set_linetype ( int  type)
private

Callback for the set linetype.

Callback function called when selecting the 'Set linetype' button in the signal popover menu.

◆ on_plot_tree_selected()

void PlotTreeView::on_plot_tree_selected ( )
private

Callback for the tree view selected.

Callback function called when selecting a signal or log in the trew view.

◆ on_popover_button_pressed()

void PlotTreeView::on_popover_button_pressed ( int  n_press,
double  x,
double  y 
)
private

Callback for popover item pressed.

Callback function called when pressing a button of the popover menu.

See also
Glib::SignalProxy<void(int, double, double)> Gtk::GestureClick::signal_pressed()
Parameters
n_pressHow many touch/button presses happened with this one.
xThe X coordinate, in widget allocation coordinates.
yThe Y coordinate, in widget allocation coordinates.

◆ set_fftGraph()

void PlotTreeView::set_fftGraph ( CGraph::CairoGraph *  mag,
CGraph::CairoGraph *  ph 
)

Set the spectra graph pointer.

Function to set the spectra graph pointer, in order to have full access to the graph.

Parameters
magThe pointer to the CGraph::CairoGraph graph of the magnitude.
phThe pointer to the CGraph::CairoGraph graph of the phase.

◆ set_sampleGraph()

void PlotTreeView::set_sampleGraph ( CGraph::CairoGraph *  graph)

Set the sample-domain graph pointer.

Function to set the sample-domain graph pointer, in order to have full access to the graph.

Parameters
graphThe pointer to the CGraph::CairoGraph graph object.

◆ update_logname()

void PlotTreeView::update_logname ( int  id,
std::string  name 
)

Update the log name shown.

Function to update the log name in the tree view row.

Parameters
idThe ID of the log.
nameThe new name.

Member Data Documentation

◆ name_col

Gtk::TreeView::Column PlotTreeView::name_col
protected

Gtk::TreeView::Column object for the editable name column.

◆ name_render

Gtk::CellRendererText PlotTreeView::name_render
protected

Gtk::CellRendererText object for the editable name column.

◆ p_builder

Glib::RefPtr<Gtk::Builder> PlotTreeView::p_builder
protected

Gtk::Builder pointer to read the popover menu from the XML file.

◆ p_colorChooser

std::unique_ptr<Gtk::ColorChooserDialog> PlotTreeView::p_colorChooser
protected

Gtk::ColorChooserDialog pointer for the color chooser dialog.

◆ p_core

SBBHostCore* PlotTreeView::p_core = nullptr
protected

SBBHostCore pointer to the SBB Host core object.

◆ p_lineTypeAction

Glib::RefPtr<Gio::SimpleAction> PlotTreeView::p_lineTypeAction
protected

Gio::SimpleActionGroup pointer for line-type action in the signal popover menu.

◆ p_log_popOverMenu

std::unique_ptr<Gtk::PopoverMenu> PlotTreeView::p_log_popOverMenu = nullptr
protected

Gtk::PopoverMenu pointer for the log popover menu.

◆ p_logActionGroup

Glib::RefPtr<Gio::SimpleActionGroup> PlotTreeView::p_logActionGroup
protected

Gio::SimpleActionGroup pointer for simple actions in the log popover menu.

◆ p_magfftgraph

CGraph::CairoGraph* PlotTreeView::p_magfftgraph = nullptr
protected

CGraph::CairoGraph pointer to the magnitude-spectra graph.

◆ p_phfftgraph

CGraph::CairoGraph* PlotTreeView::p_phfftgraph = nullptr
protected

CGraph::CairoGraph pointer to the phase-spectra graph.

◆ p_samplegraph

CGraph::CairoGraph* PlotTreeView::p_samplegraph = nullptr
protected

CGraph::CairoGraph pointer to the sample-domain graph.

◆ p_signal_popOverMenu

std::unique_ptr<Gtk::PopoverMenu> PlotTreeView::p_signal_popOverMenu = nullptr
protected

Gtk::PopoverMenu pointer for the signal popover menu.

◆ p_signalActionGroup

Glib::RefPtr<Gio::SimpleActionGroup> PlotTreeView::p_signalActionGroup
protected

Gio::SimpleActionGroup pointer for simple actions in the signal popover menu.

◆ p_treeColumns

TreeColumns* PlotTreeView::p_treeColumns = nullptr

TreeColumns pointer for the format of the tree view column(s).

◆ p_TreeModel

Glib::RefPtr<Gtk::TreeStore> PlotTreeView::p_TreeModel = nullptr
protected

Gtk::TreeStore pointer for the tree view model.

◆ p_TreeSelection

Glib::RefPtr<Gtk::TreeSelection> PlotTreeView::p_TreeSelection = nullptr
protected

Gtk::TreeSelection pointer for the tree view selection.

◆ p_win

Gtk::ApplicationWindow* PlotTreeView::p_win = nullptr
protected

Gtk::ApplicationWindow pointer to the application main window.