octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [unclassified] patch for color_properties assignment


From: kahacjde
Subject: Re: [unclassified] patch for color_properties assignment
Date: Sat, 1 Sep 2007 12:46:22 -0700 (PDT)


kahacjde wrote:
> 
> John W. Eaton schrieb:
>> I'm now confused about the patches in this thread and the 
>> "problem with radio values in color_property" thread.  Which ones are
>> needed?  Am I missing any other patches for graphics?
>>
>> Thanks,
>>
>> jwe
>>
>>   
> I think there is still one problem unsolved. Here is the relevant part 
> of the discussion
> (http://www.nabble.com/patch-for-color_properties-assignment-tf4041176.html)
> 
>>
>>> 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.
>>
>> I think the issue here is that validate raises an error. I will send a
>> patch which will overcome this (e,g, replace radio_val.validate (s)
>> with
>>
>> radio_val.possible_vals.find (val) != radio_val.possible_vals.end ()
> I have tried to replace "radio_val.validate (s)" with 
> "radio_val.possible_vals.find (val) != radio_val.possible_vals.end ()" 
> for the operator
> 
> color_property&
> color_property::operator = (const octave_value& val)
> 
> (line 187 of graphics.cc), but this causes an compilation error:
> 
> g++ -c  -fPIC -I. -I.. -I../liboctave -I../src -I../libcruft/misc   
> -DHAVE_CONFIG_H -mieee-fp -Wall -W -Wshadow -Wold-style-cast -g -O2 
> graphics.cc -o pic/graphics.o
> graphics.h: In member function 'color_property& 
> color_property::operator=(const octave_value&)':
> graphics.h:112: error: 'std::set<std::basic_string<char, 
> std::char_traits<char>, std::allocator<char> >, 
> std::less<std::basic_string<char, std::char_traits<char>, 
> std::allocator<char> > >, std::allocator<std::basic_string<char, 
> std::char_traits<char>, std::allocator<char> > > > 
> radio_values::possible_vals' is private
> (Please note I use a modified graphics.h, the line 112 refers to 
> std::set<std::string> possible_vals;)
> 
> I don't know if some 'friend' magic  would help here. Another solution 
> is to have an addtional radio_values::__validate__() function without 
> this error() call.
> 
> I don't know how to proceed here, any suggestions?
> 
> Kai
> 
> 


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 
-- 
View this message in context: 
http://www.nabble.com/patch-for-color_properties-assignment-tf4041176.html#a12443384
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]