comparison libgui/graphics/Figure.h @ 19697:dfea01b3425f

more mouse interaction features for Qt plotting widget * graphics.in.h, graphics.cc (figure::properties::__mouse_mode__, figure::properties::__pan_mode__, figure::properties::__rotate_mode__, figure::properties::__zoom_mode__): New properties. (figure::properties::set___mouse_mode__): New function. (axes::properties::pan, axes::properties::rotate3d, axes::properties::zoom): New functions. Handle zoom, and pan modes. (axes::properties::clear_zoom_stack): New arg, do_unzoom. Conditionally call unzoom. (axes::properties::unzoom): Also restore view property. (axes::properties::rotate_view): Conditionall save state to zoom stack. (axes::properties::push_zoom_stack): New function. (axes::properties::pan, axes::properties::rotate3d): Delete properties. (axes::properties::update_xlim, axes::properties::update_ylim, axes::properties::update_zlim): Don't clear zoom stack. Delete do_clr_zoom argument. (axes::properties::set_pan, axes::properties::set_rotate3d): Delete. (F__zoom__): New function. * Canvas.h, Canvas.cc (Canvas::toggleAxes, Canvas::toggleGrid): New pure virtual functions. (Canvas::setCursor, Canvas::canvasToggleAxes, Canvas::canvasToggleGrid, Canvas::canvasMouseDoubleClickEvent, Canvas::canvasWheelEvent): New functions. (zoom_enabled, pan_enabled, pan_mode, rotate_enabled, rotate_mode): New static functions. (Canvas::canvasMouseMoveEvent): Call axes::properties::rotate3d to do rotation. Handle panning. (Canvas::canvasMousePressEvent): Also handle "unzoom" action when in pan and rotate modes. (Canvas::canvasMouseReleaseEvent): Zoom by factor if mouse has not moved from mouse press event. * Figure.h, Figure.cc (MouseMode): New enum value, TextMode. (Figure::m_mouseMode, Figure::m_lastMouseMode): Delete member variables. (Figure::mouseMode, Figure::setMouseMode): Get info from and save info to figure properties. (Figure::updateFigureToolBarAndMenuBar, Figure::toggleAxes, Figure::toggleGrid): New functions. (Figure::m_mouseModeGroup): New member variable. (Figure::createFigureToolBarAndMenuBar): Add actions for toggling Axes and Grid. Maintain pointer to MouseModeActionGroup. (mouse_mode_to_string, mouse_mode_from_string): New functions. * GLCanvas.h, GLCanvas.cc (GLCanvas::toggleAxes, GLCanvas::ToggleGrid, GLCanvas::mouseDoubleClickEvent, GLCanvas::wheelEvent): New functions. * MouseModeActionGroup.h, MouseModeActionGroup.cc (MouseModeActionGroup::mouseMode): Delete. (MouseModeActionGroup::setMode): New function. (MouseModeActionGroup::MouseModeActionGroup): Also include action to insert text in the list. * figure.m: Set default pan, rotate, and zoom mode properties for the figure object. * pan.m, rotate3d.m, zoom.m: Improve compatibility with Matlab. Set mode properties for figure. * __init_fltk__.cc: Cope with changes to graphics properties.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Feb 2015 13:06:54 -0500
parents fe0e34be5576
children 35bca657d74d
comparison
equal deleted inserted replaced
19696:c728ae4d1790 19697:dfea01b3425f
35 namespace QtHandles 35 namespace QtHandles
36 { 36 {
37 37
38 enum MouseMode 38 enum MouseMode
39 { 39 {
40 // NOTE: These values must match the order of the buttons in the
41 // MouseModeActionGroup object.
42
40 NoMode = 0, 43 NoMode = 0,
41 RotateMode = 1, 44 RotateMode = 1,
42 ZoomMode = 2, 45 ZoomMode = 2,
43 PanMode = 3, 46 PanMode = 3,
44 SelectMode = 4 47 TextMode = 4,
48 SelectMode = 5
45 }; 49 };
46 50
47 class Container; 51 class Container;
48 class FigureWindow; 52 class FigureWindow;
49 class MenuBar; 53 class MenuBar;
50 class ToolBar; 54 class ToolBar;
55
56 class MouseModeActionGroup;
51 57
52 class Figure : 58 class Figure :
53 public Object, 59 public Object,
54 public MenuContainer, 60 public MenuContainer,
55 public GenericEventNotifyReceiver 61 public GenericEventNotifyReceiver
62 Figure (const graphics_object& go, FigureWindow* win); 68 Figure (const graphics_object& go, FigureWindow* win);
63 ~Figure (void); 69 ~Figure (void);
64 70
65 static Figure* create (const graphics_object& go); 71 static Figure* create (const graphics_object& go);
66 72
67 MouseMode mouseMode (void) { return m_mouseMode; } 73 MouseMode mouseMode (void);
68 74
69 Container* innerContainer (void); 75 Container* innerContainer (void);
70 QWidget* menu (void); 76 QWidget* menu (void);
71 77
72 bool eventNotifyBefore (QObject* watched, QEvent* event); 78 bool eventNotifyBefore (QObject* watched, QEvent* event);
91 void showFigureToolBar (bool visible); 97 void showFigureToolBar (bool visible);
92 void showMenuBar (bool visible); 98 void showMenuBar (bool visible);
93 void addCustomToolBar (QToolBar* bar, bool visible); 99 void addCustomToolBar (QToolBar* bar, bool visible);
94 void showCustomToolBar (QToolBar* bar, bool visible); 100 void showCustomToolBar (QToolBar* bar, bool visible);
95 101
102 void updateFigureToolBarAndMenuBar (void);
103
96 static void updateBoundingBoxHelper (void*); 104 static void updateBoundingBoxHelper (void*);
97 105
98 private slots: 106 private slots:
99 void setMouseMode (MouseMode mode) { m_mouseMode = mode; } 107 void setMouseMode (MouseMode mode);
100 void fileNewFigure (void); 108 void fileNewFigure (void);
101 void fileCloseFigure (void); 109 void fileCloseFigure (void);
102 void editCopy (void); 110 void editCopy (void);
103 void editCut (void); 111 void editCut (void);
104 void editPaste (void); 112 void editPaste (void);
105 void helpAboutQtHandles (void); 113 void helpAboutQtHandles (void);
106 void updateMenuBar (void); 114 void updateMenuBar (void);
107 void updateContainer (void); 115 void updateContainer (void);
116 void toggleAxes (void);
117 void toggleGrid (void);
108 118
109 signals: 119 signals:
110 void asyncUpdate (void); 120 void asyncUpdate (void);
111 121
112 private: 122 private:
113 Container* m_container; 123 Container* m_container;
114 bool m_blockUpdates; 124 bool m_blockUpdates;
115 MouseMode m_mouseMode, m_lastMouseMode;
116 QToolBar* m_figureToolBar; 125 QToolBar* m_figureToolBar;
117 MenuBar* m_menuBar; 126 MenuBar* m_menuBar;
118 QRect m_innerRect; 127 QRect m_innerRect;
119 QRect m_outerRect; 128 QRect m_outerRect;
129 MouseModeActionGroup* m_mouseModeGroup;
120 }; 130 };
121 131
122 }; // namespace QtHandles 132 }; // namespace QtHandles
123 133
124 #endif 134 #endif