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 <fvutils/base/roi.h> 00028 #include <fvutils/color/colorspaces.h> 00029 #include <netcomm/dns-sd/avahi_thread.h> 00030 00031 namespace firevision { 00032 class Camera; 00033 class SharedMemoryImageBuffer; 00034 class ShmImageLister; 00035 class Writer; 00036 class FuseImageListWidget; 00037 class MirrorCalibTool; 00038 } 00039 namespace fawkes { 00040 class AvahiDispatcher; 00041 } 00042 class ColorTrainTool; 00043 class ColorTrainWidget; 00044 class FuseTransferWidget; 00045 00046 class Firestation : public Gtk::Window 00047 { 00048 public: 00049 Firestation(Glib::RefPtr<Gtk::Builder> builder); 00050 virtual ~Firestation(); 00051 00052 Gtk::Window& get_window() const; 00053 00054 private: 00055 class ShmColumnRecord : public Gtk::TreeModel::ColumnRecord 00056 { 00057 public: 00058 ShmColumnRecord() 00059 { 00060 add(m_id); add(m_name); 00061 }; 00062 /// @cond INTERNALS 00063 Gtk::TreeModelColumn<int> m_id; 00064 Gtk::TreeModelColumn<Glib::ustring> m_name; 00065 /// @endcond 00066 }; 00067 00068 class FuseColumnRecord : public Gtk::TreeModel::ColumnRecord 00069 { 00070 public: 00071 FuseColumnRecord() 00072 { 00073 add(m_id); add(m_name); 00074 add(m_service_name); add(m_service_domain); 00075 add(m_service_hostname); add(m_service_port); 00076 add(m_image_id); add(m_image_width), add(m_image_height); 00077 add(m_image_colorspace); 00078 }; 00079 /// @cond INTERNALS 00080 Gtk::TreeModelColumn<int> m_id; 00081 Gtk::TreeModelColumn<Glib::ustring> m_name; 00082 Gtk::TreeModelColumn<Glib::ustring> m_service_name; 00083 Gtk::TreeModelColumn<Glib::ustring> m_service_type; 00084 Gtk::TreeModelColumn<Glib::ustring> m_service_domain; 00085 Gtk::TreeModelColumn<Glib::ustring> m_service_hostname; 00086 Gtk::TreeModelColumn<unsigned short int> m_service_port; 00087 Gtk::TreeModelColumn<Glib::ustring> m_image_id; 00088 Gtk::TreeModelColumn<unsigned int> m_image_width; 00089 Gtk::TreeModelColumn<unsigned int> m_image_height; 00090 Gtk::TreeModelColumn<Glib::ustring> m_image_colorspace; 00091 /// @endcond 00092 }; 00093 00094 typedef enum 00095 { 00096 SRC_NONE, 00097 SRC_FILE, 00098 SRC_SHM, 00099 SRC_FUSE 00100 } ImageSource; 00101 00102 typedef enum 00103 { 00104 MODE_VIEWER, 00105 MODE_COLOR_TRAIN, 00106 MODE_MIRROR_CALIB, 00107 MODE_MIRROR_CALIB_EVAL 00108 } OpMode; 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 double mc_line_angle_deg; 00137 void mc_load_mask(); 00138 void mc_set_center(); 00139 void mc_memorize(); 00140 void mc_simulate_clicks(); 00141 void mc_draw_line(); 00142 bool mc_on_line_angle_changed(Gtk::ScrollType scroll, double value); 00143 void mc_save(); 00144 void mc_load(); 00145 00146 Glib::Dispatcher m_update_img; 00147 00148 fawkes::AvahiDispatcher* m_avahi_dispatcher; 00149 00150 // widgets 00151 Gtk::Window* m_wnd_main; 00152 Gtk::Dialog* m_dlg_open_shm; 00153 Gtk::Dialog* m_dlg_open_fuse; 00154 Gtk::CheckButton* m_ckb_fuse_jpeg; 00155 Gtk::CheckButton* m_ckb_cont_trans; 00156 Gtk::SpinButton* m_spb_update_time; 00157 Gtk::FileChooserDialog* m_fcd_open_image; 00158 Gtk::FileChooserDialog* m_fcd_save_image; 00159 Gtk::ToolButton* m_tbtn_open_file; 00160 Gtk::ToolButton* m_tbtn_open_folder; 00161 Gtk::ToolButton* m_tbtn_open_shm; 00162 Gtk::ToolButton* m_tbtn_open_fuse; 00163 Gtk::ToolButton* m_tbtn_update; 00164 Gtk::ToolButton* m_tbtn_save; 00165 Gtk::ToolButton* m_tbtn_close_camera; 00166 Gtk::ToolButton* m_tbtn_exit; 00167 Gtk::Image* m_img_image; 00168 Gtk::EventBox* m_evt_image; 00169 Gtk::TreeView* m_trv_shm_image_ids; 00170 Gtk::TreeView* m_trv_fuse_services; 00171 Gtk::Statusbar* m_stb_status; 00172 00173 // color training widgets 00174 Gtk::ComboBox* m_cmb_ct_type; 00175 Gtk::ToggleButton* m_btn_ct_start; 00176 Gtk::ToggleButton* m_btn_ct_seg; 00177 Gtk::SpinButton* m_spbtn_depth; 00178 Gtk::SpinButton* m_spbtn_width; 00179 Gtk::SpinButton* m_spbtn_height; 00180 00181 // mirror calibration widgets 00182 Gtk::FileChooserDialog* m_fcd_mc_load_mask; 00183 Gtk::FileChooserDialog* m_fcd_mc_save; 00184 Gtk::FileChooserDialog* m_fcd_mc_load; 00185 Gtk::Button* m_btn_mc_load_mask; 00186 Gtk::ToggleButton* m_btn_mc_set_center; 00187 Gtk::Button* m_btn_mc_memorize; 00188 Gtk::Button* m_btn_mc_simulate_clicks; 00189 Gtk::Scale* m_scl_mc_line; 00190 Gtk::Button* m_btn_mc_load; 00191 Gtk::Button* m_btn_mc_save; 00192 Gtk::Entry* m_ent_mc_dist; 00193 Gtk::Entry* m_ent_mc_ori; 00194 00195 ShmColumnRecord m_shm_columns; 00196 Glib::RefPtr<Gtk::ListStore> m_shm_list_store; 00197 00198 FuseColumnRecord m_fuse_columns; 00199 Glib::RefPtr<Gtk::TreeStore> m_fuse_tree_store; 00200 00201 firevision::SharedMemoryImageBuffer* m_shm_buffer; 00202 firevision::Camera* m_camera; 00203 firevision::Writer* m_img_writer; 00204 00205 ImageSource m_img_src; 00206 OpMode m_op_mode; 00207 00208 // image buffer 00209 unsigned char* m_yuv_orig_buffer; 00210 unsigned char* m_yuv_draw_buffer; 00211 unsigned char* m_yuv_scaled_buffer; 00212 unsigned char* m_rgb_scaled_buffer; 00213 00214 unsigned int m_img_width; 00215 unsigned int m_img_height; 00216 unsigned int m_scaled_img_width; 00217 unsigned int m_scaled_img_height; 00218 unsigned int m_max_img_width; 00219 unsigned int m_max_img_height; 00220 00221 firevision::colorspace_t m_img_cs; 00222 size_t m_img_size; 00223 00224 bool m_cont_img_trans; 00225 00226 bool m_enable_scaling; 00227 float m_scale_factor; 00228 00229 #ifdef HAVE_MIRROR_CALIB 00230 firevision::MirrorCalibTool* m_calib_tool; 00231 #endif 00232 ColorTrainWidget* m_ctw; 00233 FuseTransferWidget* m_ftw; 00234 firevision::FuseImageListWidget* m_filw; 00235 00236 fawkes::AvahiThread* m_avahi_thread; 00237 }; 00238 00239 #endif /* __FIREVISION_TOOLS_FIRESTATION_FIRESTATION_H_ */