comparison src/graphics.h.in @ 7826:68550ad9ee9c

Add support for extern updaters. Add set_figure_position interface to graphics_backend.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 12 Feb 2008 16:37:56 +0100
parents adb520646d7e
children 3584f37eac69
comparison
equal deleted inserted replaced
7825:13871b7de124 7826:68550ad9ee9c
1160 std::string get_name (void) const { return name; } 1160 std::string get_name (void) const { return name; }
1161 1161
1162 virtual bool is_valid (void) const { return false; } 1162 virtual bool is_valid (void) const { return false; }
1163 1163
1164 virtual void close_figure (const octave_value&) const 1164 virtual void close_figure (const octave_value&) const
1165 { error ("close_figure: invalid graphics backend"); } 1165 { gripe_invalid ("close_figure"); }
1166 1166
1167 virtual void redraw_figure (const graphics_handle&) const 1167 virtual void redraw_figure (const graphics_handle&) const
1168 { error ("redraw_figure: invalid graphics backend"); } 1168 { gripe_invalid ("redraw_figure"); }
1169 1169
1170 virtual void print_figure (const graphics_handle&, const std::string&, 1170 virtual void print_figure (const graphics_handle&, const std::string&,
1171 const std::string&, bool, 1171 const std::string&, bool,
1172 const std::string& = "") const 1172 const std::string& = "") const
1173 { error ("print_figure: invalid graphics backend"); } 1173 { gripe_invalid ("print_figure"); }
1174 1174
1175 virtual Matrix get_canvas_size (const graphics_handle&) const 1175 virtual Matrix get_canvas_size (const graphics_handle&) const
1176 { 1176 {
1177 error ("get_canvas_size: invalid graphics backend"); 1177 gripe_invalid ("get_canvas_size");
1178 return Matrix (1, 2, 0.0); 1178 return Matrix (1, 2, 0.0);
1179 } 1179 }
1180 1180
1181 virtual double get_screen_resolution (void) const 1181 virtual double get_screen_resolution (void) const
1182 { 1182 {
1183 error ("get_screen_resolution: invalid graphics backend"); 1183 gripe_invalid ("get_screen_resolution");
1184 return -1; 1184 return 72.0;
1185 } 1185 }
1186 1186
1187 virtual Matrix get_screen_size (void) const 1187 virtual Matrix get_screen_size (void) const
1188 { 1188 {
1189 error ("get_screen_size: invalid graphics backend"); 1189 gripe_invalid ("get_screen_size");
1190 return Matrix (1, 2, 0.0); 1190 return Matrix (1, 2, 0.0);
1191 } 1191 }
1192
1193 virtual void set_figure_position (const graphics_handle&, const Matrix&) const
1194 { gripe_invalid ("set_figure_position"); }
1192 1195
1193 private: 1196 private:
1194 std::string name; 1197 std::string name;
1195 int count; 1198 int count;
1199
1200 private:
1201 void gripe_invalid (const std::string& fname) const
1202 {
1203 if (! is_valid ())
1204 error ("%s: invalid graphics backend", fname.c_str ());
1205 }
1196 }; 1206 };
1197 1207
1198 class graphics_backend 1208 class graphics_backend
1199 { 1209 {
1200 public: 1210 public:
1257 double get_screen_resolution (void) const 1267 double get_screen_resolution (void) const
1258 { return rep->get_screen_resolution (); } 1268 { return rep->get_screen_resolution (); }
1259 1269
1260 Matrix get_screen_size (void) const 1270 Matrix get_screen_size (void) const
1261 { return rep->get_screen_size (); } 1271 { return rep->get_screen_size (); }
1272
1273 void set_figure_position (const graphics_handle& h, const Matrix& pos) const
1274 { rep->set_figure_position (h, pos); }
1262 1275
1263 OCTINTERP_API static graphics_backend default_backend (void); 1276 OCTINTERP_API static graphics_backend default_backend (void);
1264 1277
1265 static void register_backend (const graphics_backend& b) 1278 static void register_backend (const graphics_backend& b)
1266 { available_backends[b.get_name ()] = b; } 1279 { available_backends[b.get_name ()] = b; }
2146 error ("__backend__ must be a string"); 2159 error ("__backend__ must be a string");
2147 } 2160 }
2148 } 2161 }
2149 2162
2150 Matrix get_boundingbox (bool internal = false) const; 2163 Matrix get_boundingbox (bool internal = false) const;
2164
2165 void update_position (void)
2166 { backend.set_figure_position (__myhandle__, get_boundingbox ()); }
2151 2167
2152 // See the genprops.awk script for an explanation of the 2168 // See the genprops.awk script for an explanation of the
2153 // properties declarations. 2169 // properties declarations.
2154 2170
2155 BEGIN_PROPERTIES(figure) 2171 BEGIN_PROPERTIES(figure)
2182 array_property papersize r , Matrix (1, 4, 0) 2198 array_property papersize r , Matrix (1, 4, 0)
2183 radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid" 2199 radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid"
2184 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand" 2200 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand"
2185 array_property pointershapecdata , Matrix (16, 16, 0) 2201 array_property pointershapecdata , Matrix (16, 16, 0)
2186 array_property pointershapehotspot , Matrix (1, 2, 0) 2202 array_property pointershapehotspot , Matrix (1, 2, 0)
2187 array_property position , default_figure_position () 2203 array_property position u , default_figure_position ()
2188 radio_property renderer , "{painters}|zbuffer|opengl|none" 2204 radio_property renderer , "{painters}|zbuffer|opengl|none"
2189 radio_property renderermode , "{auto}|manual" 2205 radio_property renderermode , "{auto}|manual"
2190 bool_property resize , "on" 2206 bool_property resize , "on"
2191 callback_property resizefcn , Matrix () 2207 callback_property resizefcn , Matrix ()
2192 radio_property selectiontype , "{normal}|open|alt|extend" 2208 radio_property selectiontype , "{normal}|open|alt|extend"