comparison src/graphics.cc @ 10733:f72a761a784c

eliminate code duplication in reset_default_properties methods
author John W. Eaton <jwe@octave.org>
date Fri, 25 Jun 2010 07:22:45 -0400
parents 755fcb5baad3
children 91342260063e
comparison
equal deleted inserted replaced
10732:9d95d8ab7c3a 10733:f72a761a784c
2623 } 2623 }
2624 2624
2625 property_list 2625 property_list
2626 root_figure::factory_properties = root_figure::init_factory_properties (); 2626 root_figure::factory_properties = root_figure::init_factory_properties ();
2627 2627
2628 void 2628 static void
2629 root_figure::reset_default_properties (void) 2629 reset_default_properties (property_list& default_properties)
2630 { 2630 {
2631 property_list new_defaults; 2631 property_list new_defaults;
2632 2632
2633 for (property_list::plist_map_const_iterator p = default_properties.begin (); 2633 for (property_list::plist_map_const_iterator p = default_properties.begin ();
2634 p != default_properties.end (); p++) 2634 p != default_properties.end (); p++)
2648 || s == "windowstyle" 2648 || s == "windowstyle"
2649 || s == "paperunits")) 2649 || s == "paperunits"))
2650 new_defaults.set (prefix + s, q->second); 2650 new_defaults.set (prefix + s, q->second);
2651 } 2651 }
2652 } 2652 }
2653
2653 default_properties = new_defaults; 2654 default_properties = new_defaults;
2655 }
2656
2657 void
2658 root_figure::reset_default_properties (void)
2659 {
2660 ::reset_default_properties (default_properties);
2654 } 2661 }
2655 2662
2656 // --------------------------------------------------------------------- 2663 // ---------------------------------------------------------------------
2657 2664
2658 void 2665 void
2798 } 2805 }
2799 2806
2800 void 2807 void
2801 figure::reset_default_properties (void) 2808 figure::reset_default_properties (void)
2802 { 2809 {
2803 property_list new_defaults; 2810 ::reset_default_properties (default_properties);
2804
2805 for (property_list::plist_map_const_iterator p = default_properties.begin ();
2806 p != default_properties.end (); p++)
2807 {
2808 const property_list::pval_map_type pval_map = p->second;
2809 std::string prefix = p->first;
2810
2811 for (property_list::pval_map_const_iterator q = pval_map.begin ();
2812 q != pval_map.end ();
2813 q++)
2814 {
2815 std::string s = q->first;
2816
2817 if (prefix == "axes" && (s == "position" || s == "units"))
2818 new_defaults.set (prefix + s, q->second);
2819 else if (prefix == "figure" && (s == "position" || s == "units"
2820 || s == "windowstyle"
2821 || s == "paperunits"))
2822 new_defaults.set (prefix + s, q->second);
2823 }
2824 }
2825 default_properties = new_defaults;
2826 } 2811 }
2827 2812
2828 // --------------------------------------------------------------------- 2813 // ---------------------------------------------------------------------
2829 2814
2830 void 2815 void
4343 } 4328 }
4344 4329
4345 void 4330 void
4346 axes::reset_default_properties (void) 4331 axes::reset_default_properties (void)
4347 { 4332 {
4348 property_list new_defaults; 4333 ::reset_default_properties (default_properties);
4349
4350 for (property_list::plist_map_const_iterator p = default_properties.begin ();
4351 p != default_properties.end (); p++)
4352 {
4353 const property_list::pval_map_type pval_map = p->second;
4354 std::string prefix = p->first;
4355
4356 for (property_list::pval_map_const_iterator q = pval_map.begin ();
4357 q != pval_map.end ();
4358 q++)
4359 {
4360 std::string s = q->first;
4361
4362 if (prefix == "axes" && (s == "position" || s == "units"))
4363 new_defaults.set (prefix + s, q->second);
4364 else if (prefix == "figure" && (s == "position" || s == "units"
4365 || s == "windowstyle"
4366 || s == "paperunits"))
4367 new_defaults.set (prefix + s, q->second);
4368 }
4369 }
4370 default_properties = new_defaults;
4371 } 4334 }
4372 4335
4373 // --------------------------------------------------------------------- 4336 // ---------------------------------------------------------------------
4374 4337
4375 Matrix 4338 Matrix