comparison src/graphics/fltk_backend/fltk_backend.cc @ 7840:2c8f693c32fd

convert_position not static anymore * * * the other part of convert_position -- added prototype to graphics.h * * * reverted convert_position to it's previous static state
author Shai Ayal <shaiay@sourceforge.net>
date Sat, 23 Feb 2008 21:10:08 +0200
parents 71eb1793f0db
children c643e5c520f5
comparison
equal deleted inserted replaced
7839:71eb1793f0db 7840:2c8f693c32fd
188 delete status; 188 delete status;
189 }; 189 };
190 190
191 double number () { return _number;}; 191 double number () { return _number;};
192 192
193 void mark_modified () { damage (FL_DAMAGE_ALL); } 193 void mark_modified ()
194 {
195 damage (FL_DAMAGE_ALL);
196 canvas->damage (FL_DAMAGE_ALL);
197 }
194 198
195 private: 199 private:
196 // figure number 200 // figure number
197 double _number; 201 double _number;
198 figure::properties err_props; 202 figure::properties err_props;
245 249
246 graphics_handle pixel2axes (int px, int py) { 250 graphics_handle pixel2axes (int px, int py) {
247 251
248 double x,y; 252 double x,y;
249 253
250 pixel2pos (px, py, x, y); 254 figure::properties fp = get_figure_props ();
251 255 Matrix children = fp.get_children ();
252 figure::properties pp = get_figure_props ();
253 Matrix children = (get_figure_props ()).get_children ();
254 for (octave_idx_type n = 0; n < children.numel (); n++) 256 for (octave_idx_type n = 0; n < children.numel (); n++)
255 { 257 {
256 graphics_object ax = gh_manager::get_object (children (n)); 258 graphics_object ax = gh_manager::get_object (children (n));
257 if (ax) 259 if (ax && ax.isa ("axes"))
258 { 260 {
259 if (ax.isa ("axes")) 261 axes::properties& ap =
260 { 262 dynamic_cast<axes::properties&> (ax.get_properties ());
261 axes::properties& props = 263 Matrix pixpos =
262 dynamic_cast<axes::properties&> (ax.get_properties ()); 264 convert_position (ap.get_position (). matrix_value (),
263 Matrix pos = props.get_position (). matrix_value (); 265 ap.get_units (),
264 266 "pixels" ,
265 if (x >= pos(0) && x <= pos(0) + pos(2) 267 fp.get_position ().matrix_value (),
266 && 268 fp.get_backend ());
267 y >= pos(1) && y <= pos(1) + pos(3) ) 269 std::cout << "\npixpos="<<pixpos<<"(px,py)=("<<px<<","<<py<<")\n";
268 return props.get___myhandle__ (); 270 if (px >= pixpos(0) && px <= pixpos(0) + pixpos(2)
269 } 271 &&
272 py >= pixpos(1) && py <= pixpos(1) + pixpos(3) )
273 return ap.get___myhandle__ ();
270 } 274 }
271 } 275 }
272 return graphics_handle (); 276 return graphics_handle ();
273 } 277 }
274 278
275 void pixel2status (int px, int py) { 279 void pixel2status (int px, int py) {
276 double x,y; 280 // std::stringstream cbuf;
277 std::stringstream cbuf; 281 // figure::properties fp = get_figure_props ();
278 282 // graphics_object obj = gh_manager::get_object (fp.get_currentaxes ());
279 pixel2pos (px, py, x, y); 283 // if (obj && obj.isa ("axes"))
280 cbuf << "[" << x << ", " << y <<"]"; 284 // {
281 status->value (cbuf.str ().c_str ()); 285 // axes::properties& ap =
282 status->redraw (); 286 // dynamic_cast<axes::properties&> (obj.get_properties ());
287
288 // Matrix pos(1,2,0);
289 // pos(0) = px;
290 // pos(1) = py;
291
292 // Matrix axpos =
293 // convert_position (pos,
294 // "pixels",
295 // ap.get_units () ,
296 // fp.get_position ().matrix_value (),
297 // fp.get_backend ());
298
299 // cbuf << "[" << axpos(0) << ", " << axpos(1) << "]";
300 // }
301 // else
302 // {
303 // cbuf << "[-, -]";
304 // }
305
306 // status->value (cbuf.str ().c_str ());
307 // status->redraw ();
283 } 308 }
284 309
285 void resize (int _x,int _y,int _w,int _h) 310 void resize (int _x,int _y,int _w,int _h)
286 { 311 {
287 Fl_Window::resize (_x, _y, _w, _h); 312 Fl_Window::resize (_x, _y, _w, _h);
353 in_drag = false; 378 in_drag = false;
354 } 379 }
355 // one click -- select axes 380 // one click -- select axes
356 else if ( Fl::event_clicks () == 0) 381 else if ( Fl::event_clicks () == 0)
357 { 382 {
383 std::cout << "ca="<< h0.value ()<<"\n";
358 if (h0.ok ()) 384 if (h0.ok ())
359 get_figure_props ().set_currentaxes (h0. value()); 385 get_figure_props ().set_currentaxes (h0.value());
360 return 1; 386 return 1;
361 } 387 }
362 } 388 }
363 break; 389 break;
364 } 390 }