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       typedef enum
00085       {
00086         LUT_COLORMAP,
00087         LUT_MIRROR
00088       } LutType;
00089 
00090       Gtk::TreeModelColumn<Glib::ustring> filename;
00091       Gtk::TreeModelColumn<Glib::ustring> service_name;
00092       Gtk::TreeModelColumn<Glib::ustring> host_name;
00093       Gtk::TreeModelColumn<unsigned int> port;
00094       Gtk::TreeModelColumn<Glib::ustring> lut_id;
00095       Gtk::TreeModelColumn<unsigned int> width;
00096       Gtk::TreeModelColumn<unsigned int> height;
00097       Gtk::TreeModelColumn<unsigned int> depth;
00098       Gtk::TreeModelColumn<unsigned int> bytes_per_cell;
00099       Gtk::TreeModelColumn<LutRecord::LutType> type;
00100     };
00101 
00102   // signal handler
00103   void update_local_lut_list();
00104   void update_remote_lut_list();
00105   void get_lut_list();
00106   void delete_clients();
00107   void update_local_lut();
00108   void update_remote_lut();
00109   void upload_lut();
00110 
00111   void local_lut_selected();
00112   void remote_lut_selected();
00113 
00114   struct ClientData
00115   {
00116     firevision::FuseClient* client;
00117     std::string service_name;
00118     std::string host_name;
00119     uint16_t port;
00120     bool active;
00121   };
00122 
00123   fawkes::LockQueue<ClientData> m_new_clients;
00124   fawkes::LockQueue<firevision::FuseClient*> m_delete_clients;
00125 
00126   ClientData m_cur_client;
00127 
00128   Glib::Dispatcher m_signal_update_local_lut_list;
00129   Glib::Dispatcher m_signal_update_remote_lut_list;
00130   Glib::Dispatcher m_signal_get_lut_list;
00131   Glib::Dispatcher m_signal_delete_client;
00132   Glib::Dispatcher m_signal_update_remote_lut;
00133 
00134   ColormapViewerWidget* m_local_colormap_viewer;
00135   ColormapViewerWidget* m_remote_colormap_viewer;
00136 
00137   Gtk::Button* m_btn_upload;
00138   Gtk::Button* m_btn_download;
00139   Gtk::Image* m_img_local;
00140   Gtk::Image* m_img_remote;
00141   Gtk::TreeView* m_trv_local_lut_list;
00142   Gtk::TreeView* m_trv_remote_lut_list;
00143   
00144   Glib::RefPtr<Gtk::ListStore> m_remote_lut_list;
00145   Glib::RefPtr<Gtk::ListStore> m_local_lut_list;
00146   LutRecord m_lut_record;
00147 
00148   firevision::YuvColormap* m_current_colormap;
00149   firevision::YuvColormap* m_local_colormap;
00150   firevision::YuvColormap* m_remote_colormap;
00151 };
00152 
00153 #endif /* __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_ */