comparison src/graphics.cc @ 10722:755fcb5baad3

Add the reset built function
author David Bateman <dbateman@free.fr>
date Wed, 23 Jun 2010 11:23:32 +0200
parents 9d4a198614ab
children f72a761a784c
comparison
equal deleted inserted replaced
10720:998d7ba68009 10722:755fcb5baad3
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
2629 root_figure::reset_default_properties (void)
2630 {
2631 property_list new_defaults;
2632
2633 for (property_list::plist_map_const_iterator p = default_properties.begin ();
2634 p != default_properties.end (); p++)
2635 {
2636 const property_list::pval_map_type pval_map = p->second;
2637 std::string prefix = p->first;
2638
2639 for (property_list::pval_map_const_iterator q = pval_map.begin ();
2640 q != pval_map.end ();
2641 q++)
2642 {
2643 std::string s = q->first;
2644
2645 if (prefix == "axes" && (s == "position" || s == "units"))
2646 new_defaults.set (prefix + s, q->second);
2647 else if (prefix == "figure" && (s == "position" || s == "units"
2648 || s == "windowstyle"
2649 || s == "paperunits"))
2650 new_defaults.set (prefix + s, q->second);
2651 }
2652 }
2653 default_properties = new_defaults;
2654 }
2655
2628 // --------------------------------------------------------------------- 2656 // ---------------------------------------------------------------------
2629 2657
2630 void 2658 void
2631 figure::properties::set_currentaxes (const octave_value& v) 2659 figure::properties::set_currentaxes (const octave_value& v)
2632 { 2660 {
2765 2793
2766 retval = parent_obj.get_default (name); 2794 retval = parent_obj.get_default (name);
2767 } 2795 }
2768 2796
2769 return retval; 2797 return retval;
2798 }
2799
2800 void
2801 figure::reset_default_properties (void)
2802 {
2803 property_list new_defaults;
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;
2770 } 2826 }
2771 2827
2772 // --------------------------------------------------------------------- 2828 // ---------------------------------------------------------------------
2773 2829
2774 void 2830 void
4284 zoom_stack.pop_front (); 4340 zoom_stack.pop_front ();
4285 4341
4286 unzoom (); 4342 unzoom ();
4287 } 4343 }
4288 4344
4345 void
4346 axes::reset_default_properties (void)
4347 {
4348 property_list new_defaults;
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 }
4372
4289 // --------------------------------------------------------------------- 4373 // ---------------------------------------------------------------------
4290 4374
4291 Matrix 4375 Matrix
4292 line::properties::compute_xlim (void) const 4376 line::properties::compute_xlim (void) const
4293 { 4377 {
5028 retval = is_handle (args(0)); 5112 retval = is_handle (args(0));
5029 else 5113 else
5030 print_usage (); 5114 print_usage ();
5031 5115
5032 return retval; 5116 return retval;
5117 }
5118
5119 DEFUN (reset, args, ,
5120 "-*- texinfo -*-\n\
5121 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\
5122 Removes any defaults set for the handle @var{h}. The default figure\n\
5123 properties \"position\", \"units\", \"windowstyle\" and\n\
5124 \"paperunits\" and the default axes properties \"position\" and \"units\"\n\
5125 are not reset.\n\
5126 @end deftypefn")
5127 {
5128 int nargin = args.length ();
5129
5130 if (nargin != 1)
5131 print_usage ();
5132 else
5133 {
5134 // get vector of graphics handles
5135 ColumnVector hcv (args(0).vector_value ());
5136
5137 if (! error_state)
5138 {
5139 // loop over graphics objects
5140 for (octave_idx_type n = 0; n < hcv.length (); n++)
5141 gh_manager::get_object (hcv(n)).reset_default_properties ();
5142 }
5143 }
5144
5145 return octave_value ();
5033 } 5146 }
5034 5147
5035 DEFUN (set, args, nargout, 5148 DEFUN (set, args, nargout,
5036 "-*- texinfo -*-\n\ 5149 "-*- texinfo -*-\n\
5037 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\ 5150 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\