[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [unclassified] Re: patch: Invalid call to __patch__
From: |
David Bateman |
Subject: |
Re: [unclassified] Re: patch: Invalid call to __patch__ |
Date: |
Tue, 25 Sep 2007 00:22:50 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Kai Habel wrote:
>>
>> Matthias Brennwald wrote:
>>
>>> > Dear all
>>> >
>>> > I just built and installed Octave 2.9.14 on my Ubuntu box and tried
>>> the > patch function that comes with it. However, this did not work
>>> (see > below). What am I doing wrong?
>>> >
>>> > Matthias
>>> >
>>> >
>>> > --------------------
>>> > octave:6> version
>>> > ans = 2.9.14
>>> > octave:7> patch(rand(1,4),rand(1,4),"r")
>>> >
>>> > Invalid call to __patch__. Correct usage is:
>>> >
>>> >
>> The __patch__.m doesn't yet support colors passed as strings like that.
>> Try instead
>>
>> patch(rand(1,4),rand(1,4),[1,0,0])
>>
>> and it will work.. The patch attached will add the missing support..
>>
>> D.
>>
>
>
>> I am not in front of my PC, so I cannot check this now. But AFAIK the
>> assignment of string values to a color-property (like here) should
>> work again. Therefore, the color_values class should be used to
>> convert a string to a rgb value. if (isstr (color_var)) ## Have color
>> string. set (h, "FaceColor", color_var); I will look at this later
>> today. Kai
> The following patch should allow string values for 'FaceColor' for patch
> objects.
>
> patch(rand(1,4),rand(1,4),"r")
> should plot a red patch object.
>
> Kai
>
> 2007-09-24 Kai Habel <address@hidden>
>
> * plot/__patch__.m : Allow color string for patch
Hi Kai,
I think this is wrong, this way. Firstly isstr is deprecated and
replaced with ischar, and secondly this change would be confused by for
example
patch (rand(4,1), rand(4,1), "FaceColor", "red")
that currently works.. However, it is cleaner than what I suggested, and
easily fixed with the attached..
I also noticed a couple of issues.. The color_properties should allow
upper and lower case values, and that setting the facecolor of a patch
to "interp" or "flat" is broken. That is
set (h, "facecolor", "interp")
will fail. The attached version of the patch addresses that as well..
D.
what I originally suggested
*** ./scripts/plot/__patch__.m.orig6 2007-09-15 10:18:47.000000000 +0200
--- ./scripts/plot/__patch__.m 2007-09-24 23:47:50.963737124 +0200
***************
*** 51,63 ****
endif
endif
! if (have_x && nargin > iarg && isnumeric (varargin{iarg}))
! c = varargin{iarg};
! have_c = true;
! iarg++;
! if (ndims (c) == 3 && size (c, 2) == 1)
! c = permute (c, [1, 3, 2]);
endif
endif
--- 51,70 ----
endif
endif
! if (have_x && nargin > iarg)
! if (isnumeric (varargin{iarg}))
! c = varargin{iarg};
! have_c = true;
! iarg++;
! if (ndims (c) == 3 && size (c, 2) == 1)
! c = permute (c, [1, 3, 2]);
! endif
! elseif (ischar (varargin{iarg}) && rem (nargin - iarg, 2) != 0)
! ## Assume that any additional argument over an even number is color
string
! c = tolower (varargin{iarg});
! have_c = true;
! iarg++;
endif
endif
***************
*** 96,102 ****
c2 = c;
endif
! if (numel (c2) == 1)
if (isnan (c))
set (h, "facecolor", [1, 1, 1]);
set (h, "cdata", c2);
--- 103,111 ----
c2 = c;
endif
! if (ischar (c2))
! set (h, "facecolor", c2);
! elseif (numel (c2) == 1)
if (isnan (c))
set (h, "facecolor", [1, 1, 1]);
set (h, "cdata", c2);
*** ./src/graphics.cc.orig6 2007-09-24 23:22:01.837007226 +0200
--- ./src/graphics.cc 2007-09-25 00:18:07.714772463 +0200
***************
*** 90,98 ****
bool retval = true;
unsigned int len = str.length();
if (str.compare(0, len, "blue", 0, len) == 0)
tmp_rgb[2] = 1;
! else if (str.compare(0, len, "black", 0, len) == 0 || str.compare(0, len,
"w", 0, len) == 0)
tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
else if (str.compare(0, len, "red", 0, len) == 0)
tmp_rgb[0] = 1;
--- 90,101 ----
bool retval = true;
unsigned int len = str.length();
+ std::transform (str.begin (), str.end (), str.begin (), tolower);
+
if (str.compare(0, len, "blue", 0, len) == 0)
tmp_rgb[2] = 1;
! else if (str.compare(0, len, "black", 0, len) == 0 ||
! str.compare(0, len, "k", 0, len) == 0)
tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
else if (str.compare(0, len, "red", 0, len) == 0)
tmp_rgb[0] = 1;
***************
*** 104,110 ****
tmp_rgb[0] = tmp_rgb[2] = 1;
else if (str.compare(0, len, "cyan", 0, len) == 0)
tmp_rgb[1] = tmp_rgb[2] = 1;
! else if (str.compare(0, len, "white", 0, len) == 0)
tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
else
retval = false;
--- 107,114 ----
tmp_rgb[0] = tmp_rgb[2] = 1;
else if (str.compare(0, len, "cyan", 0, len) == 0)
tmp_rgb[1] = tmp_rgb[2] = 1;
! else if (str.compare(0, len, "white", 0, len) == 0 ||
! str.compare(0, len, "w", 0, len) == 0)
tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
else
retval = false;
***************
*** 118,125 ****
return retval;
}
! color_property::color_property (const octave_value& val)
! : radio_val (), current_val ()
{
// FIXME -- need some error checking here.
--- 122,129 ----
return retval;
}
! color_property::color_property (const octave_value& val, const radio_values
&v)
! : radio_val (v), current_val ()
{
// FIXME -- need some error checking here.
***************
*** 129,139 ****
if (! s.empty ())
{
! color_values col (s);
! if (! error_state)
{
! color_val = col;
! current_type = color_t;
}
}
else
--- 133,151 ----
if (! s.empty ())
{
! if (radio_val.contains (s))
{
! current_val = s;
! current_type = radio_t;
! }
! else
! {
! color_values col (s);
! if (! error_state)
! {
! color_val = col;
! current_type = color_t;
! }
}
}
else
***************
*** 2119,2125 ****
else if (name.compare ("zdata"))
set_zdata (val);
else if (name.compare ("facecolor"))
! set_facecolor (val);
else if (name.compare ("facealpha"))
set_facealpha (val);
else if (name.compare ("edgecolor"))
--- 2131,2137 ----
else if (name.compare ("zdata"))
set_zdata (val);
else if (name.compare ("facecolor"))
! set_facecolor (color_property (val, radio_values ("flat|none|interp")));
else if (name.compare ("facealpha"))
set_facealpha (val);
else if (name.compare ("edgecolor"))
*** ./src/graphics.h.in.orig6 2007-09-25 00:21:09.869451457 +0200
--- ./src/graphics.h.in 2007-09-25 00:13:55.673669616 +0200
***************
*** 206,212 ****
current_val (initial_value)
{ }
! color_property (const octave_value& val);
operator octave_value (void) const
{
--- 206,213 ----
current_val (initial_value)
{ }
! color_property (const octave_value& val,
! const radio_values &v = radio_values());
operator octave_value (void) const
{
- patch: Invalid call to __patch__, Matthias Brennwald, 2007/09/24
- patch: Invalid call to __patch__, Matthias Brennwald, 2007/09/24
- Re: patch: Invalid call to __patch__, David Bateman, 2007/09/24
- Re: patch: Invalid call to __patch__, kahacjde, 2007/09/24
- Re: [unclassified] Re: patch: Invalid call to __patch__, Kai Habel, 2007/09/24
- Re: [unclassified] Re: patch: Invalid call to __patch__,
David Bateman <=
- Re: [unclassified] Re: patch: Invalid call to __patch__, kahacjde, 2007/09/25
- Re: [unclassified] Re: patch: Invalid call to __patch__, David Bateman, 2007/09/25
- Re: [unclassified] Re: patch: Invalid call to __patch__, David Bateman, 2007/09/25
- Re: [unclassified] Re: patch: Invalid call to __patch__, Kai Habel, 2007/09/25
patch: Invalid call to __patch__, Matthias Brennwald, 2007/09/24