comparison src/graphics.cc @ 7370:74d64ead0cd7

[project @ 2008-01-14 19:12:45 by jwe]
author jwe
date Mon, 14 Jan 2008 19:14:26 +0000
parents 600808df131c
children f350da755600
comparison
equal deleted inserted replaced
7369:39160daffccb 7370:74d64ead0cd7
811 is_figure (double val) 811 is_figure (double val)
812 { 812 {
813 graphics_object obj = gh_manager::get_object (val); 813 graphics_object obj = gh_manager::get_object (val);
814 814
815 return obj && obj.isa ("figure"); 815 return obj && obj.isa ("figure");
816 }
817
818 static void
819 xcreatefcn (const graphics_handle& h)
820 {
821 graphics_object obj = gh_manager::get_object (h);
822 obj.get_properties ().execute_createfcn ();
816 } 823 }
817 824
818 // --------------------------------------------------------------------- 825 // ---------------------------------------------------------------------
819 826
820 static int 827 static int
1738 handle_map[0] = graphics_object (new root_figure ()); 1745 handle_map[0] = graphics_object (new root_figure ());
1739 } 1746 }
1740 1747
1741 graphics_handle 1748 graphics_handle
1742 gh_manager::do_make_graphics_handle (const std::string& go_name, 1749 gh_manager::do_make_graphics_handle (const std::string& go_name,
1743 const graphics_handle& p) 1750 const graphics_handle& p, bool do_createfcn)
1744 { 1751 {
1745 graphics_handle h = get_handle (go_name); 1752 graphics_handle h = get_handle (go_name);
1746 1753
1747 base_graphics_object *go = 0; 1754 base_graphics_object *go = 0;
1748 1755
1759 else if (go_name == "patch") 1766 else if (go_name == "patch")
1760 go = new patch (h, p); 1767 go = new patch (h, p);
1761 else if (go_name == "surface") 1768 else if (go_name == "surface")
1762 go = new surface (h, p); 1769 go = new surface (h, p);
1763 if (go) 1770 if (go)
1764 handle_map[h] = graphics_object (go); 1771 {
1772 handle_map[h] = graphics_object (go);
1773 if (do_createfcn)
1774 go->get_properties ().execute_createfcn ();
1775 }
1765 else 1776 else
1766 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", 1777 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'",
1767 go_name.c_str ()); 1778 go_name.c_str ());
1768 1779
1769 return h; 1780 return h;
1968 graphics_handle parent = gh_manager::lookup (val); 1979 graphics_handle parent = gh_manager::lookup (val);
1969 1980
1970 if (parent.ok ()) 1981 if (parent.ok ())
1971 { 1982 {
1972 graphics_handle h 1983 graphics_handle h
1973 = gh_manager::make_graphics_handle (go_name, parent); 1984 = gh_manager::make_graphics_handle (go_name, parent, false);
1974 1985
1975 if (! error_state) 1986 if (! error_state)
1976 { 1987 {
1977 adopt (parent, h); 1988 adopt (parent, h);
1978 1989
1979 xset (h, args.splice (0, 1)); 1990 xset (h, args.splice (0, 1));
1991 xcreatefcn (h);
1980 1992
1981 retval = h.value (); 1993 retval = h.value ();
1982 1994
1983 if (! error_state) 1995 if (! error_state)
1984 feval ("__request_drawnow__"); 1996 feval ("__request_drawnow__");
2021 else 2033 else
2022 { 2034 {
2023 graphics_handle h = octave_NaN; 2035 graphics_handle h = octave_NaN;
2024 2036
2025 if (xisnan (val)) 2037 if (xisnan (val))
2026 h = gh_manager::make_graphics_handle ("figure", 0); 2038 h = gh_manager::make_graphics_handle ("figure", 0, false);
2027 else if (val > 0 && D_NINT (val) == val) 2039 else if (val > 0 && D_NINT (val) == val)
2028 h = gh_manager::make_figure_handle (val); 2040 h = gh_manager::make_figure_handle (val);
2029 else 2041 else
2030 error ("__go_figure__: invalid figure number"); 2042 error ("__go_figure__: invalid figure number");
2031 2043
2032 if (! error_state && h.ok ()) 2044 if (! error_state && h.ok ())
2033 { 2045 {
2034 adopt (0, h); 2046 adopt (0, h);
2035 2047
2036 xset (h, args.splice (0, 1)); 2048 xset (h, args.splice (0, 1));
2049 xcreatefcn (h);
2037 2050
2038 retval = h.value (); 2051 retval = h.value ();
2039 } 2052 }
2040 else 2053 else
2041 error ("__go_figure__: failed to create figure handle"); 2054 error ("__go_figure__: failed to create figure handle");