[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [unclassified] patch for color_properties assignment
From: |
Kai Habel |
Subject: |
Re: [unclassified] patch for color_properties assignment |
Date: |
Tue, 10 Jul 2007 22:08:51 +0000 |
User-agent: |
IceDove 1.5.0.12 (X11/20070607) |
Shai Ayal schrieb:
I attach a patch to fix color_property assignment.
As discussed earlier on at least 2 other threads, color_property and
radio_value are unique in the graphics properties objects in that
their set of allowable values is defined at runtime in their
constructor. This in turn means that assignment of new values to these
objects cannot be done by converting an octave_value object to them
with a constructor, but rather using assignment:
instead of
color_property color("aa|bb|cc");
octave_value ov("bb");
...
// don't use this -- it will destroy the old color definition and
throw an error!
//color = color_property(ov);
// use assignment to keep old definition and give no error
color = ov;
this patch adds the
color_property& color_property::operator = (const octave_value& val)
operator to facilitate this syntax, and also fixes the assignment in
line_properties
Shai
Hello,
I have some problems with this patch.
I think we have to modify the constructor
"color_property::color_property (const octave_value& val)" in the same
way. Because if I try to set the allowed radio_values (e.g. for line) with
xudata (Matrix ()),
color ("none|flat|interp"),
linestyle ("-"),
I get the following error:
octave:1> h=__go_line__ (gca)
error: invalid color specification
error: __goline__: unable to create graphics handle
error: evaluating assignment expression near line 1, column 2
Another problem is the radio_values::validate method. In your patch you
check first for valid radio values:
if (radio_val.validate (s))
+ {
+ current_val = s;
+ current_type = radio_t;
+ }
+ else
+ {
+ color_values col (s);
+ if (! error_state)
+ {
+ color_val = col;
+ current_type = color_t;
+ }
+ else
+ error ("invalid color specification");
+ }
but if 's' is a string color value (e.g. 'r' or 'red') validate calls
the error function and sets the error flag. This causes an error message
and octave terminates. I have turned off the error call in
radio_values::validate for test purposes. Then the creation of a line
object with:
h=__go_line__ (gca);
works as expected.
Kai
patch for color_properties assignment, John W. Eaton, 2007/07/24