changeset 11160:131d56b6d9a3

Set cdata from facevertexcdata and visa versa for patch at all times
author David Bateman <dbateman@free.fr>
date Thu, 28 Oct 2010 01:56:14 +0200
parents a06759adaa79
children 2e32236eaa90
files scripts/ChangeLog scripts/plot/private/__patch__.m
diffstat 2 files changed, 27 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Oct 26 19:36:19 2010 +0200
+++ b/scripts/ChangeLog	Thu Oct 28 01:56:14 2010 +0200
@@ -1,3 +1,9 @@
+2010-10-27  David Bateman  <dbateman@free.fr>
+
+	* plot/private/__patch__.m (setdata, setvertexdata): If argments are
+	repeated, take the last argument only into account. Set cdata and
+	facevertexcdata properties always.
+
 2010-10-26  Kai Habel  <kai.habel@gmx.de>
 
 	* plot/uimenu.m: Add simple demo
--- a/scripts/plot/private/__patch__.m	Tue Oct 26 19:36:19 2010 +0200
+++ b/scripts/plot/private/__patch__.m	Thu Oct 28 01:56:14 2010 +0200
@@ -171,25 +171,25 @@
   ## Remove the readonly fields as well
   args = delfields (args, {"type", "uicontextmenu"});
   nargs = length (args);
-  idx = find (cellfun (@(x) strcmpi (x, "faces"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "faces"), args))(end) + 1;
   if (idx > nargs)
     faces = [];
   else
     faces = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "vertices"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "vertices"), args))(end) + 1;
   if (idx > nargs)
     vert = [];
   else
     vert = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "facevertexcdata"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "facevertexcdata"), args))(end) + 1;
   if (isempty(idx) || idx > nargs)
     fvc = [];
   else
     fvc = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args))(end) + 1;
   if (isempty(idx) || idx > nargs)
     if (!isempty (fvc))
       fc = "flat";
@@ -219,20 +219,16 @@
     z = [];
   endif
 
-  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
-    if (size(fvc, 1) == nc || size (fvc, 1) == 1)
-      c = reshape (fvc, [1, size(fvc)]);
+  if (size(fvc, 1) == nc || size (fvc, 1) == 1)
+    c = reshape (fvc, [1, size(fvc)]);
+  else
+    if (size(fvc, 2) == 3)
+      c = cat(3, reshape (fvc(idx, 1), size(idx)),
+              reshape (fvc(idx, 2), size(idx)),
+              reshape (fvc(idx, 3), size(idx)));
     else
-      if (size(fvc, 2) == 3)
-        c = cat(3, reshape (fvc(idx, 1), size(idx)),
-                reshape (fvc(idx, 2), size(idx)),
-                reshape (fvc(idx, 3), size(idx)));
-      else
-        c = reshape (fvc(idx), size(idx));
-      endif
+      c = reshape (fvc(idx), size(idx));
     endif
-  else
-    c = [];
   endif
   args = {"xdata", x, "ydata", y, "zdata", z, "cdata", c, args{:}};
 endfunction
@@ -242,31 +238,31 @@
   ## Remove the readonly fields as well
   args = delfields (args, {"type", "uicontextmenu"});
   nargs = length (args);
-  idx = find (cellfun (@(x) strcmpi (x, "xdata"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "xdata"), args))(end) + 1;
   if (idx > nargs)
     x = [];
   else
     x = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "ydata"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "ydata"), args))(end) + 1;
   if (idx > nargs)
     y = [];
   else
     y = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "zdata"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "zdata"), args))(end) + 1;
   if (isempty(idx) || idx > nargs)
     z = [];
   else
     z = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "cdata"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "cdata"), args))(end) + 1;
   if (isempty(idx) || idx > nargs)
     c = [];
   else
     c = args {idx};
   endif
-  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args)) + 1;
+  idx = find (cellfun (@(x) strcmpi (x, "facecolor"), args))(end) + 1;
   if (isempty(idx) || idx > nargs)
     if (!isempty (c))
       fc = "flat";
@@ -287,16 +283,12 @@
   faces = reshape (1:numel(x), rows (x), columns (x));
   faces = faces';
 
-  if (ischar (fc) && (strcmpi (fc, "flat") || strcmpi (fc, "interp")))
-    if (ndims (c) == 3)
-      fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
-    else
-      fvc = c(:);
-    endif
+  if (ndims (c) == 3)
+    fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
   else
-    fvc = [];
+    fvc = c(:).';
   endif
-
+ 
   args = {"faces", faces, "vertices", vert, "facevertexcdata", fvc, args{:}};
 endfunction