comparison libinterp/corefcn/graphics.cc @ 19867:6ba3d0f7c6e8

improve mouse zooming for Qt plotting (bug #44302) * Figure.h (enum MouseMode): Split ZoomMode into ZoomInMode and ZoomOutMode. Change all uses. * Canvas.cc (Canvas::canvasMouseReleaseEvent, Canvas::canvasWheelEvent): Make meaning of zoom factor consistent with zoom function. Make direction of wheel event consistent with other programs. * __init_fltk__.cc (plot_window::handle): Make meaning of zoom factor consistent with zoom function. * MouseModeActionGroup.cc (MouseModeActionGroup::MouseModeActionGroup): Provide buttons for zooming in and out. * graphics.cc (figure::properties::set_toolkit): Handle zoom direction. (do_zoom): Make factor > 1 zoom in.
author John W. Eaton <jwe@octave.org>
date Thu, 26 Feb 2015 19:24:59 -0500
parents 726df008104d
children 60fe3ef12bb0
comparison
equal deleted inserted replaced
19866:726df008104d 19867:6ba3d0f7c6e8
1808 1808
1809 mark_modified (); 1809 mark_modified ();
1810 } 1810 }
1811 1811
1812 void 1812 void
1813 figure::properties::set___mouse_mode__ (const octave_value& val) 1813 figure::properties::set___mouse_mode__ (const octave_value& val_arg)
1814 { 1814 {
1815 if (! error_state) 1815 if (! error_state)
1816 { 1816 {
1817 if (__mouse_mode__.set (val, true)) 1817 std::string direction = "in";
1818 { 1818
1819 std::string mode = __mouse_mode__.current_value (); 1819 octave_value val = val_arg;
1820 1820
1821 octave_scalar_map pm = get___pan_mode__ ().scalar_map_value (); 1821 if (val.is_string ())
1822 pm.setfield ("Enable", mode == "pan" ? "on" : "off"); 1822 {
1823 set___pan_mode__ (pm); 1823 std::string modestr = val.string_value ();
1824 1824
1825 octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value (); 1825 if (modestr == "zoom in")
1826 rm.setfield ("Enable", mode == "rotate" ? "on" : "off"); 1826 {
1827 set___rotate_mode__ (rm); 1827 val = modestr = "zoom";
1828 1828 direction = "in";
1829 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value (); 1829 }
1830 zm.setfield ("Enable", mode == "zoom" ? "on" : "off"); 1830 else if (modestr == "zoom out")
1831 set___zoom_mode__ (zm); 1831 {
1832 1832 val = modestr = "zoom";
1833 mark_modified (); 1833 direction = "out";
1834 }
1835
1836 if (__mouse_mode__.set (val, true))
1837 {
1838 std::string mode = __mouse_mode__.current_value ();
1839
1840 octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
1841 pm.setfield ("Enable", mode == "pan" ? "on" : "off");
1842 set___pan_mode__ (pm);
1843
1844 octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
1845 rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
1846 set___rotate_mode__ (rm);
1847
1848 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1849 zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
1850 zm.setfield ("Direction", direction);
1851 set___zoom_mode__ (zm);
1852
1853 mark_modified ();
1854 }
1855 else if (modestr == "zoom")
1856 {
1857 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1858 std::string curr_direction
1859 = zm.getfield ("Direction").string_value ();
1860
1861 if (direction != curr_direction)
1862 {
1863 zm.setfield ("Direction", direction);
1864 set___zoom_mode__ (zm);
1865
1866 mark_modified ();
1867 }
1868 }
1834 } 1869 }
1835 } 1870 }
1836 } 1871 }
1837 1872
1838 // --------------------------------------------------------------------- 1873 // ---------------------------------------------------------------------
7570 val = std::log10 (val); 7605 val = std::log10 (val);
7571 } 7606 }
7572 } 7607 }
7573 7608
7574 // Perform the zooming 7609 // Perform the zooming
7575 lo = val + factor * (lo - val); 7610 lo = val + (lo - val) / factor;
7576 hi = val + factor * (hi - val); 7611 hi = val + (hi - val) / factor;
7577 7612
7578 if (is_logscale) 7613 if (is_logscale)
7579 { 7614 {
7580 if (is_negative) 7615 if (is_negative)
7581 { 7616 {