# HG changeset patch # User Rik # Date 1378425880 25200 # Node ID 50b2863d10a6693ce763a5ddbbec5600c86d7e0a # Parent 06b46e67f8684a7f0b97e9dca75c8cfc5fdf9408 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. diff -r 06b46e67f868 -r 50b2863d10a6 libinterp/corefcn/graphics.cc --- 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) { diff -r 06b46e67f868 -r 50b2863d10a6 libinterp/corefcn/graphics.in.h --- 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}"