23 #include "retriever_config_plugin.h"
25 #include <config/config.h>
26 #include <core/exceptions/software.h>
27 #include <fvutils/system/camargp.h>
30 using namespace fawkes;
31 using namespace firevision;
44 const Glib::RefPtr<Gtk::Builder> &builder)
45 : Gtk::Dialog( cobject )
47 builder->get_widget(
"trvCameras", m_trv_cameras);
48 builder->get_widget(
"btnAdd", m_btn_add_camera);
49 builder->get_widget(
"btnDelete", m_btn_delete_camera);
51 m_btn_add_camera->signal_clicked().connect( sigc::mem_fun( *
this, &RetrieverConfigDialog::on_add_clicked ) );
52 m_btn_delete_camera->signal_clicked().connect( sigc::mem_fun( *
this, &RetrieverConfigDialog::on_delete_clicked ) );
54 m_camera_list = Gtk::ListStore::create( m_camera_record );
55 m_trv_cameras->set_model( m_camera_list );
56 m_trv_cameras->append_column_editable(
"Name", m_camera_record.name );
57 m_trv_cameras->append_column_editable(
"Type", m_camera_record.type );
58 m_trv_cameras->append_column_editable(
"Id", m_camera_record.id );
59 m_trv_cameras->append_column_editable(
"Parameter", m_camera_record.params );
60 m_trv_cameras->append_column_editable(
"Record", m_camera_record.record_images );
61 m_trv_cameras->append_column_editable(
"Save path", m_camera_record.save_path );
84 string cam_id = argp->
cam_id();
86 std::map< string, string > param_map = argp->
parameters();
88 std::map< string, string >::iterator i = param_map.begin();
89 while ( i != param_map.end() )
91 params += i->first +
"=" + i->second;
93 if ( ++i != param_map.end() )
97 Gtk::TreeModel::Row row = *m_camera_list->append();
98 row[ m_camera_record.name ] = camera_name;
99 row[ m_camera_record.type ] = cam_type;
100 row[ m_camera_record.id ] = cam_id;
101 row[ m_camera_record.params ] = params;
102 row[ m_camera_record.record_images ] = record_images;
103 row[ m_camera_record.save_path ] = save_path;
111 std::map< string, string >
114 std::map< string, string > cameras;
116 Gtk::TreeModel::Row row;
118 Glib::ustring cam_string;
120 for ( Gtk::TreeIter i = m_camera_list->children().begin();
121 i != m_camera_list->children().end();
125 name = row[ m_camera_record.name ];
126 cam_string = row[ m_camera_record.type ] +
":" +
127 row[ m_camera_record.id ] +
":" +
128 row[ m_camera_record.params ];
130 cameras[ name ] = cam_string;
137 RetrieverConfigDialog::on_add_clicked()
140 Gtk::TreeIter iter = m_camera_list->append();
141 Gtk::TreeModel::Row row = *iter;
142 row[ m_camera_record.name ] =
"";
143 row[ m_camera_record.type ] =
"";
144 row[ m_camera_record.id ] =
"";
145 row[ m_camera_record.params ] =
"";
146 row[ m_camera_record.record_images ] =
false;
147 row[ m_camera_record.save_path ] =
"";
149 m_trv_cameras->set_cursor( m_camera_list->get_path( iter ) );
153 RetrieverConfigDialog::on_delete_clicked()
155 Gtk::TreeIter iter = m_trv_cameras->get_selection()->get_selected();
156 m_camera_list->erase( iter );
185 while ( vit->
next() )
190 "argument string, but got %s for %s",
195 string camera_name = string( vit->
path() ).substr( prefix.length() );
210 case ( Gtk::RESPONSE_OK ):
213 std::map< string, string > cameras = dlg->
get_cameras();
217 for ( std::map< string, string >::iterator i = cameras.begin();
227 case ( Gtk::RESPONSE_CANCEL ):
231 printf(
"unknonw response\n");
240 m_builder->get_widget_derived(
"PluginDialog", dlg);
void add_camera(std::string camera_name, std::string camera_string, bool record_images=false, std::string save_path="")
Adds a camera to the list of cameras.
std::map< std::string, std::string > parameters() const
Get a map of parameters.
virtual const char * type() const =0
Type of value.
virtual void post_run(int response)
This method is called after the dialog is closed.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
fawkes::Configuration * m_config
The fawkes::Configuration.
virtual bool next()=0
Check if there is another element and advance to this if possible.
Glib::RefPtr< Gtk::Builder > m_builder
Gtk Builder created from the UI file of the plugin.
Config dialog of the config editor plugin for the fvretriever.
std::string cam_type() const
Get camera type.
virtual ~RetrieverConfigDialog()
Destructor.
std::string m_config_path
The config prefix the plugin is attached to.
RetrieverConfigPlugin(std::string ui_path)
Constructor.
virtual ~RetrieverConfigPlugin()
Destructor.
virtual bool is_string() const =0
Check if current value is a string.
virtual void pre_run()
Config editor plugins need to implement this function.
virtual std::string get_string() const =0
Get string value.
virtual const char * path() const =0
Path of value.
virtual void unlock()=0
Unlock the config.
Iterator interface to iterate over config values.
Gtk::Dialog * m_dialog
The (main-) dialog of the plugin.
RetrieverConfigDialog(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
std::map< std::string, std::string > get_cameras() const
Obtain the list of cameras shown in the dialog.
Base class for plugins for the Fawkes config editor.
virtual void set_string(const char *path, std::string &s)=0
Set new value in configuration of type string.
virtual void lock()=0
Lock the config.
virtual Gtk::Dialog * load_dialog()
In this function the (custom) dialog of the plugin needs to be initialized.
std::string cam_id() const
Get camera ID.