# HG changeset patch # User Rik # Date 1433893073 25200 # Node ID 0d94ec291ee65b11d7b71bea1111349271e50b44 # Parent b93a155dc2005418aba962123e9eaf53379b9c7c# Parent 7fa170cc14fec67c0ef9d96eef2ae8faca77793c maint: Periodic merge of stable to default. diff -r b93a155dc200 -r 0d94ec291ee6 libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libgui/graphics/Canvas.cc Tue Jun 09 16:37:53 2015 -0700 @@ -401,14 +401,14 @@ gh_manager::auto_lock lock; graphics_object ax = gh_manager::get_object (m_mouseAxes); - if (m_mouseMode != NoMode && ax.valid_object ()) + if (m_mouseMode != NoMode && (ax.valid_object () || m_mouseMode == TextMode)) { - axes::properties& ap = Utils::properties (ax); - switch (m_mouseMode) { case RotateMode: { + axes::properties& ap = Utils::properties (ax); + ap.rotate3d (m_mouseCurrent.x (), event->x (), m_mouseCurrent.y (), event->y ()); @@ -428,6 +428,8 @@ case PanMode: { + axes::properties& ap = Utils::properties (ax); + graphics_object figObj (ax.get_ancestor ("figure")); std::string mode = pan_mode (figObj); @@ -617,7 +619,6 @@ { case Qt::LeftButton: m_mouseAnchor = m_mouseCurrent = event->pos (); - m_mouseAxes = axesObj.get_handle (); m_mouseMode = newMouseMode; m_rectMode = true; } @@ -794,13 +795,14 @@ bb(2) = (event->x () - m_mouseAnchor.x ()) / bb(2); bb(3) = (m_mouseAnchor.y () - event->y ()) / bb(3); - octave_value_list props = ovl("textbox", bb); + octave_value_list props = ovl ("textbox", bb); annotation_dialog anno_dlg (w, props); if (anno_dlg.exec () == QDialog::Accepted) { props = anno_dlg.get_properties (); + props.prepend (figObj.get_handle ().as_octave_value ()); octave_link::post_event (this, &Canvas::annotation_callback, props); diff -r b93a155dc200 -r 0d94ec291ee6 libgui/graphics/Figure.cc --- a/libgui/graphics/Figure.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libgui/graphics/Figure.cc Tue Jun 09 16:37:53 2015 -0700 @@ -813,7 +813,10 @@ void Figure::save_figure_callback (const std::string& file) { - Ffeval (ovl ("print", file)); + figure::properties& fp = properties
(); + octave_value fnum = fp.get___myhandle__ ().as_octave_value (); + + Ffeval (ovl ("print", fnum, file)); } void @@ -829,9 +832,7 @@ return; } - std::string device = "-d" + format; - - Ffeval (ovl ("print", file, device)); + save_figure_callback (file); octave_link::copy_image_to_clipboard (file); } diff -r b93a155dc200 -r 0d94ec291ee6 libgui/graphics/annotation-dialog.cc --- a/libgui/graphics/annotation-dialog.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libgui/graphics/annotation-dialog.cc Tue Jun 09 16:37:53 2015 -0700 @@ -53,7 +53,8 @@ QSettings *settings = resource_manager::get_settings (); // restore last geometry - restoreGeometry (settings->value("annotation/geometry").toByteArray ()); + if (settings) + restoreGeometry (settings->value("annotation/geometry").toByteArray ()); // connect signals connect (ui->button_box, SIGNAL (clicked (QAbstractButton *)), @@ -96,7 +97,8 @@ QSettings *settings = resource_manager::get_settings (); // save position - settings->setValue ("annotation/geometry",saveGeometry ()); + if (settings) + settings->setValue ("annotation/geometry",saveGeometry ()); if (button_role == QDialogButtonBox::ApplyRole || button_role == QDialogButtonBox::AcceptRole) diff -r b93a155dc200 -r 0d94ec291ee6 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libgui/src/main-window.cc Tue Jun 09 16:37:53 2015 -0700 @@ -1502,6 +1502,10 @@ connect (_octave_qt_link, SIGNAL (confirm_shutdown_signal ()), this, SLOT (confirm_shutdown_octave ())); + connect (_octave_qt_link, + SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)), + this, SLOT (copy_image_to_clipboard (const QString&, bool))); + if (_start_gui) { connect (_octave_qt_link, @@ -1551,10 +1555,6 @@ SIGNAL (show_preferences_signal (void)), this, SLOT (process_settings_dialog_request ())); - connect (_octave_qt_link, - SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)), - this, SLOT (copy_image_to_clipboard (const QString&, bool))); - #ifdef HAVE_QSCINTILLA connect (_octave_qt_link, SIGNAL (edit_file_signal (const QString&)), diff -r b93a155dc200 -r 0d94ec291ee6 libgui/src/octave-gui.cc --- a/libgui/src/octave-gui.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libgui/src/octave-gui.cc Tue Jun 09 16:37:53 2015 -0700 @@ -122,35 +122,37 @@ QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("UTF-8")); #endif + // show wizard if this is the first run + if (resource_manager::is_first_run ()) + { + // before wizard + resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); + application.installTranslator (&qt_tr); + application.installTranslator (&gui_tr); + if (start_gui) + application.installTranslator (&qsci_tr); + + welcome_wizard welcomeWizard; + + if (welcomeWizard.exec () == QDialog::Rejected) + exit (1); + + resource_manager::reload_settings (); // install settings file + } + else + { + resource_manager::reload_settings (); // get settings file + + // after settings + resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); + application.installTranslator (&qt_tr); + application.installTranslator (&gui_tr); + if (start_gui) + application.installTranslator (&qsci_tr); + } + if (start_gui) { - // show wizard if this is the first run - if (resource_manager::is_first_run ()) - { - // before wizard - resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); - application.installTranslator (&qt_tr); - application.installTranslator (&qsci_tr); - application.installTranslator (&gui_tr); - - welcome_wizard welcomeWizard; - - if (welcomeWizard.exec () == QDialog::Rejected) - exit (1); - - resource_manager::reload_settings (); // install settings file - } - else - { - resource_manager::reload_settings (); // get settings file - - // after settings - resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); - application.installTranslator (&qt_tr); - application.installTranslator (&qsci_tr); - application.installTranslator (&gui_tr); - } - // update network-settings resource_manager::update_network_settings (); @@ -178,10 +180,10 @@ main_window w (0, start_gui); - w.read_settings (); - if (start_gui) { + w.read_settings (); + w.init_terminal_size (); // Connect signals for changes in visibility not before w diff -r b93a155dc200 -r 0d94ec291ee6 libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libinterp/corefcn/oct-stream.cc Tue Jun 09 16:37:53 2015 -0700 @@ -2435,7 +2435,7 @@ uint64_t limit = std::numeric_limits::max (); if (val.is_string ()) - return false; + return true; else if (val.is_integer_type ()) { if (val.is_uint64_type ()) @@ -2463,7 +2463,7 @@ ok_for_unsigned_int_conv (const octave_value& val) { if (val.is_string ()) - return false; + return true; else if (val.is_integer_type ()) { // Easier than dispatching here... diff -r b93a155dc200 -r 0d94ec291ee6 libinterp/octave-value/ov-ch-mat.cc --- a/libinterp/octave-value/ov-ch-mat.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libinterp/octave-value/ov-ch-mat.cc Tue Jun 09 16:37:53 2015 -0700 @@ -87,6 +87,42 @@ return retval; } +octave_int64 +octave_char_matrix::int64_scalar_value () const +{ + octave_int64 retval = 0; + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-to-scalar", + "character matrix", "int64 scalar"); + + retval = octave_int64 (matrix (0, 0)); + } + else + gripe_invalid_conversion ("character matrix", "int64 scalar"); + + return retval; +} + +octave_uint64 +octave_char_matrix::uint64_scalar_value () const +{ + octave_uint64 retval = 0; + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-to-scalar", + "character matrix", "uint64 scalar"); + + retval = octave_uint64 (matrix (0, 0)); + } + else + gripe_invalid_conversion ("character matrix", "uint64 scalar"); + + return retval; +} + Complex octave_char_matrix::complex_value (bool) const { diff -r b93a155dc200 -r 0d94ec291ee6 libinterp/octave-value/ov-ch-mat.h --- a/libinterp/octave-value/ov-ch-mat.h Sat Jun 06 08:26:21 2015 -0700 +++ b/libinterp/octave-value/ov-ch-mat.h Tue Jun 09 16:37:53 2015 -0700 @@ -36,6 +36,7 @@ #include "ov.h" #include "ov-base.h" #include "ov-base-mat.h" +#include "ov-int64.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" @@ -105,6 +106,9 @@ float float_scalar_value (bool frc_str_conv = false) const { return float_value (frc_str_conv); } + octave_int64 int64_scalar_value () const; + octave_uint64 uint64_scalar_value () const; + Matrix matrix_value (bool = false) const { return Matrix (charMatrix (matrix)); } diff -r b93a155dc200 -r 0d94ec291ee6 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Sat Jun 06 08:26:21 2015 -0700 +++ b/libinterp/octave-value/ov-java.cc Tue Jun 09 16:37:53 2015 -0700 @@ -1296,7 +1296,8 @@ // Note that we do NOT handle char here because they are unboxed // into a String[], not into a char array - IF_UNBOX_PRIMITIVE_ARRAY(bool, bool_, bool, jboolean, Boolean) + IF_UNBOX_PRIMITIVE_ARRAY(double, , , jdouble, Double) + else IF_UNBOX_PRIMITIVE_ARRAY(bool, bool_, bool, jboolean, Boolean) else IF_UNBOX_PRIMITIVE_ARRAY(float, float_, Float, jfloat, Float) else IF_UNBOX_PRIMITIVE_ARRAY(int8, int8_, int8, jbyte, Byte) else IF_UNBOX_PRIMITIVE_ARRAY(uint8, uint8_, uint8, jbyte, Byte) diff -r b93a155dc200 -r 0d94ec291ee6 scripts/linear-algebra/linsolve.m --- a/scripts/linear-algebra/linsolve.m Sat Jun 06 08:26:21 2015 -0700 +++ b/scripts/linear-algebra/linsolve.m Tue Jun 09 16:37:53 2015 -0700 @@ -79,12 +79,13 @@ error ("linsolve: A and B must be numeric"); endif + trans_A = false; + ## Process any opts if (nargin > 2) if (! isstruct (opts)) error ("linsolve: OPTS must be a structure"); endif - trans_A = false; if (isfield (opts, "TRANSA") && opts.TRANSA) trans_A = true; endif @@ -119,6 +120,14 @@ %!test %! n = 10; +%! A = rand (n); +%! x = rand (n, 1); +%! b = A * x; +%! assert (linsolve (A, b), A \ b); +%! assert (linsolve (A, b, struct ()), A \ b); + +%!test +%! n = 10; %! A = triu (gallery ("condex", n)); %! x = rand (n, 1); %! b = A' * x; diff -r b93a155dc200 -r 0d94ec291ee6 scripts/miscellaneous/run.m --- a/scripts/miscellaneous/run.m Sat Jun 06 08:26:21 2015 -0700 +++ b/scripts/miscellaneous/run.m Tue Jun 09 16:37:53 2015 -0700 @@ -61,7 +61,7 @@ if (! isempty (d)) if (exist (d, "dir")) startdir = pwd (); - d = canonicalize_file_name (d); + d = make_absolute_filename (d); unwind_protect cd (d); evalin ("caller", sprintf ("source ('%s%s');", f, ext), diff -r b93a155dc200 -r 0d94ec291ee6 scripts/signal/fftshift.m --- a/scripts/signal/fftshift.m Sat Jun 06 08:26:21 2015 -0700 +++ b/scripts/signal/fftshift.m Tue Jun 09 16:37:53 2015 -0700 @@ -52,6 +52,10 @@ print_usage (); endif + if (! (isnumeric (x) || islogical (x) || ischar (x))) + error ("fftshift: X must be a vector or matrix"); + endif + if (nargin == 2) if (! (isscalar (dim) && dim > 0 && dim == fix (dim))) error ("fftshift: dimension DIM must be a positive integer"); @@ -68,7 +72,7 @@ xl = length (x); xx = ceil (xl/2); retval = x([xx+1:xl, 1:xx]); - elseif (ismatrix (x)) + else nd = ndims (x); sz = size (x); sz2 = ceil (sz ./ 2); @@ -77,8 +81,6 @@ idx{i} = [sz2(i)+1:sz(i), 1:sz2(i)]; endfor retval = x(idx{:}); - else - error ("fftshift: expecting vector or matrix argument"); endif endif @@ -130,3 +132,24 @@ %! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); %! assert (fftshift (y,2), x); +%!test +%! x = "abcdefg"; +%! y = fftshift (x); +%! assert (y, "efgabcd"); +%! assert (fftshift (y), "bcdefga"); + +## Test N-dimensional input (bug #45207) +%!test +%! x = [0:3]; +%! x = x + x' + reshape (x, [1 1 4]); +%! y1 = [4 5 2 3; 5 6 3 4; 2 3 0 1; 3 4 1 2]; +%! y = fftshift (x); +%! assert (y, reshape ([y1 + 2, y1 + 3, y1, y1 + 1], [4 4 4])); +%! assert (fftshift (y), x); + +%% Test input validation +%!error fftshift () +%!error fftshift (1, 2, 3) +%!error fftshift (0:3, -1) +%!error fftshift (0:3, 0:3) + diff -r b93a155dc200 -r 0d94ec291ee6 scripts/signal/ifftshift.m --- a/scripts/signal/ifftshift.m Sat Jun 06 08:26:21 2015 -0700 +++ b/scripts/signal/ifftshift.m Tue Jun 09 16:37:53 2015 -0700 @@ -34,15 +34,17 @@ function retval = ifftshift (x, dim) - retval = 0; - if (nargin != 1 && nargin != 2) print_usage (); endif + if (! (isnumeric (x) || islogical (x) || ischar (x))) + error ("ifftshift: X must be a vector or matrix"); + endif + if (nargin == 2) - if (! isscalar (dim)) - error ("ifftshift: dimension must be an integer scalar"); + if (! (isscalar (dim) && dim > 0 && dim == fix (dim))) + error ("ifftshift: dimension DIM must be a positive integer"); endif nd = ndims (x); sz = size (x); @@ -55,7 +57,7 @@ xl = length (x); xx = floor (xl/2); retval = x([xx+1:xl, 1:xx]); - elseif (ismatrix (x)) + else nd = ndims (x); sz = size (x); sz2 = floor (sz ./ 2); @@ -64,8 +66,6 @@ idx{i} = [sz2(i)+1:sz(i), 1:sz2(i)]; endfor retval = x(idx{:}); - else - error ("ifftshift: expecting vector or matrix argument"); endif endif @@ -117,3 +117,24 @@ %! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); %! assert (ifftshift (y,2), x); +%!test +%! x = "efgabcd"; +%! y = ifftshift (x); +%! assert (y, "abcdefg"); +%! assert (ifftshift (y), "defgabc"); + +## Test N-dimensional input (bug #45207) +%!test +%! x = [0:3]; +%! x = x + x' + reshape (x, [1 1 4]); +%! y1 = [4 5 2 3; 5 6 3 4; 2 3 0 1; 3 4 1 2]; +%! y = ifftshift (x); +%! assert (y, reshape ([y1 + 2, y1 + 3, y1, y1 + 1], [4 4 4])); +%! assert (ifftshift (y), x); + +%% Test input validation +%!error ifftshift () +%!error ifftshift (1, 2, 3) +%!error ifftshift (0:3, -1) +%!error ifftshift (0:3, 0:3) +