comparison src/graphics.cc @ 8196:32e9e8103390

Allow arrays of graphic handles to F__go_delete__
author David Bateman <dbateman@free.fr>
date Wed, 08 Oct 2008 11:29:27 -0400
parents 277218396978
children f6ca8ff51818
comparison
equal deleted inserted replaced
8195:ec3a55bd876b 8196:32e9e8103390
4417 4417
4418 if (args.length () == 1) 4418 if (args.length () == 1)
4419 { 4419 {
4420 graphics_handle h = octave_NaN; 4420 graphics_handle h = octave_NaN;
4421 4421
4422 double val = args(0).double_value (); 4422 const NDArray vals = args (0).array_value ();
4423 4423
4424 if (! error_state) 4424 if (! error_state)
4425 { 4425 {
4426 h = gh_manager::lookup (val); 4426 for (octave_idx_type i = 0; i < vals.numel (); i++)
4427 4427 {
4428 if (h.ok ()) 4428 h = gh_manager::lookup (vals.elem (i));
4429 { 4429
4430 graphics_object obj = gh_manager::get_object (h); 4430 if (h.ok ())
4431 4431 {
4432 graphics_handle parent_h = obj.get_parent (); 4432 graphics_object obj = gh_manager::get_object (h);
4433 4433
4434 graphics_object parent_obj = gh_manager::get_object (parent_h); 4434 graphics_handle parent_h = obj.get_parent ();
4435 4435
4436 // NOTE: free the handle before removing it from its parent's 4436 graphics_object parent_obj =
4437 // children, such that the object's state is correct when 4437 gh_manager::get_object (parent_h);
4438 // the deletefcn callback is executed 4438
4439 4439 // NOTE: free the handle before removing it from its parent's
4440 gh_manager::free (h); 4440 // children, such that the object's state is correct
4441 4441 // when the deletefcn callback is executed
4442 parent_obj.remove_child (h); 4442
4443 4443 gh_manager::free (h);
4444 Vdrawnow_requested = true; 4444
4445 } 4445 parent_obj.remove_child (h);
4446 else 4446
4447 error ("delete: invalid graphics object (= %g)", val); 4447 Vdrawnow_requested = true;
4448 }
4449 else
4450 {
4451 error ("delete: invalid graphics object (= %g)",
4452 vals.elem (i));
4453 break;
4454 }
4455 }
4448 } 4456 }
4449 else 4457 else
4450 error ("delete: invalid graphics object"); 4458 error ("delete: invalid graphics object");
4451 } 4459 }
4452 else 4460 else