comparison src/graphics.cc @ 6807:0089a504fdd6

[project @ 2007-08-10 17:34:59 by jwe]
author jwe
date Fri, 10 Aug 2007 17:34:59 +0000
parents f1157da78825
children 5e61f0bc0c27
comparison
equal deleted inserted replaced
6806:afa9123c5faa 6807:0089a504fdd6
243 offset = 4; 243 offset = 4;
244 else if (len > 5) 244 else if (len > 5)
245 { 245 {
246 pfx = name.substr (0, 5); 246 pfx = name.substr (0, 5);
247 247
248 if (pfx.compare ("image")) 248 if (pfx.compare ("image") || pfx.compare ("patch"))
249 offset = 5; 249 offset = 5;
250 else if (len > 6) 250 else if (len > 6)
251 { 251 {
252 pfx = name.substr (0, 6); 252 pfx = name.substr (0, 6);
253 253
316 offset = 4; 316 offset = 4;
317 else if (len > 5) 317 else if (len > 5)
318 { 318 {
319 pfx = name.substr (0, 5); 319 pfx = name.substr (0, 5);
320 320
321 if (pfx.compare ("image")) 321 if (pfx.compare ("image") || pfx.compare ("patch"))
322 offset = 5; 322 offset = 5;
323 else if (len > 6) 323 else if (len > 6)
324 { 324 {
325 pfx = name.substr (0, 6); 325 pfx = name.substr (0, 6);
326 326
943 dataaspectratio (Matrix (1, 3, 1.0)), 943 dataaspectratio (Matrix (1, 3, 1.0)),
944 dataaspectratiomode ("auto"), 944 dataaspectratiomode ("auto"),
945 xlim (), 945 xlim (),
946 ylim (), 946 ylim (),
947 zlim (), 947 zlim (),
948 clim (),
948 xlimmode ("auto"), 949 xlimmode ("auto"),
949 ylimmode ("auto"), 950 ylimmode ("auto"),
950 zlimmode ("auto"), 951 zlimmode ("auto"),
952 climmode ("auto"),
951 xlabel (octave_NaN), 953 xlabel (octave_NaN),
952 ylabel (octave_NaN), 954 ylabel (octave_NaN),
953 zlabel (octave_NaN), 955 zlabel (octave_NaN),
954 xgrid ("off"), 956 xgrid ("off"),
955 ygrid ("off"), 957 ygrid ("off"),
983 Matrix tlim (1, 2, 0.0); 985 Matrix tlim (1, 2, 0.0);
984 tlim(1) = 1; 986 tlim(1) = 1;
985 xlim = tlim; 987 xlim = tlim;
986 ylim = tlim; 988 ylim = tlim;
987 zlim = tlim; 989 zlim = tlim;
990 Matrix cl (1, 2, 0);
991 cl(1) = 1;
992 clim = cl;
988 993
989 Matrix tview (1, 2, 0.0); 994 Matrix tview (1, 2, 0.0);
990 tview(1) = 90; 995 tview(1) = 90;
991 view = tview; 996 view = tview;
992 997
1052 else if (name.compare ("zlim")) 1057 else if (name.compare ("zlim"))
1053 { 1058 {
1054 zlim = val; 1059 zlim = val;
1055 zlimmode = "manual"; 1060 zlimmode = "manual";
1056 } 1061 }
1062 else if (name.compare ("clim"))
1063 {
1064 clim = val;
1065 climmode = "manual";
1066 }
1057 else if (name.compare ("xlimmode")) 1067 else if (name.compare ("xlimmode"))
1058 xlimmode = val; 1068 xlimmode = val;
1059 else if (name.compare ("ylimmode")) 1069 else if (name.compare ("ylimmode"))
1060 ylimmode = val; 1070 ylimmode = val;
1061 else if (name.compare ("zlimmode")) 1071 else if (name.compare ("zlimmode"))
1062 zlimmode = val; 1072 zlimmode = val;
1073 else if (name.compare ("climmode"))
1074 climmode = val;
1063 else if (name.compare ("xlabel")) 1075 else if (name.compare ("xlabel"))
1064 { 1076 {
1065 graphics_handle h = ::reparent (val, "set", "xlabel", 1077 graphics_handle h = ::reparent (val, "set", "xlabel",
1066 __myhandle__, false); 1078 __myhandle__, false);
1067 if (! error_state) 1079 if (! error_state)
1196 Matrix tlim (1, 2, 0.0); 1208 Matrix tlim (1, 2, 0.0);
1197 tlim(1) = 1; 1209 tlim(1) = 1;
1198 xlim = tlim; 1210 xlim = tlim;
1199 ylim = tlim; 1211 ylim = tlim;
1200 zlim = tlim; 1212 zlim = tlim;
1201 1213
1214 Matrix cl (1, 2, 0);
1215 cl(1) = 1;
1216 clim = cl;
1217
1202 xlimmode = "auto"; 1218 xlimmode = "auto";
1203 ylimmode = "auto"; 1219 ylimmode = "auto";
1204 zlimmode = "auto"; 1220 zlimmode = "auto";
1221 climmode = "auto";
1205 xlabel = octave_NaN; 1222 xlabel = octave_NaN;
1206 ylabel = octave_NaN; 1223 ylabel = octave_NaN;
1207 zlabel = octave_NaN; 1224 zlabel = octave_NaN;
1208 xgrid = "off"; 1225 xgrid = "off";
1209 ygrid = "off"; 1226 ygrid = "off";
1285 m.assign ("dataaspectratio", dataaspectratio); 1302 m.assign ("dataaspectratio", dataaspectratio);
1286 m.assign ("dataaspectratiomode", dataaspectratiomode); 1303 m.assign ("dataaspectratiomode", dataaspectratiomode);
1287 m.assign ("xlim", xlim); 1304 m.assign ("xlim", xlim);
1288 m.assign ("ylim", ylim); 1305 m.assign ("ylim", ylim);
1289 m.assign ("zlim", zlim); 1306 m.assign ("zlim", zlim);
1307 m.assign ("clim", clim);
1290 m.assign ("xlimmode", xlimmode); 1308 m.assign ("xlimmode", xlimmode);
1291 m.assign ("ylimmode", ylimmode); 1309 m.assign ("ylimmode", ylimmode);
1292 m.assign ("zlimmode", zlimmode); 1310 m.assign ("zlimmode", zlimmode);
1311 m.assign ("climmode", climmode);
1293 m.assign ("xlabel", xlabel); 1312 m.assign ("xlabel", xlabel);
1294 m.assign ("ylabel", ylabel); 1313 m.assign ("ylabel", ylabel);
1295 m.assign ("zlabel", zlabel); 1314 m.assign ("zlabel", zlabel);
1296 m.assign ("xgrid", xgrid); 1315 m.assign ("xgrid", xgrid);
1297 m.assign ("ygrid", ygrid); 1316 m.assign ("ygrid", ygrid);
1363 retval = xlim; 1382 retval = xlim;
1364 else if (name.compare ("ylim")) 1383 else if (name.compare ("ylim"))
1365 retval = ylim; 1384 retval = ylim;
1366 else if (name.compare ("zlim")) 1385 else if (name.compare ("zlim"))
1367 retval = zlim; 1386 retval = zlim;
1387 else if (name.compare ("clim"))
1388 retval = clim;
1368 else if (name.compare ("xlimmode")) 1389 else if (name.compare ("xlimmode"))
1369 retval = xlimmode; 1390 retval = xlimmode;
1370 else if (name.compare ("ylimmode")) 1391 else if (name.compare ("ylimmode"))
1371 retval = ylimmode; 1392 retval = ylimmode;
1372 else if (name.compare ("zlimmode")) 1393 else if (name.compare ("zlimmode"))
1373 retval = zlimmode; 1394 retval = zlimmode;
1395 else if (name.compare ("climmode"))
1396 retval = climmode;
1374 else if (name.compare ("xlabel")) 1397 else if (name.compare ("xlabel"))
1375 { 1398 {
1376 if (xisnan (xlabel)) 1399 if (xisnan (xlabel))
1377 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); 1400 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
1378 1401
1504 tlim(1) = 1; 1527 tlim(1) = 1;
1505 1528
1506 m["xlim"] = tlim; 1529 m["xlim"] = tlim;
1507 m["ylim"] = tlim; 1530 m["ylim"] = tlim;
1508 m["zlim"] = tlim; 1531 m["zlim"] = tlim;
1532
1533 Matrix cl(1, 2, 0);
1534 cl(1) = 1;
1535
1536 m["clim"] = cl;
1509 1537
1510 m["xlimmode"] = "auto"; 1538 m["xlimmode"] = "auto";
1511 m["ylimmode"] = "auto"; 1539 m["ylimmode"] = "auto";
1512 m["zlimmode"] = "auto"; 1540 m["zlimmode"] = "auto";
1541 m["climmode"] = "auto";
1513 m["xlabel"] = octave_NaN; 1542 m["xlabel"] = octave_NaN;
1514 m["ylabel"] = octave_NaN; 1543 m["ylabel"] = octave_NaN;
1515 m["zlabel"] = octave_NaN; 1544 m["zlabel"] = octave_NaN;
1516 m["xgrid"] = "off"; 1545 m["xgrid"] = "off";
1517 m["ygrid"] = "off"; 1546 m["ygrid"] = "off";
1950 1979
1951 std::string image::image_properties::go_name ("image"); 1980 std::string image::image_properties::go_name ("image");
1952 1981
1953 // --------------------------------------------------------------------- 1982 // ---------------------------------------------------------------------
1954 1983
1984 patch::patch_properties::patch_properties (const graphics_handle& mh,
1985 const graphics_handle& p)
1986 : base_properties (go_name, mh, p),
1987 cdata (Matrix ()),
1988 xdata (Matrix ()),
1989 ydata (Matrix ()),
1990 zdata (Matrix ()),
1991 facecolor (radio_values("{flat}|none|interp")),
1992 facealpha (1.0),
1993 edgecolor (color_values(0, 0, 0), radio_values("flat|none|interp")),
1994 linestyle ("-"),
1995 linewidth (0.5),
1996 marker ("none"),
1997 markeredgecolor ("auto"),
1998 markerfacecolor ("none"),
1999 markersize (1)
2000 { }
2001
2002 void
2003 patch::patch_properties::set (const property_name& name,
2004 const octave_value& val)
2005 {
2006 bool modified = true;
2007
2008 if (name.compare ("parent"))
2009 set_parent (val);
2010 else if (name.compare ("children"))
2011 children = maybe_set_children (children, val);
2012 else if (name.compare ("__modified__"))
2013 {
2014 __modified__ = val.bool_value ();
2015 modified = false;
2016 }
2017 else if (name.compare ("cdata"))
2018 cdata = val;
2019 else if (name.compare ("xdata"))
2020 xdata = val;
2021 else if (name.compare ("ydata"))
2022 ydata = val;
2023 else if (name.compare ("zdata"))
2024 zdata = val;
2025 else if (name.compare ("facecolor"))
2026 facecolor = val;
2027 else if (name.compare ("facealpha"))
2028 facealpha = val;
2029 else if (name.compare ("edgecolor"))
2030 edgecolor = val;
2031 else if (name.compare ("linestyle"))
2032 linestyle = val;
2033 else if (name.compare ("linewidth"))
2034 linewidth = val;
2035 else if (name.compare ("marker"))
2036 marker = val;
2037 else if (name.compare ("markeredgecolor"))
2038 markeredgecolor = val;
2039 else if (name.compare ("markerfacecolor"))
2040 markerfacecolor = val;
2041 else if (name.compare ("markersize"))
2042 markersize = val;
2043
2044 else
2045 {
2046 modified = false;
2047 warning ("set: invalid property `%s'", name.c_str ());
2048 }
2049
2050 if (modified)
2051 mark_modified ();
2052 }
2053
2054 octave_value
2055 patch::patch_properties::get (void) const
2056 {
2057 Octave_map m;
2058
2059 m.assign ("type", type);
2060 m.assign ("parent", parent);
2061 m.assign ("children", children);
2062 m.assign ("__modified__", __modified__);
2063 m.assign ("cdata", cdata);
2064 m.assign ("xdata", xdata);
2065 m.assign ("ydata", ydata);
2066 m.assign ("zdata", zdata);
2067 m.assign ("facecolor", facecolor);
2068 m.assign ("facealpha", facealpha);
2069 m.assign ("edgecolor", edgecolor);
2070 m.assign ("linestyle", linestyle);
2071 m.assign ("linewidth", linewidth);
2072 m.assign ("marker", marker);
2073 m.assign ("markeredgecolor", markeredgecolor);
2074 m.assign ("markerface", markerfacecolor);
2075 m.assign ("markersize", markersize);
2076
2077 return m;
2078 }
2079
2080 octave_value
2081 patch::patch_properties::get (const property_name& name) const
2082 {
2083 octave_value retval;
2084
2085 if (name.compare ("type"))
2086 retval = type;
2087 else if (name.compare ("parent"))
2088 retval = parent;
2089 else if (name.compare ("children"))
2090 retval = children;
2091 else if (name.compare ("__modified__"))
2092 retval = __modified__;
2093 else if (name.compare ("cdata"))
2094 retval = cdata;
2095 else if (name.compare ("xdata"))
2096 retval = xdata;
2097 else if (name.compare ("ydata"))
2098 retval = ydata;
2099 else if (name.compare ("zdata"))
2100 retval = zdata;
2101 else if (name.compare ("facecolor"))
2102 retval = facecolor;
2103 else if (name.compare ("facealpha"))
2104 retval = facecolor;
2105 else if (name.compare ("egdecolor"))
2106 retval = edgecolor;
2107 else if (name.compare ("linestyle"))
2108 retval = linestyle;
2109 else if (name.compare ("linewidth"))
2110 retval = linewidth;
2111 else if (name.compare ("marker"))
2112 retval = marker;
2113 else if (name.compare ("markeredgecolor"))
2114 retval = markeredgecolor;
2115 else if (name.compare ("markerfacecolor"))
2116 retval = markerfacecolor;
2117 else if (name.compare ("markersize"))
2118 retval = markersize;
2119 else
2120 warning ("get: invalid property `%s'", name.c_str ());
2121
2122 return retval;
2123 }
2124
2125 property_list::pval_map_type patch::patch_properties::factory_defaults (void)
2126 {
2127 property_list::pval_map_type m;
2128
2129 m["cdata"] = Matrix ();
2130 m["xdata"] = Matrix ();
2131 m["ydata"] = Matrix ();
2132 m["zdata"] = Matrix ();
2133 m["facecolor"] = color_property();
2134 m["facealpha"] = 1.0;
2135 m["edgecolor"] = color_property("black");
2136 m["linestyle"] = "-";
2137 m["linewidth"] = 0.5;
2138 m["marker"] = "none";
2139 m["markeredgecolor"] = "auto";
2140 m["markerfacecolor"] = "none";
2141 m["markersize"] = 1;
2142
2143
2144 return m;
2145 }
2146
2147 std::string patch::patch_properties::go_name ("patch");
2148
2149 // ---------------------------------------------------------------------
2150
1955 surface::surface_properties::surface_properties (const graphics_handle& mh, 2151 surface::surface_properties::surface_properties (const graphics_handle& mh,
1956 const graphics_handle& p) 2152 const graphics_handle& p)
1957 : base_properties (go_name, mh, p), 2153 : base_properties (go_name, mh, p),
1958 xdata (Matrix ()), 2154 xdata (Matrix ()),
1959 ydata (Matrix ()), 2155 ydata (Matrix ()),
2094 go = new line (h, p); 2290 go = new line (h, p);
2095 else if (go_name == "text") 2291 else if (go_name == "text")
2096 go = new text (h, p); 2292 go = new text (h, p);
2097 else if (go_name == "image") 2293 else if (go_name == "image")
2098 go = new image (h, p); 2294 go = new image (h, p);
2295 else if (go_name == "patch")
2296 go = new patch (h, p);
2099 else if (go_name == "surface") 2297 else if (go_name == "surface")
2100 go = new surface (h, p); 2298 go = new surface (h, p);
2101
2102 if (go) 2299 if (go)
2103 handle_map[h] = graphics_object (go); 2300 handle_map[h] = graphics_object (go);
2104 else 2301 else
2105 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", 2302 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'",
2106 go_name.c_str ()); 2303 go_name.c_str ());
2149 plist_map["figure"] = figure::figure_properties::factory_defaults (); 2346 plist_map["figure"] = figure::figure_properties::factory_defaults ();
2150 plist_map["axes"] = axes::axes_properties::factory_defaults (); 2347 plist_map["axes"] = axes::axes_properties::factory_defaults ();
2151 plist_map["line"] = line::line_properties::factory_defaults (); 2348 plist_map["line"] = line::line_properties::factory_defaults ();
2152 plist_map["text"] = text::text_properties::factory_defaults (); 2349 plist_map["text"] = text::text_properties::factory_defaults ();
2153 plist_map["image"] = image::image_properties::factory_defaults (); 2350 plist_map["image"] = image::image_properties::factory_defaults ();
2351 plist_map["patch"] = patch::patch_properties::factory_defaults ();
2154 plist_map["surface"] = surface::surface_properties::factory_defaults (); 2352 plist_map["surface"] = surface::surface_properties::factory_defaults ();
2155 2353
2156 return plist_map; 2354 return plist_map;
2157 } 2355 }
2158 2356
2438 @end deftypefn") 2636 @end deftypefn")
2439 { 2637 {
2440 GO_BODY (surface); 2638 GO_BODY (surface);
2441 } 2639 }
2442 2640
2641 DEFUN (__go_patch__, args, ,
2642 "-*- texinfo -*-\n\
2643 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\
2644 Create a patch graphics object.\n\
2645 @end deftypefn")
2646 {
2647 GO_BODY (patch);
2648 }
2649
2443 DEFUN (__go_delete__, args, , 2650 DEFUN (__go_delete__, args, ,
2444 "-*- texinfo -*-\n\ 2651 "-*- texinfo -*-\n\
2445 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ 2652 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\
2446 @end deftypefn") 2653 @end deftypefn")
2447 { 2654 {