# HG changeset patch # User David Bateman # Date 1297031131 -3600 # Node ID 6001e10ce1522411913b7a088e9b8083418deeb8 # Parent 581f65bcc1a4f2ded655a6e10efe471513fd6aad Fix for legends with location southeastoutside and soutwestoutside. Pad legend position diff -r 581f65bcc1a4 -r 6001e10ce152 scripts/ChangeLog --- a/scripts/ChangeLog Sun Feb 06 16:45:05 2011 -0500 +++ b/scripts/ChangeLog Sun Feb 06 23:25:31 2011 +0100 @@ -1,3 +1,8 @@ +2011-02-05 David Bateman + + * plot/legend.m: Add padding to legend positions. Fix for outerposition + for southeastoutside and southwestoutside. + 2011-02-06 Ben Abbott * plot/legend.m: Align legends to plot box, add demo. Bug 32373. diff -r 581f65bcc1a4 -r 6001e10ce152 scripts/plot/legend.m --- a/scripts/plot/legend.m Sun Feb 06 16:45:05 2011 -0500 +++ b/scripts/plot/legend.m Sun Feb 06 23:25:31 2011 +0100 @@ -553,7 +553,8 @@ case "north" if (outside) lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... - ca_outpos(2) + ca_outpos(4) - lpos(4), lpos(3), lpos(4)]; + ca_outpos(2) + ca_outpos(4) - lpos(4) - ypad, lpos(3), ... + lpos(4)]; new_pos = [ca_pos(1), ca_pos(2), ca_pos(3), ca_pos(4) - lpos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2), ca_outpos(3), ... @@ -564,8 +565,8 @@ endif case "south" if (outside) - lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ca_outpos(2), ... - lpos(3), lpos(4)]; + lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... + ca_outpos(2) + ypad, lpos(3), lpos(4)]; new_pos = [ca_pos(1), ca_pos(2) + lpos(4), ca_pos(3), ... ca_pos(4) - lpos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2) + lpos(4), ... @@ -576,7 +577,7 @@ endif case "east" if (outside) - lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ... + lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)]; new_pos = [ca_pos(1), ca_pos(2), ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2), ... @@ -587,7 +588,8 @@ endif case "west" if (outside) - lpos = [ca_outpos(1), ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, ... + lpos = [ca_outpos(1) + ypad, ... + ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, ... lpos(3), lpos(4)]; new_pos = [ca_pos(1) + lpos(3), ca_pos(2), ... ca_pos(3) - lpos(3), ca_pos(4)]; @@ -599,7 +601,7 @@ endif case "northeast" if (outside) - lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ... + lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... ca_pos(2) + ca_pos(4) - lpos(4), lpos(3), lpos(4)]; new_pos = [ca_pos(1), ca_pos(2), ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2), ... @@ -610,7 +612,7 @@ endif case "northwest" if (outside) - lpos = [ca_outpos(1), ca_pos(2) + ca_pos(4) - lpos(4), ... + lpos = [ca_outpos(1) + ypad , ca_pos(2) + ca_pos(4) - lpos(4), ... lpos(3), lpos(4)]; new_pos = [ca_pos(1) + lpos(3), ca_pos(2), ... ca_pos(3) - lpos(3), ca_pos(4)]; @@ -622,23 +624,23 @@ endif case "southeast" if (outside) - lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ca_pos(2), ... - lpos(3), lpos(4)]; + lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... + ca_pos(2), lpos(3), lpos(4)]; new_pos = [ca_pos(1), ca_pos(2), ... ca_pos(3) - lpos(3), ca_pos(4)]; - new_outpos = [ca_outpos(1), ca_outpos(2) + lpos(4), ... - ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; + new_outpos = [ca_outpos(1), ca_outpos(2), ... + ca_outpos(3) - lpos(3), ca_outpos(4)]; else lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ... ca_pos(2) + ypad, lpos(3), lpos(4)]; endif case "southwest" if (outside) - lpos = [ca_outpos(1), ca_pos(2), lpos(3), lpos(4)]; + lpos = [ca_outpos(1) + ypad, ca_pos(2), lpos(3), lpos(4)]; new_pos = [ca_pos(1) + lpos(3), ca_pos(2), ... ca_pos(3) - lpos(3), ca_pos(4)]; - new_outpos = [ca_outpos(1) + lpos(3), ca_outpos(2) + lpos(4), ... - ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; + new_outpos = [ca_outpos(1) + lpos(3), ca_outpos(2), ... + ca_outpos(3) - lpos(3), ca_outpos(4)]; else lpos = [ca_pos(1) + ypad, ca_pos(2) + ypad, lpos(3), lpos(4)]; endif diff -r 581f65bcc1a4 -r 6001e10ce152 src/ls-mat5.cc --- a/src/ls-mat5.cc Sun Feb 06 16:45:05 2011 -0500 +++ b/src/ls-mat5.cc Sun Feb 06 23:25:31 2011 +0100 @@ -525,6 +525,8 @@ OCTAVE_LOCAL_BUFFER (char, inbuf, element_length); is.read (inbuf, element_length); + std::cerr << "len: " << element_length << "\n"; + // We uncompress the first 8 bytes of the header to get the buffer length // This will fail with an error Z_MEM_ERROR uLongf destLen = 8; @@ -537,61 +539,75 @@ if (swap) swap_bytes<4> (tmp, 2); - destLen = tmp[1] + 8; + destLen = tmp[1] + 32; std::string outbuf (destLen, ' '); - // FIXME -- find a way to avoid casting away const here! - - int err = uncompress (reinterpret_cast (const_cast (outbuf.c_str ())), - &destLen, reinterpret_cast (inbuf), - element_length); - - if (err != Z_OK) + // Try reading the compressed file with 8 different lengthes + // to account for the zero padding that are added to matlab + // files + for (int k = 0; k < 8; k++) { - std::string msg; - switch (err) + // FIXME -- find a way to avoid casting away const here! + int err = uncompress (reinterpret_cast + (const_cast (outbuf.c_str ())), + &destLen, reinterpret_cast (inbuf), + element_length - k); + + if (err != Z_OK) { - case Z_STREAM_END: - msg = "stream end"; - break; - - case Z_NEED_DICT: - msg = "need dict"; - break; - - case Z_ERRNO: - msg = "errno case"; - break; - - case Z_STREAM_ERROR: - msg = "stream error"; - break; - - case Z_DATA_ERROR: - msg = "data error"; - break; - - case Z_MEM_ERROR: - msg = "mem error"; - break; - - case Z_BUF_ERROR: - msg = "buf error"; - break; - - case Z_VERSION_ERROR: - msg = "version error"; + std::string msg; + switch (err) + { + case Z_STREAM_END: + msg = "stream end"; + break; + + case Z_NEED_DICT: + msg = "need dict"; + break; + + case Z_ERRNO: + msg = "errno case"; + break; + + case Z_STREAM_ERROR: + msg = "stream error"; + break; + + case Z_DATA_ERROR: + if (k != 7) + { + std::cerr << "k = " << k << "\n"; + continue; + } + else + msg = "data error"; + break; + + case Z_MEM_ERROR: + msg = "mem error"; + break; + + case Z_BUF_ERROR: + msg = "buf error"; + break; + + case Z_VERSION_ERROR: + msg = "version error"; + break; + } + + error ("load: error uncompressing data element (%s from zlib)", + msg.c_str ()); break; } - - error ("load: error uncompressing data element (%s from zlib)", - msg.c_str ()); - } - else - { - std::istringstream gz_is (outbuf); - retval = read_mat5_binary_element (gz_is, filename, + else + { + std::istringstream gz_is (outbuf); + retval = read_mat5_binary_element (gz_is, filename, swap, global, tc); + break; + } } } else diff -r 581f65bcc1a4 -r 6001e10ce152 src/txt-eng.h --- a/src/txt-eng.h Sun Feb 06 16:45:05 2011 -0500 +++ b/src/txt-eng.h Sun Feb 06 23:25:31 2011 +0100 @@ -190,4 +190,32 @@ } }; +class +OCTINTERP_API +text_parser_tex : public text_parser +{ +public: + text_parser_tex (void) : text_parser () { } + + ~text_parser_tex (void) { } + + // FIXME: is it possible to use reference counting to manage the + // memory for the object returned by the text parser? That would be + // preferable to having to know when and where to delete the object it + // creates... + + text_element* parse (const std::string& s); + + private: + text_element_list lst; + mutable size_t anchor; + + std::string getargument(const std::string& s, size_t start) const; + + size_t matchbrace(const std::string& s, size_t start) const; + + + +}; + #endif