comparison libinterp/corefcn/graphics.in.h @ 26982:8d7265e353a0 stable

Improve performance when closing figures (bug #55908). * graphics.cc (gh_manager::do_free): Don't execute remove_child when deleting from groot. * graphics.[cc,in.h] (delete_children, free): Add optional argument to indicate that an object is deleted from graphics root.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 16 Mar 2019 22:21:26 +0100
parents 3c7c5b7c3044
children 4313b3caa483 232102b1e920
comparison
equal deleted inserted replaced
26978:222f5ac853c8 26982:8d7265e353a0
1762 void delete_children (bool clear = false) 1762 void delete_children (bool clear = false)
1763 { 1763 {
1764 do_delete_children (clear); 1764 do_delete_children (clear);
1765 } 1765 }
1766 1766
1767 void delete_children (bool clear, bool from_root)
1768 {
1769 do_delete_children (clear, from_root);
1770 }
1771
1767 void renumber (graphics_handle old_gh, graphics_handle new_gh) 1772 void renumber (graphics_handle old_gh, graphics_handle new_gh)
1768 { 1773 {
1769 for (auto& hchild : children_list) 1774 for (auto& hchild : children_list)
1770 { 1775 {
1771 if (hchild == old_gh) 1776 if (hchild == old_gh)
1884 { 1889 {
1885 children_list.push_front (val); 1890 children_list.push_front (val);
1886 } 1891 }
1887 1892
1888 void do_delete_children (bool clear); 1893 void do_delete_children (bool clear);
1894
1895 void do_delete_children (bool clear, bool from_root);
1889 }; 1896 };
1890 1897
1891 // --------------------------------------------------------------------- 1898 // ---------------------------------------------------------------------
1892 1899
1893 class callback_property : public base_property 1900 class callback_property : public base_property
2241 children.run_listeners (); 2248 children.run_listeners ();
2242 mark_modified (); 2249 mark_modified ();
2243 } 2250 }
2244 } 2251 }
2245 2252
2253 virtual void remove_child (const graphics_handle& h, bool)
2254 {
2255 if (children.remove_child (h.value ()))
2256 {
2257 children.run_listeners ();
2258 mark_modified ();
2259 }
2260 }
2261
2246 virtual void adopt (const graphics_handle& h) 2262 virtual void adopt (const graphics_handle& h)
2247 { 2263 {
2248 children.adopt (h.value ()); 2264 children.adopt (h.value ());
2249 children.run_listeners (); 2265 children.run_listeners ();
2250 mark_modified (); 2266 mark_modified ();
2307 virtual void update_uicontextmenu (void) const; 2323 virtual void update_uicontextmenu (void) const;
2308 2324
2309 virtual void delete_children (bool clear = false) 2325 virtual void delete_children (bool clear = false)
2310 { 2326 {
2311 children.delete_children (clear); 2327 children.delete_children (clear);
2328 }
2329
2330 virtual void delete_children (bool clear, bool from_root)
2331 {
2332 children.delete_children (clear, from_root);
2312 } 2333 }
2313 2334
2314 void renumber_child (graphics_handle old_gh, graphics_handle new_gh) 2335 void renumber_child (graphics_handle old_gh, graphics_handle new_gh)
2315 { 2336 {
2316 children.renumber (old_gh, new_gh); 2337 children.renumber (old_gh, new_gh);
2544 error ("base_graphics_object::remove_child: invalid graphics object"); 2565 error ("base_graphics_object::remove_child: invalid graphics object");
2545 2566
2546 get_properties ().remove_child (h); 2567 get_properties ().remove_child (h);
2547 } 2568 }
2548 2569
2570 virtual void remove_child (const graphics_handle& h, bool from_root)
2571 {
2572 if (! valid_object ())
2573 error ("base_graphics_object::remove_child: invalid graphics object");
2574
2575 get_properties ().remove_child (h, from_root);
2576 }
2577
2549 virtual void adopt (const graphics_handle& h) 2578 virtual void adopt (const graphics_handle& h)
2550 { 2579 {
2551 if (! valid_object ()) 2580 if (! valid_object ())
2552 error ("base_graphics_object::adopt: invalid graphics object"); 2581 error ("base_graphics_object::adopt: invalid graphics object");
2553 2582
2891 2920
2892 class OCTINTERP_API properties : public base_properties 2921 class OCTINTERP_API properties : public base_properties
2893 { 2922 {
2894 public: 2923 public:
2895 void remove_child (const graphics_handle& h); 2924 void remove_child (const graphics_handle& h);
2925
2926 void remove_child (const graphics_handle& h, bool from_root);
2896 2927
2897 Matrix get_boundingbox (bool internal = false, 2928 Matrix get_boundingbox (bool internal = false,
2898 const Matrix& parent_pix_size = Matrix ()) const; 2929 const Matrix& parent_pix_size = Matrix ()) const;
2899 2930
2900 // See the genprops.awk script for an explanation of the 2931 // See the genprops.awk script for an explanation of the
3072 { 3103 {
3073 integerhandle = val; 3104 integerhandle = val;
3074 } 3105 }
3075 3106
3076 void remove_child (const graphics_handle& h); 3107 void remove_child (const graphics_handle& h);
3108
3109 void remove_child (const graphics_handle& h, bool from_root);
3077 3110
3078 void set_visible (const octave_value& val); 3111 void set_visible (const octave_value& val);
3079 3112
3080 graphics_toolkit get_toolkit (void) const; 3113 graphics_toolkit get_toolkit (void) const;
3081 3114
3408 public: 3441 public:
3409 void set_defaults (base_graphics_object& obj, const std::string& mode); 3442 void set_defaults (base_graphics_object& obj, const std::string& mode);
3410 3443
3411 void remove_child (const graphics_handle& h); 3444 void remove_child (const graphics_handle& h);
3412 3445
3446 void remove_child (const graphics_handle& h, bool from_root);
3447
3413 void adopt (const graphics_handle& h); 3448 void adopt (const graphics_handle& h);
3414 3449
3415 const scaler& get_x_scaler (void) const { return sx; } 3450 const scaler& get_x_scaler (void) const { return sx; }
3416 const scaler& get_y_scaler (void) const { return sy; } 3451 const scaler& get_y_scaler (void) const { return sy; }
3417 const scaler& get_z_scaler (void) const { return sz; } 3452 const scaler& get_z_scaler (void) const { return sz; }
3605 3640
3606 void set_text_child (handle_property& h, const std::string& who, 3641 void set_text_child (handle_property& h, const std::string& who,
3607 const octave_value& v); 3642 const octave_value& v);
3608 3643
3609 void delete_text_child (handle_property& h); 3644 void delete_text_child (handle_property& h);
3645
3646 void delete_text_child (handle_property& h, bool from_root);
3610 3647
3611 // See the genprops.awk script for an explanation of the 3648 // See the genprops.awk script for an explanation of the
3612 // properties declarations. 3649 // properties declarations.
3613 // Programming note: Keep property list sorted if new ones are added. 3650 // Programming note: Keep property list sorted if new ones are added.
3614 3651
5231 class OCTINTERP_API properties : public base_properties 5268 class OCTINTERP_API properties : public base_properties
5232 { 5269 {
5233 public: 5270 public:
5234 void remove_child (const graphics_handle& h); 5271 void remove_child (const graphics_handle& h);
5235 5272
5273 void remove_child (const graphics_handle& h, bool from_root);
5274
5236 void adopt (const graphics_handle& h); 5275 void adopt (const graphics_handle& h);
5237 5276
5238 // See the genprops.awk script for an explanation of the 5277 // See the genprops.awk script for an explanation of the
5239 // properties declarations. 5278 // properties declarations.
5240 // Programming note: Keep property list sorted if new ones are added. 5279 // Programming note: Keep property list sorted if new ones are added.
5306 { 5345 {
5307 public: 5346 public:
5308 void remove_child (const graphics_handle& h) 5347 void remove_child (const graphics_handle& h)
5309 { 5348 {
5310 base_properties::remove_child (h); 5349 base_properties::remove_child (h);
5350 }
5351
5352 void remove_child (const graphics_handle& h, bool from_root)
5353 {
5354 base_properties::remove_child (h, from_root);
5311 } 5355 }
5312 5356
5313 void adopt (const graphics_handle& h) 5357 void adopt (const graphics_handle& h)
5314 { 5358 {
5315 base_properties::adopt (h); 5359 base_properties::adopt (h);
6212 { 6256 {
6213 if (instance_ok ()) 6257 if (instance_ok ())
6214 instance->do_free (h); 6258 instance->do_free (h);
6215 } 6259 }
6216 6260
6261 static void free (const graphics_handle& h, bool from_root)
6262 {
6263 if (instance_ok ())
6264 instance->do_free (h, from_root);
6265 }
6266
6217 static void renumber_figure (const graphics_handle& old_gh, 6267 static void renumber_figure (const graphics_handle& old_gh,
6218 const graphics_handle& new_gh) 6268 const graphics_handle& new_gh)
6219 { 6269 {
6220 if (instance_ok ()) 6270 if (instance_ok ())
6221 instance->do_renumber_figure (old_gh, new_gh); 6271 instance->do_renumber_figure (old_gh, new_gh);
6463 6513
6464 graphics_handle do_get_handle (bool integer_figure_handle); 6514 graphics_handle do_get_handle (bool integer_figure_handle);
6465 6515
6466 void do_free (const graphics_handle& h); 6516 void do_free (const graphics_handle& h);
6467 6517
6518 void do_free (const graphics_handle& h, bool from_root);
6519
6468 void do_renumber_figure (const graphics_handle& old_gh, 6520 void do_renumber_figure (const graphics_handle& old_gh,
6469 const graphics_handle& new_gh); 6521 const graphics_handle& new_gh);
6470 6522
6471 graphics_handle do_lookup (double val) 6523 graphics_handle do_lookup (double val)
6472 { 6524 {