octave-maintainers
[Top][All Lists]
Advanced

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

problem with radio values in color_property


From: Kai Habel
Subject: problem with radio values in color_property
Date: Wed, 04 Jul 2007 20:53:48 +0000
User-agent: IceDove 1.5.0.12 (X11/20070607)

Hello,

currently I am trying to implement the patch graphic object. So far it has worked well I can plot 2D patches with gnuplot, but I have a problem with radio_values in the color_property class.

Just to demonstrate the issue, please consider the attached patches. If you change the color property of the line object like this

--- graphics.cc    2007-07-04 20:02:47.000000000 +0000
+++ graphics.cc.new    2007-07-03 22:44:15.000000000 +0000
@@ -1525,7 +1533,7 @@
    udata (Matrix ()),
    xldata (Matrix ()),
    xudata (Matrix ()),
-    color (),
+    color (radio_values("{none}|flat")),
    linestyle ("-"),
    linewidth (0.5),
    marker ("none"),


a first problem appears, when the color_property object is constructed. The current code does not check for a radio string. So, I have added check and have turned off the two error() calls to avoid a premature end.

Now we can create a line object in octave:

octave:1> line([1 2],[1 2])
octave:2> h=line([1 2],[1 2])
h = -7
octave:3> get(h,'color')
ans = none

Fine, 'none' is chosen as default value, but if we try to change the color to 'flat', this happens.

octave:4> set(h,'color','flat')
warning: invalid color specification
octave:5> get(h,'color')
ans =

  2.1220e-314   4.9407e-324   2.7025e-310

Apperently the set command fails, but I have no idea why. So, maybe you can help here.
(Setting a color value e.g. 'r', 'red', [10 0] works fine.)

Kai




--- graphics.cc.orig    2007-07-04 20:02:47.000000000 +0000
+++ graphics.cc 2007-07-04 20:28:16.000000000 +0000
@@ -141,12 +141,20 @@
 
       if (! s.empty ())
        {
-         color_values col (s);
-         if (! error_state)
-           {
-             color_val = col;
-             current_type = color_t;
-           }
+          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");    
@@ -1525,7 +1533,7 @@
     udata (Matrix ()),
     xldata (Matrix ()),
     xudata (Matrix ()),
-    color (),
+    color (radio_values("{none}|flat")),
     linestyle ("-"),
     linewidth (0.5),
     marker ("none"),
--- graphics.h.orig     2007-07-04 20:02:48.000000000 +0000
+++ graphics.h  2007-07-04 20:28:26.000000000 +0000
@@ -79,7 +79,7 @@
 
     if (possible_vals.find (val) == possible_vals.end ())
       {
-       error ("invalid value = %s", val.c_str ());
+       //warning ("invalid value = %s", val.c_str ());
        retval = false;
       }
 
@@ -147,7 +147,7 @@
   color_values (std::string str)
   {
     if (! str2rgb (str))
-      error ("invalid color specification");
+      warning ("invalid color specification");
   }
 
   color_values (const color_values& c)

reply via email to

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