[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [unclassified] patch for color_properties assignment
From: |
John W. Eaton |
Subject: |
Re: [unclassified] patch for color_properties assignment |
Date: |
Fri, 14 Sep 2007 01:21:19 -0400 |
On 1-Sep-2007, Kai Habel wrote:
| > O.k. I propose the following patches to make the color assigment work again.
| > As you might have noticed currently something like:
| > plot([0 1],'Color','blue')
| > is not possible because "color_property::operator = (const octave_value&
| > val)" is to restrictive.
| >
| > If you look at the code of this operator (around line 179 of graphics.cc) if
| > 's' is an string the assigment must fail because either "validate(s)" or
| > later "color_values col (s);" raise an error.
| >
| > I have introduced a __validate__ function which just checks for valid
| > entries.
| >
| > Here is the respective Changelog:
| >
| > 2007-09-01 Kai Habel <address@hidden>
| >
| > * graphics.h (radio_values::__validate__): New function.
| > * graphics.cc (color_property::operator =): Use __validate__ instead of
| > validate.
| >
| > Kai
| >
| > P.S. I send this email via nabble so I hope the attachments are correct.
| >
| > http://www.nabble.com/file/p12443384/graphics.h.patch graphics.h.patch
| > http://www.nabble.com/file/p12443384/graphics.cc.patch graphics.cc.patch
| >
| O.k. since the patches are not attached, I attach them here
|
| Kai
| --- graphics.cc.orig 2007-09-01 20:52:06.000000000 +0000
| +++ graphics.cc 2007-09-01 20:52:58.000000000 +0000
| @@ -184,7 +184,7 @@
|
| if (! s.empty ())
| {
| - if (radio_val.validate (s))
| + if (radio_val.__validate__ (s))
| {
| current_val = s;
| current_type = radio_t;
| --- graphics.h.orig 2007-09-01 20:52:09.000000000 +0000
| +++ graphics.h 2007-09-01 20:54:18.000000000 +0000
| @@ -79,7 +79,7 @@
| {
| bool retval = true;
|
| - if (possible_vals.find (val) == possible_vals.end ())
| + if (!__validate__ (val))
| {
| error ("invalid value = %s", val.c_str ());
| retval = false;
| @@ -87,6 +87,12 @@
|
| return retval;
| }
| +
| + bool __validate__ (const std::string& val)
| + {
| + return (possible_vals.find (val) != possible_vals.end ());
| + }
| +
|
| private:
| // Might also want to cache
I made this change, but used the name "contains" instead of
"__validate__".
Thanks,
jwe