Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * firestation.h - Firestation 00004 * 00005 * Created: Wed Oct 10 14:15:56 2007 00006 * Copyright 2007 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_FIRESTATION_H_ 00024 #define __FIREVISION_TOOLS_FIRESTATION_FIRESTATION_H_ 00025 00026 #include <gtkmm.h> 00027 #include <libglademm/xml.h> 00028 #include <fvutils/base/roi.h> 00029 #include <fvutils/color/colorspaces.h> 00030 #include <netcomm/dns-sd/avahi_thread.h> 00031 00032 namespace firevision { 00033 class Camera; 00034 class SharedMemoryImageBuffer; 00035 class ShmImageLister; 00036 class Writer; 00037 class FuseImageListWidget; 00038 } 00039 namespace fawkes { 00040 class AvahiDispatcher; 00041 } 00042 class MirrorCalibTool; 00043 class ColorTrainTool; 00044 class ColorTrainWidget; 00045 class FuseTransferWidget; 00046 00047 class Firestation : public Gtk::Window 00048 { 00049 public: 00050 Firestation(Glib::RefPtr<Gnome::Glade::Xml> ref_xml); 00051 virtual ~Firestation(); 00052 00053 Gtk::Window& get_window() const; 00054 00055 private: 00056 class ShmColumnRecord : public Gtk::TreeModel::ColumnRecord 00057 { 00058 public: 00059 ShmColumnRecord() 00060 { 00061 add(m_id); add(m_name); 00062 }; 00063 Gtk::TreeModelColumn<int> m_id; 00064 Gtk::TreeModelColumn<Glib::ustring> m_name; 00065 }; 00066 00067 class FuseColumnRecord : public Gtk::TreeModel::ColumnRecord 00068 { 00069 public: 00070 FuseColumnRecord() 00071 { 00072 add(m_id); add(m_name); 00073 add(m_service_name); add(m_service_domain); 00074 add(m_service_hostname); add(m_service_port); 00075 add(m_image_id); add(m_image_width), add(m_image_height); 00076 add(m_image_colorspace); 00077 }; 00078 Gtk::TreeModelColumn<int> m_id; 00079 Gtk::TreeModelColumn<Glib::ustring> m_name; 00080 Gtk::TreeModelColumn<Glib::ustring> m_service_name; 00081 Gtk::TreeModelColumn<Glib::ustring> m_service_type; 00082 Gtk::TreeModelColumn<Glib::ustring> m_service_domain; 00083 Gtk::TreeModelColumn<Glib::ustring> m_service_hostname; 00084 Gtk::TreeModelColumn<unsigned short int> m_service_port; 00085 Gtk::TreeModelColumn<Glib::ustring> m_image_id; 00086 Gtk::TreeModelColumn<unsigned int> m_image_width; 00087 Gtk::TreeModelColumn<unsigned int> m_image_height; 00088 Gtk::TreeModelColumn<Glib::ustring> m_image_colorspace; 00089 }; 00090 00091 typedef enum 00092 { 00093 SRC_NONE, 00094 SRC_FILE, 00095 SRC_SHM, 00096 SRC_FUSE 00097 } ImageSource; 00098 00099 typedef enum 00100 { 00101 MODE_VIEWER, 00102 MODE_COLOR_TRAIN, 00103 MODE_MIRROR_CALIB, 00104 MODE_MIRROR_CALIB_EVAL 00105 } OpMode; 00106 00107 Gtk::Widget* get_widget(Glib::RefPtr<Gnome::Glade::Xml> ref_xml, 00108 const char* widget_name) const; 00109 00110 void save_image(); 00111 void exit(); 00112 void close_camera(); 00113 void update_image(); 00114 bool call_update_image(); 00115 void enable_cont_img_trans(); 00116 void open_file(); 00117 void open_folder(); 00118 void open_shm(); 00119 void open_fuse(); 00120 void on_fuse_image_selected(); 00121 void on_colormap_updated(); 00122 bool image_click(GdkEventButton*); 00123 00124 void on_service_added( fawkes::NetworkService* service ); 00125 void on_service_removed( fawkes::NetworkService* service ); 00126 00127 void pre_open_img_src(); 00128 void post_open_img_src(); 00129 void resize_image(Gtk::Allocation& allocation); 00130 void draw_image(); 00131 00132 void ct_start(); 00133 firevision::hint_t ct_get_fg_object(); 00134 void ct_object_changed(); 00135 00136 void mc_start(); 00137 void mc_save(); 00138 void mc_load(); 00139 00140 Glib::Dispatcher m_update_img; 00141 00142 fawkes::AvahiDispatcher* m_avahi_dispatcher; 00143 00144 // widgets 00145 Gtk::Window* m_wnd_main; 00146 Gtk::Dialog* m_dlg_open_shm; 00147 Gtk::Dialog* m_dlg_open_fuse; 00148 Gtk::CheckButton* m_ckb_fuse_jpeg; 00149 Gtk::CheckButton* m_ckb_cont_trans; 00150 Gtk::SpinButton* m_spb_update_time; 00151 Gtk::FileChooserDialog* m_fcd_open_image; 00152 Gtk::FileChooserDialog* m_fcd_save_image; 00153 Gtk::ToolButton* m_tbtn_open_file; 00154 Gtk::ToolButton* m_tbtn_open_folder; 00155 Gtk::ToolButton* m_tbtn_open_shm; 00156 Gtk::ToolButton* m_tbtn_open_fuse; 00157 Gtk::ToolButton* m_tbtn_update; 00158 Gtk::ToolButton* m_tbtn_save; 00159 Gtk::ToolButton* m_tbtn_close_camera; 00160 Gtk::ToolButton* m_tbtn_exit; 00161 Gtk::Image* m_img_image; 00162 Gtk::EventBox* m_evt_image; 00163 Gtk::TreeView* m_trv_shm_image_ids; 00164 Gtk::TreeView* m_trv_fuse_services; 00165 Gtk::Statusbar* m_stb_status; 00166 00167 // color training widgets 00168 Gtk::ComboBox* m_cmb_ct_type; 00169 Gtk::ToggleButton* m_btn_ct_start; 00170 Gtk::ToggleButton* m_btn_ct_seg; 00171 Gtk::SpinButton* m_spbtn_depth; 00172 Gtk::SpinButton* m_spbtn_width; 00173 Gtk::SpinButton* m_spbtn_height; 00174 00175 // mirror calibration widgets 00176 Gtk::FileChooserDialog* m_fcd_mc_save; 00177 Gtk::FileChooserDialog* m_fcd_mc_load; 00178 Gtk::Button* m_btn_mc_start; 00179 Gtk::Button* m_btn_mc_load; 00180 Gtk::Button* m_btn_mc_save; 00181 Gtk::Entry* m_ent_mc_dist; 00182 Gtk::Entry* m_ent_mc_ori; 00183 00184 ShmColumnRecord m_shm_columns; 00185 Glib::RefPtr<Gtk::ListStore> m_shm_list_store; 00186 00187 FuseColumnRecord m_fuse_columns; 00188 Glib::RefPtr<Gtk::TreeStore> m_fuse_tree_store; 00189 00190 firevision::SharedMemoryImageBuffer* m_shm_buffer; 00191 firevision::Camera* m_camera; 00192 firevision::Writer* m_img_writer; 00193 00194 ImageSource m_img_src; 00195 OpMode m_op_mode; 00196 00197 // image buffer 00198 unsigned char* m_yuv_orig_buffer; 00199 unsigned char* m_yuv_draw_buffer; 00200 unsigned char* m_yuv_scaled_buffer; 00201 unsigned char* m_rgb_scaled_buffer; 00202 00203 unsigned int m_img_width; 00204 unsigned int m_img_height; 00205 unsigned int m_scaled_img_width; 00206 unsigned int m_scaled_img_height; 00207 unsigned int m_max_img_width; 00208 unsigned int m_max_img_height; 00209 00210 firevision::colorspace_t m_img_cs; 00211 size_t m_img_size; 00212 00213 bool m_cont_img_trans; 00214 00215 bool m_enable_scaling; 00216 float m_scale_factor; 00217 00218 MirrorCalibTool* m_calib_tool; 00219 ColorTrainWidget* m_ctw; 00220 FuseTransferWidget* m_ftw; 00221 firevision::FuseImageListWidget* m_filw; 00222 00223 fawkes::AvahiThread* m_avahi_thread; 00224 }; 00225 00226 #endif /* __FIREVISION_TOOLS_FIRESTATION_FIRESTATION_H_ */