changeset 17382:50b2863d10a6

Create Matlab compatible linestyleorder char matrices (bug #34906) * libinterp/corefcn/graphics.cc(convert_linestyleorder_string): New function which changes strings and char matrices to row vector char matrices. * libinterp/corefcn/graphics.in.h: Update axes BEGIN_PROPERTIES list for linestyleorder to use set_linestyleorder function which calls convert_linestyleorder_string.
author Rik <rik@octave.org>
date Thu, 05 Sep 2013 17:04:40 -0700
parents 06b46e67f868
children 1a4d036e1456
files libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h
diffstat 2 files changed, 52 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Thu Sep 05 16:53:52 2013 -0700
+++ b/libinterp/corefcn/graphics.cc	Thu Sep 05 17:04:40 2013 -0700
@@ -5782,6 +5782,56 @@
     }
 }
 
+// Almost identical to convert_ticklabel_string but it only accepts
+// cellstr or string, not numeric input.
+static octave_value
+convert_linestyleorder_string (const octave_value& val)
+{
+  octave_value retval = val;
+
+  if (val.is_cellstr ())
+    {
+      // Always return a column vector for Matlab Compatibility
+      if (val.columns () > 1)
+        retval = val.reshape (dim_vector (val.numel (), 1));
+    }
+  else
+    {
+      string_vector sv;
+      if (val.is_string () && val.rows () == 1)
+        {
+          std::string valstr = val.string_value ();
+          std::istringstream iss (valstr);
+          std::string tmpstr;
+
+          // Split string with delimiter '|'
+          while (std::getline (iss, tmpstr, '|'))
+            sv.append (tmpstr);
+          
+          // If string ends with '|' Matlab appends a null string
+          if (*valstr.rbegin () == '|')
+            sv.append (std::string (""));
+        }
+      else
+        return retval;
+
+      charMatrix chmat (sv, ' ');
+
+      retval = octave_value (chmat);
+    }
+
+  return retval;
+}
+
+void
+axes::properties::set_linestyleorder (const octave_value& v)
+{
+  if (!error_state)
+    {
+      linestyleorder.set (convert_linestyleorder_string (v), false);
+    }
+}
+
 void
 axes::properties::set_units (const octave_value& v)
 {
--- a/libinterp/corefcn/graphics.in.h	Thu Sep 05 16:53:52 2013 -0700
+++ b/libinterp/corefcn/graphics.in.h	Thu Sep 05 17:04:40 2013 -0700
@@ -3811,7 +3811,8 @@
       //       more sense to have it so that axis ticklabels can use it.
       radio_property interpreter , "tex|{none}|latex"
       radio_property layer u , "{bottom}|top"
-      string_array_property linestyleorder , "-"
+      // FIXME: should be kind of string array.
+      any_property linestyleorder S , "-"
       double_property linewidth , 0.5
       radio_property minorgridlinestyle , "-|--|{:}|-.|none"
       radio_property nextplot , "add|replacechildren|{replace}"