Fawkes API  Fawkes Development Version
fuse_transfer_widget.h
00001  
00002 /***************************************************************************
00003  *  fuse_transfer_widget.h - Fuse transfer widget
00004  *
00005  *  Created: Wed Mar 19 17:11:01 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_
00024 #define __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_
00025 
00026 #include <fvutils/net/fuse_client_handler.h>
00027 #include <core/utils/lock_queue.h>
00028 
00029 #include <gtkmm.h>
00030 
00031 namespace firevision {
00032   class FuseClient;
00033   class YuvColormap;
00034 }
00035 class ColormapViewerWidget;
00036 
00037 class FuseTransferWidget : firevision::FuseClientHandler
00038 {
00039  public:
00040   FuseTransferWidget();
00041   virtual ~FuseTransferWidget();
00042   
00043   void add_fountain_service( const char* name,
00044                              const char* host_name,
00045                              uint16_t port );
00046   void remove_fountain_service(const char* name);
00047 
00048   void set_current_colormap(firevision::YuvColormap* colormap);
00049 
00050   void set_upload_btn(Gtk::Button* btn_upload);
00051   void set_download_btn(Gtk::Button* btn_download);
00052   void set_local_img(Gtk::Image* img_local);
00053   void set_local_layer_selector(Gtk::Scale* scl);
00054   void set_remote_img(Gtk::Image* img_remote);
00055   void set_remote_layer_selector(Gtk::Scale* scl);
00056   void set_local_lut_list_trv(Gtk::TreeView* lut_list);
00057   void set_remote_lut_list_trv(Gtk::TreeView* lut_list);
00058 
00059   // Fuse client handler
00060   void fuse_invalid_server_version(uint32_t local_version, 
00061                                    uint32_t remote_version) throw();
00062   void fuse_connection_established() throw();
00063   void fuse_connection_died() throw();
00064   void fuse_inbound_received(firevision::FuseNetworkMessage *m) throw();
00065 
00066  private:
00067   class LutRecord : public Gtk::TreeModelColumnRecord
00068     {
00069     public:
00070       LutRecord()
00071         {
00072           add(filename);
00073           add(service_name);
00074           add(host_name);
00075           add(port);
00076           add(lut_id);
00077           add(width);
00078           add(height);
00079           add(depth);
00080           add(bytes_per_cell);
00081           add(type);
00082         }
00083       
00084       /// @cond INTERNALS
00085       typedef enum
00086       {
00087         LUT_COLORMAP,
00088         LUT_MIRROR
00089       } LutType;
00090 
00091       Gtk::TreeModelColumn<Glib::ustring> filename;
00092       Gtk::TreeModelColumn<Glib::ustring> service_name;
00093       Gtk::TreeModelColumn<Glib::ustring> host_name;
00094       Gtk::TreeModelColumn<unsigned int> port;
00095       Gtk::TreeModelColumn<Glib::ustring> lut_id;
00096       Gtk::TreeModelColumn<unsigned int> width;
00097       Gtk::TreeModelColumn<unsigned int> height;
00098       Gtk::TreeModelColumn<unsigned int> depth;
00099       Gtk::TreeModelColumn<unsigned int> bytes_per_cell;
00100       Gtk::TreeModelColumn<LutRecord::LutType> type;
00101       /// @endcond
00102     };
00103 
00104   // signal handler
00105   void update_local_lut_list();
00106   void update_remote_lut_list();
00107   void get_lut_list();
00108   void delete_clients();
00109   void update_local_lut();
00110   void update_remote_lut();
00111   void upload_lut();
00112 
00113   void local_lut_selected();
00114   void remote_lut_selected();
00115 
00116   /// @cond INTERNALS
00117   struct ClientData
00118   {
00119     firevision::FuseClient* client;
00120     std::string service_name;
00121     std::string host_name;
00122     uint16_t port;
00123     bool active;
00124   };
00125   /// @endcond
00126 
00127   fawkes::LockQueue<ClientData> m_new_clients;
00128   fawkes::LockQueue<firevision::FuseClient*> m_delete_clients;
00129 
00130   ClientData m_cur_client;
00131 
00132   Glib::Dispatcher m_signal_update_local_lut_list;
00133   Glib::Dispatcher m_signal_update_remote_lut_list;
00134   Glib::Dispatcher m_signal_get_lut_list;
00135   Glib::Dispatcher m_signal_delete_client;
00136   Glib::Dispatcher m_signal_update_remote_lut;
00137 
00138   ColormapViewerWidget* m_local_colormap_viewer;
00139   ColormapViewerWidget* m_remote_colormap_viewer;
00140 
00141   Gtk::Button* m_btn_upload;
00142   Gtk::Button* m_btn_download;
00143   Gtk::Image* m_img_local;
00144   Gtk::Image* m_img_remote;
00145   Gtk::TreeView* m_trv_local_lut_list;
00146   Gtk::TreeView* m_trv_remote_lut_list;
00147   
00148   Glib::RefPtr<Gtk::ListStore> m_remote_lut_list;
00149   Glib::RefPtr<Gtk::ListStore> m_local_lut_list;
00150   LutRecord m_lut_record;
00151 
00152   firevision::YuvColormap* m_current_colormap;
00153   firevision::YuvColormap* m_local_colormap;
00154   firevision::YuvColormap* m_remote_colormap;
00155 };
00156 
00157 #endif /* __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_ */