Go to the documentation of this file.00001
00002 #ifndef bgui_image_tableau_h_
00003 #define bgui_image_tableau_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "bgui_image_tableau_sptr.h"
00020 #include <vgui/vgui_image_tableau.h>
00021 #include <vgui/vgui_range_map_params_sptr.h>
00022 #include <vil/vil_image_resource.h>
00023 #include <vil/vil_image_view_base.h>
00024 #include <vgui/vgui_text_tableau.h>
00025 #include <vil1/vil1_image.h>
00026 #include <vgui/vgui_gl.h>
00027
00028 class bgui_image_tableau_vp_sc_snapshot
00029 {
00030 public:
00031 GLint vp[4];
00032 GLint sc[4];
00033 bool sc_was_enabled;
00034
00035 bgui_image_tableau_vp_sc_snapshot() {
00036 glGetIntegerv(GL_VIEWPORT, vp);
00037
00038
00039 glGetIntegerv(GL_SCISSOR_BOX, sc);
00040 sc_was_enabled = glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE;
00041 }
00042
00043 ~bgui_image_tableau_vp_sc_snapshot() {
00044
00045 glViewport(vp[0], vp[1], vp[2], vp[3]);
00046
00047
00048
00049 if (sc_was_enabled)
00050 glEnable(GL_SCISSOR_TEST);
00051 else
00052 glDisable(GL_SCISSOR_TEST);
00053 glScissor(sc[0], sc[1], sc[2], sc[3]);
00054 }
00055 };
00056
00057 class bgui_image_tableau : public vgui_image_tableau
00058 {
00059 public:
00060 typedef vgui_image_tableau base;
00061
00062 bgui_image_tableau();
00063
00064 bgui_image_tableau(vil_image_resource_sptr const & img,
00065 vgui_range_map_params_sptr const & rmp = 0);
00066
00067 bgui_image_tableau( vil_image_view_base const & img,
00068 vgui_range_map_params_sptr const & rmp = 0);
00069
00070 bgui_image_tableau(vil1_image const & img,
00071 vgui_range_map_params_sptr const & rmp = 0);
00072
00073 bgui_image_tableau(char const* filename,
00074 vgui_range_map_params_sptr const & rmp = 0);
00075
00076
00077 vcl_string type_name() const { return "vgui_image_tableau"; }
00078
00079
00080 vil1_image get_image() const;
00081
00082
00083 vil_image_resource_sptr get_image_resource() const;
00084
00085
00086 void image_line(const float col_start,
00087 const float row_start,
00088 const float col_end,
00089 const float row_end,
00090 vcl_vector<double>& line_pos,
00091 vcl_vector<double>& vals);
00092
00093
00094 void image_line(const float col_start,
00095 const float row_start,
00096 const float col_end,
00097 const float row_end,
00098 vcl_vector<double>& line_pos,
00099 vcl_vector<vcl_vector<double> >& vals);
00100
00101
00102 void set_handle_motion() { handle_motion_ = true; }
00103 void unset_handle_motion() { handle_motion_ = false; }
00104
00105 bool handle_motion() const { return handle_motion_; }
00106
00107
00108 void lock_linenum(bool b) { locked_ = b; handle_motion_=!b; }
00109 void show_image_path(bool show){show_path_ = show;}
00110 vgui_text_tableau_sptr text_tab(){return tt_;}
00111 protected:
00112
00113 bool handle(vgui_event const &e);
00114
00115
00116 double get_pixel_value(const unsigned c, const unsigned r);
00117
00118
00119 vcl_vector<double> get_color_pixel_value(const unsigned c, const unsigned r);
00120
00121
00122 void get_pixel_info_from_frame_buffer(const int x, const int y,
00123 vgui_event const &e, char* msg);
00124
00125
00126 void get_pixel_info_from_image(const int x, const int y,
00127 vgui_event const &e, char* msg);
00128
00129
00130 bool handle_motion_;
00131
00132 bool locked_;
00133 bool show_path_;
00134 vgui_text_tableau_sptr tt_;
00135 };
00136
00137
00138 struct bgui_image_tableau_new : public bgui_image_tableau_sptr {
00139
00140
00141 bgui_image_tableau_new()
00142 : bgui_image_tableau_sptr( new bgui_image_tableau() )
00143 { }
00144
00145
00146
00147 bgui_image_tableau_new(vil_image_resource_sptr const & img,
00148 vgui_range_map_params_sptr const & rmp = 0)
00149 : bgui_image_tableau_sptr( new bgui_image_tableau(img, rmp) )
00150 { }
00151
00152 bgui_image_tableau_new(vil_image_view_base const & img,
00153 vgui_range_map_params_sptr const & rmp = 0)
00154 : bgui_image_tableau_sptr( new bgui_image_tableau(img, rmp) )
00155 { }
00156
00157 bgui_image_tableau_new(vil1_image const & img,
00158 vgui_range_map_params_sptr const & rmp = 0)
00159 : bgui_image_tableau_sptr( new bgui_image_tableau(img, rmp) )
00160 { }
00161
00162 bgui_image_tableau_new(char const* filename,
00163 vgui_range_map_params_sptr const & rmp = 0)
00164 : bgui_image_tableau_sptr( new bgui_image_tableau(filename, rmp) )
00165 { }
00166
00167
00168 operator vgui_image_tableau_sptr () const
00169 { vgui_image_tableau_sptr tt; tt.vertical_cast(*this); return tt; }
00170 };
00171
00172 #endif // bgui_image_tableau_h_