Mercurial > octave-nkf
annotate libgui/graphics/Canvas.cc @ 19922:966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
* Canvas.cc (Canvas::canvasMouseMoveEvent): Get pan mode and pass it
to translate_view function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Mar 2015 20:48:00 -0500 |
parents | 815db217f6f4 |
children | ac18e88ea1bf |
rev | line source |
---|---|
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
3 Copyright (C) 2011-2014 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
10 option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
15 for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 #include <config.h> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <QApplication> |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
28 #include <QBitmap> |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
29 #include <QCursor> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QList> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QMouseEvent> |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
32 #include <QWheelEvent> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <QRectF> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "Backend.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "ContextMenu.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "GLCanvas.h" |
18505
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18501
diff
changeset
|
39 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
41 #include "gl2ps-renderer.h" |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
42 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 void Canvas::redraw (bool sync) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 if (sync) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 qWidget ()->repaint (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 qWidget ()->update (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 void Canvas::blockRedraw (bool block) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 m_redrawBlocked = block; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
59 void Canvas::setCursor (MouseMode mode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
60 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
61 QWidget *w = qWidget (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
62 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
63 if (w) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
64 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
65 static QCursor origCursor = w->cursor (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
66 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
67 switch (mode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
68 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
69 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
70 case RotateMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
71 w->setCursor (Qt::OpenHandCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
72 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
73 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
74 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
75 case ZoomOutMode: |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
76 // FIXME: distinguish zoom in/out. |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
77 w->setCursor (QBitmap (":/images/zoom.png")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
78 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
79 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
80 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
81 w->setCursor (origCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
82 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
83 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
84 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
85 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
86 |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
87 void Canvas::print (const QString& file_cmd, const QString& term) |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
88 { |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
89 graphics_object obj = gh_manager::get_object (m_handle); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
90 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
91 if (obj.valid_object ()) |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
92 { |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
93 graphics_object figObj (obj.get_ancestor ("figure")); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
94 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
95 gl2ps_print (figObj, file_cmd.toStdString (), term.toStdString ()); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
96 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
97 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
98 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
99 void Canvas::updateCurrentPoint(const graphics_object& fig, |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
100 const graphics_object& obj, QMouseEvent* event) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
101 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
102 gh_manager::post_set (fig.get_handle (), "currentpoint", |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
103 Utils::figureCurrentPoint (fig, event), false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
104 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
105 Matrix children = obj.get_properties ().get_children (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
106 octave_idx_type num_children = children.numel (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
107 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
108 for (int i = 0; i < num_children; i++) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
109 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
110 graphics_object childObj (gh_manager::get_object (children(i))); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
111 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
112 if (childObj.isa ("axes")) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
113 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
114 axes::properties& ap = Utils::properties<axes> (childObj); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
115 Matrix x_zlim = ap.get_transform_zlim (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
116 graphics_xform x_form = ap.get_transform (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
117 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
118 ColumnVector p1 = x_form.untransform (event->x (), event->y (), |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
119 x_zlim(0)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
120 ColumnVector p2 = x_form.untransform (event->x (), event->y (), |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
121 x_zlim(1)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
122 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
123 Matrix cp (2, 3, 0.0); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
124 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
125 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
126 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
127 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
128 gh_manager::post_set (childObj.get_handle (), "currentpoint", cp, |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
129 false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
130 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
131 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
132 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
133 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
134 void Canvas::canvasToggleAxes (const graphics_handle& handle) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
135 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
136 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
137 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
138 graphics_object go = gh_manager::get_object (handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
139 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
140 if (go.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
141 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
142 figure::properties& fp = Utils::properties<figure> (go); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
143 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
144 graphics_handle ah = fp.get_currentaxes (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
145 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
146 graphics_object ax = gh_manager::get_object (ah); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
147 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
148 if (ax.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
149 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
150 axes::properties& ap = Utils::properties<axes> (ax); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
151 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
152 if (ap.handlevisibility_is ("on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
153 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
154 ap.set_visible (! ap.is_visible ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
155 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
156 redraw (true); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
157 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
158 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
159 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
160 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
161 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
162 void Canvas::canvasToggleGrid (const graphics_handle& handle) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
163 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
164 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
165 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
166 graphics_object go = gh_manager::get_object (handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
167 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
168 if (go.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
169 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
170 figure::properties& fp = Utils::properties<figure> (go); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
171 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
172 graphics_handle ah = fp.get_currentaxes (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
173 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
174 graphics_object ax = gh_manager::get_object (ah); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
175 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
176 if (ax.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
177 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
178 axes::properties& ap = Utils::properties<axes> (ax); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
179 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
180 if (ap.handlevisibility_is ("on") && ap.is_visible ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
181 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
182 std::string tmp; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
183 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
184 // If any grid is off, then turn them all on. If they are all |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
185 // on, then turn them off. |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
186 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
187 std::string state = ((ap.get_xgrid () == "off" |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
188 || ap.get_ygrid () == "off" |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
189 || ap.get_zgrid () == "off") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
190 ? "on" : "off"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
191 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
192 ap.set_xgrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
193 ap.set_ygrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
194 ap.set_zgrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
195 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
196 redraw (true); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
197 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
198 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
199 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
200 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
201 |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
202 static void |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
203 autoscale_axes (axes::properties& ap) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
204 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
205 ap.clear_zoom_stack (); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
206 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
207 ap.set_xlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
208 ap.set_ylimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
209 ap.set_zlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
210 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
211 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
212 void Canvas::canvasAutoAxes (const graphics_handle& handle) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
213 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
214 gh_manager::auto_lock lock; |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
215 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
216 graphics_object go = gh_manager::get_object (handle); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
217 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
218 if (go.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
219 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
220 figure::properties& fp = Utils::properties<figure> (go); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
221 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
222 graphics_handle ah = fp.get_currentaxes (); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
223 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
224 graphics_object ax = gh_manager::get_object (ah); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
225 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
226 if (ax.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
227 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
228 axes::properties& ap = Utils::properties<axes> (ax); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
229 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
230 if (ap.handlevisibility_is ("on") && ap.is_visible ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
231 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
232 autoscale_axes (ap); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
233 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
234 redraw (true); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
235 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
236 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
237 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
238 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
239 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 void Canvas::canvasPaintEvent (void) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 if (! m_redrawBlocked) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 draw (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
248 if (m_mouseMode == ZoomInMode && m_mouseAxes.ok ()) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
249 drawZoomBox (m_mouseAnchor, m_mouseCurrent); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
253 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
254 pan_enabled (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
255 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
256 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
257 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
258 = Utils::properties<figure> (figObj).get___pan_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
259 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
260 octave_scalar_map pm = ov_pm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
261 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
262 return pm.contents ("Enable").string_value () == "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
263 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
264 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
265 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
266 pan_mode (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
267 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
268 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
269 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
270 = Utils::properties<figure> (figObj).get___pan_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
271 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
272 octave_scalar_map pm = ov_pm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
273 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
274 return pm.contents ("Motion").string_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
275 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
276 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
277 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
278 rotate_enabled (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
279 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
280 // Getting rotate mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
281 octave_value ov_rm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
282 = Utils::properties<figure> (figObj).get___rotate_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
283 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
284 octave_scalar_map rm = ov_rm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
285 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
286 return rm.contents ("Enable").string_value () == "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
287 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
288 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
289 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
290 zoom_enabled (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
291 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
292 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
293 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
294 = Utils::properties<figure> (figObj).get___zoom_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
295 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
296 octave_scalar_map zm = ov_zm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
297 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
298 return zm.contents ("Enable").string_value () == "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
299 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
300 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
301 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
302 zoom_mode (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
303 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
304 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
305 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
306 = Utils::properties<figure> (figObj).get___zoom_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
307 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
308 octave_scalar_map zm = ov_zm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
309 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
310 return zm.contents ("Motion").string_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
311 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
312 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
313 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
314 zoom_direction (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
315 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
316 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
317 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
318 = Utils::properties<figure> (figObj).get___zoom_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
319 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
320 octave_scalar_map zm = ov_zm.scalar_map_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
321 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
322 return zm.contents ("Direction").string_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
323 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
324 |
19922
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
325 void Canvas::canvasMouseMoveEvent (QMouseEvent* event) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
326 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
327 gh_manager::auto_lock lock; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
328 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
329 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
330 if (m_mouseMode != NoMode && ax.valid_object ()) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
331 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
332 axes::properties& ap = Utils::properties<axes> (ax); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
333 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
334 switch (m_mouseMode) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
335 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
336 case RotateMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
337 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
338 ap.rotate3d (m_mouseCurrent.x (), event->x (), |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
339 m_mouseCurrent.y (), event->y ()); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
340 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
341 // Update current mouse position |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
342 m_mouseCurrent = event->pos (); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
343 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
344 // Force immediate redraw |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
345 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
346 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
347 break; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
348 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
349 case ZoomInMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
350 case ZoomOutMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
351 m_mouseCurrent = event->pos (); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
352 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
353 break; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
354 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
355 case PanMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
356 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
357 graphics_object figObj (ax.get_ancestor ("figure")); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
358 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
359 std::string mode = pan_mode (figObj); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
360 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
361 ColumnVector p0 = ap.pixel2coord (m_mouseCurrent.x (), |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
362 m_mouseCurrent.y ()); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
363 ColumnVector p1 = ap.pixel2coord (event->x (), |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
364 event->y ()); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
365 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
366 ap.translate_view (mode, p0(0), p1(0), p0(1), p1(1)); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
367 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
368 // Update current mouse position |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
369 m_mouseCurrent = event->pos (); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
370 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
371 // Force immediate redraw |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
372 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
373 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
374 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
375 default: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
376 break; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
377 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
378 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
379 else if (m_mouseMode == NoMode) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
380 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
381 graphics_object obj = gh_manager::get_object (m_handle); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
382 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
383 if (obj.valid_object ()) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
384 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
385 graphics_object figObj (obj.get_ancestor ("figure")); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
386 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
387 updateCurrentPoint (figObj, obj, event); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
388 gh_manager::post_callback (figObj.get_handle (), |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
389 "windowbuttonmotionfcn"); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
390 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
391 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
392 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
393 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
394 void Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
395 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
396 if (event->buttons () != Qt::LeftButton) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
397 return; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
398 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
399 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
400 graphics_object obj = gh_manager::get_object (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
401 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
402 if (obj.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
403 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
404 graphics_object axesObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
405 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
406 Matrix children = obj.get_properties ().get_children (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
407 octave_idx_type num_children = children.numel (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
408 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
409 for (int i = 0; i < num_children; i++) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
410 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
411 graphics_object childObj (gh_manager::get_object (children(i))); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
412 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
413 if (childObj.isa ("axes")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
414 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
415 graphics_object go = selectFromAxes (childObj, event->pos ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
416 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
417 if (go) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
418 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
419 axesObj = childObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
420 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
421 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
422 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
423 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
424 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
425 bool redrawFigure = true; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
426 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
427 if (axesObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
428 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
429 graphics_object figObj (obj.get_ancestor ("figure")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
430 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
431 if (axesObj.get_properties ().handlevisibility_is ("on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
432 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
433 Utils::properties<figure> (figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
434 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
435 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
436 if (pan_enabled (figObj) || rotate_enabled (figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
437 || zoom_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
438 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
439 axes::properties& ap = |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
440 Utils::properties<axes> (axesObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
441 |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
442 autoscale_axes (ap); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
443 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
444 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
445 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
446 if (redrawFigure) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
447 redraw (false); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
448 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
449 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
450 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
451 |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
452 static double |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
453 button_number (QMouseEvent *event) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
454 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
455 double retval = 0; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
456 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
457 switch (event->button ()) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
458 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
459 case Qt::LeftButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
460 retval = 1; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
461 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
462 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
463 case Qt::MidButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
464 retval = 2; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
465 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
466 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
467 case Qt::RightButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
468 retval = 3; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
469 break; |
19816
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
470 |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
471 default: |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
472 break; |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
473 } |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
474 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
475 return retval; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
476 } |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
477 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 void Canvas::canvasMousePressEvent (QMouseEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 graphics_object currentObj, axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 QList<graphics_object> axesList; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 Matrix children = obj.get_properties ().get_children (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 octave_idx_type num_children = children.numel (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 for (int i = 0; i < num_children; i++) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
493 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
494 graphics_object childObj (gh_manager::get_object (children(i))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
496 if (childObj.isa ("axes")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 axesList.append (childObj); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
498 else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel")) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
499 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
500 Matrix bb = childObj.get_properties ().get_boundingbox (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
501 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
503 r.adjust (-5, -5, 5, 5); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
504 if (r.contains (event->posF ())) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
505 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
506 currentObj = childObj; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
507 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
508 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
509 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
510 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 it != axesList.end (); ++it) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 graphics_object go = selectFromAxes (*it, event->pos ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 if (go) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 currentObj = go; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 // FIXME: is this really necessary? the axes object should |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 // have been selected through selectFromAxes anyway |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 else if (it->get_properties ().is_hittest ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 Matrix bb = it->get_properties ().get_boundingbox (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 if (r.contains (event->posF ())) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 if (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 if (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 if (axesObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 currentObj = axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 currentObj = obj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 if (currentObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 .set_currentobject (currentObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 Utils::properties<figure> (figObj).set_currentobject (octave_NaN); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 MouseMode newMouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 if (fig) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
563 newMouseMode = fig->mouseMode (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 switch (newMouseMode) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
566 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
567 case NoMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
568 gh_manager::post_set (figObj.get_handle (), "selectiontype", |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
569 Utils::figureSelectionType (event), false); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
570 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
571 updateCurrentPoint (figObj, obj, event); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
572 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
573 gh_manager::post_callback (figObj.get_handle (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
574 "windowbuttondownfcn"); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
575 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 gh_manager::post_callback (currentObj.get_handle (), |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
577 "buttondownfcn", button_number (event)); |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
578 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
579 if (event->button () == Qt::RightButton) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
580 ContextMenu::executeAt (currentObj.get_properties (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
581 event->globalPos ()); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
582 break; |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
583 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
584 case TextMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
585 // Handle text insertion here. |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
586 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
587 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
588 case PanMode: |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
589 case RotateMode: |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
590 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
591 case ZoomOutMode: |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
592 if (axesObj) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
593 { |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
594 bool redraw_figure = true; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
595 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
596 if (event->modifiers () == Qt::NoModifier) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
597 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
598 switch (event->buttons ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
599 { |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
600 case Qt::LeftButton: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
601 m_mouseAnchor = m_mouseCurrent = event->pos (); |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
602 m_mouseAxes = axesObj.get_handle (); |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
603 m_mouseMode = newMouseMode; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
604 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
605 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
606 case Qt::RightButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
607 Utils::properties<axes> (axesObj).unzoom (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
608 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
609 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
610 case Qt::MidButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
611 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
612 axes::properties& ap = |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
613 Utils::properties<axes> (axesObj); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
615 autoscale_axes (ap); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
616 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
617 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
618 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
619 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
620 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
621 break; |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
622 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
623 } |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
624 else if (event->modifiers () == Qt::ShiftModifier) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
625 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
626 switch (event->buttons ()) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
627 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
628 case Qt::LeftButton: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
629 Utils::properties<axes> (axesObj).unzoom (); |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
630 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
631 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
632 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
633 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
634 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
635 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
636 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
637 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
638 if (redraw_figure) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
639 redraw (false); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
640 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
641 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
642 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
643 default: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
644 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
645 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 void Canvas::canvasMouseReleaseEvent (QMouseEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
651 if ((m_mouseMode == ZoomInMode || m_mouseMode == ZoomOutMode) |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
652 && m_mouseAxes.ok ()) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
653 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 if (ax.valid_object ()) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
658 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
659 axes::properties& ap = Utils::properties<axes> (ax); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
661 graphics_object obj = gh_manager::get_object (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
662 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
663 graphics_object figObj (obj.get_ancestor ("figure")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
664 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
665 std::string zm = zoom_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
666 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
667 if (m_mouseAnchor == event->pos ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
668 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
669 double factor = m_mouseMode == ZoomInMode ? 2.0 : 0.5; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
671 ap.zoom (zm, factor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
672 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
673 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
674 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
675 ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
676 m_mouseAnchor.y ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
677 ColumnVector p1 = ap.pixel2coord (event->x (), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
678 event->y ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
680 Matrix xl (1, 2, 0.0); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
681 Matrix yl (1, 2, 0.0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
683 xl(0) = std::min (p0(0), p1(0)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
684 xl(1) = std::max (p0(0), p1(0)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
685 yl(0) = std::min (p0(1), p1(1)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
686 yl(1) = std::max (p0(1), p1(1)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
687 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
688 ap.zoom (zm, xl, yl); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
689 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
691 redraw (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
692 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 else if (m_mouseMode == NoMode) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
703 updateCurrentPoint (figObj, obj, event); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 gh_manager::post_callback (figObj.get_handle (), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 "windowbuttonupfcn"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 m_mouseAxes = graphics_handle (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 m_mouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
713 void Canvas::canvasWheelEvent (QWheelEvent* event) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
714 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
715 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
716 graphics_object obj = gh_manager::get_object (m_handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
717 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
718 if (obj.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
719 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
720 std::string mode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
721 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
722 graphics_object axesObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
723 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
724 Matrix children = obj.get_properties ().get_children (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
725 octave_idx_type num_children = children.numel (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
726 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
727 for (int i = 0; i < num_children; i++) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
728 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
729 graphics_object childObj (gh_manager::get_object (children(i))); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
730 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
731 if (childObj.isa ("axes")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
732 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
733 graphics_object go = selectFromAxes (childObj, event->pos ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
734 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
735 if (go) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
736 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
737 axesObj = childObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
738 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
739 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
740 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
741 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
742 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
743 if (axesObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
744 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
745 MouseMode newMouseMode = NoMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
746 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
747 graphics_object figObj (obj.get_ancestor ("figure")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
748 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
749 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
750 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
751 if (fig) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
752 newMouseMode = fig->mouseMode (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
753 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
754 if (axesObj.get_properties ().handlevisibility_is ("on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
755 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
756 Utils::properties<figure> (figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
757 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
758 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
759 if (zoom_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
760 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
761 if (event->delta () > 0) |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
762 newMouseMode = ZoomInMode; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
763 else |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
764 newMouseMode = ZoomOutMode; |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
765 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
766 mode = zoom_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
767 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
768 else if (pan_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
769 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
770 newMouseMode = PanMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
771 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
772 mode = pan_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
773 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
774 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
775 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
776 bool redrawFigure = true; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
777 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
778 switch (newMouseMode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
779 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
780 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
781 case ZoomOutMode: |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
782 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
783 axes::properties& ap = Utils::properties<axes> (axesObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
784 |
19793
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
785 // Control how fast to zoom when using scroll wheel. |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
786 double wheel_zoom_speed = ap.get_mousewheelzoom (); |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
787 |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
788 // Determine if we're zooming in or out. |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
789 double factor = (newMouseMode == ZoomInMode |
19793
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
790 ? 1 / (1.0 - wheel_zoom_speed) |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
791 : 1.0 - wheel_zoom_speed); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
792 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
793 // FIXME: should we zoom about point for 2D plots? |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
794 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
795 ap.zoom (mode, factor); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
796 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
797 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
798 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
799 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
800 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
801 axes::properties& ap = Utils::properties<axes> (axesObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
802 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
803 double factor = event->delta () > 0 ? 0.1 : -0.1; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
804 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
805 ap.pan (mode, factor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
806 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
807 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
808 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
809 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
810 redrawFigure = false; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
811 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
812 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
813 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
814 if (redrawFigure) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
815 redraw (false); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
816 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
817 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
818 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
819 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
820 bool Canvas::canvasKeyPressEvent (QKeyEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
821 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
822 if (m_eventMask & KeyPress) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 octave_scalar_map eventData = Utils::makeKeyEventStruct (event); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 gh_manager::post_set (m_handle, "currentcharacter", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
827 eventData.getfield ("Character"), false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 gh_manager::post_callback (m_handle, "keypressfcn", eventData); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
829 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
830 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
833 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
834 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
835 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 bool Canvas::canvasKeyReleaseEvent (QKeyEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
838 if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
839 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
840 gh_manager::post_callback (m_handle, "keyreleasefcn", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
841 Utils::makeKeyEventStruct (event)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
842 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
843 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
844 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
845 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
846 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
847 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
849 Canvas* Canvas::create (const std::string& /* name */, QWidget* parent, |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
850 const graphics_handle& handle) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
851 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
852 // Only OpenGL |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
853 return new GLCanvas (parent, handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
854 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
855 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
856 }; // namespace QtHandles |