Mercurial > octave-nkf
annotate libgui/graphics/Canvas.cc @ 20115:908b68a98ba6
initial implementation of text annotations with Qt plotting
* Canvas.h, Canvas.cc (Canvas::annotation_callback): New function.
(Canvas::canvasMousePressEvent): Handle TextMode case.
* MouseModeActionGroup.cc
(MouseModeActionGroup::MouseModeActionGroup): Don't disable text
annotation button.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 16 Apr 2015 08:47:20 -0400 |
parents | 055ad6fbc910 |
children | c6c5cb9c4743 |
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 |
20038
f0e61a67ad9f
Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents:
20002
diff
changeset
|
3 Copyright (C) 2011-2015 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> |
20115
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
30 #include <QInputDialog> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <QList> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QMouseEvent> |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
33 #include <QWheelEvent> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <QRectF> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "Backend.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ContextMenu.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #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
|
40 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
42 #include "gl2ps-renderer.h" |
20115
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
43 #include "octave-qt-link.h" |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
44 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
45 #include "builtin-defun-decls.h" |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
46 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
50 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
51 Canvas::redraw (bool sync) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 { |
19988
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
53 QWidget *w = qWidget (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
54 |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
55 if (w) |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
56 { |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
57 if (sync) |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
58 w->repaint (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
59 else |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
60 w->update (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19931
diff
changeset
|
61 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
64 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
65 Canvas::blockRedraw (bool block) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 m_redrawBlocked = block; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
70 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
71 Canvas::setCursor (MouseMode mode) |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
72 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
73 QWidget *w = qWidget (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
74 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
75 if (w) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
76 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
77 static QCursor origCursor = w->cursor (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
78 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
79 switch (mode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
80 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
81 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
82 case RotateMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
83 w->setCursor (Qt::OpenHandCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
84 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
85 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
86 case ZoomInMode: |
19994
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19989
diff
changeset
|
87 w->setCursor (QPixmap (":/images/zoom-in.png")); |
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19989
diff
changeset
|
88 break; |
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19989
diff
changeset
|
89 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
90 case ZoomOutMode: |
19994
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19989
diff
changeset
|
91 w->setCursor (QPixmap (":/images/zoom-out.png")); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
92 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
93 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
94 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
95 w->setCursor (origCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
96 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
97 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
98 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
99 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
100 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
101 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
102 Canvas::print (const QString& file_cmd, const QString& term) |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
103 { |
19989
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19988
diff
changeset
|
104 gh_manager::auto_lock lock; |
19715
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
105 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
|
106 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
107 if (obj.valid_object ()) |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
108 { |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
109 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
|
110 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
111 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
|
112 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
113 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
114 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
115 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
116 Canvas::updateCurrentPoint(const graphics_object& fig, |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
117 const graphics_object& obj, QMouseEvent* event) |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
118 { |
19989
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19988
diff
changeset
|
119 gh_manager::auto_lock lock; |
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19988
diff
changeset
|
120 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
121 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
|
122 Utils::figureCurrentPoint (fig, event), false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
123 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
124 Matrix children = obj.get_properties ().get_children (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
125 octave_idx_type num_children = children.numel (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
126 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
127 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
|
128 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
129 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
|
130 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
131 if (childObj.isa ("axes")) |
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 axes::properties& ap = Utils::properties<axes> (childObj); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
134 Matrix x_zlim = ap.get_transform_zlim (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
135 graphics_xform x_form = ap.get_transform (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
136 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
137 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
|
138 x_zlim(0)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
139 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
|
140 x_zlim(1)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
141 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
142 Matrix cp (2, 3, 0.0); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
143 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
144 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
|
145 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
|
146 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
147 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
|
148 false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
149 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
150 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
151 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
152 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
153 void |
20115
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
154 Canvas::annotation_callback (const octave_value_list& args) |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
155 { |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
156 Ffeval (ovl ("annotation").append (args)); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
157 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
158 redraw (); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
159 } |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
160 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
161 void |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
162 Canvas::canvasToggleAxes (const graphics_handle& handle) |
19697
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")) |
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 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
|
183 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
184 redraw (true); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
185 } |
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 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
188 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
189 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
190 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
191 Canvas::canvasToggleGrid (const graphics_handle& handle) |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
192 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
193 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
194 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
195 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
|
196 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
197 if (go.valid_object ()) |
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 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
|
200 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
201 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
|
202 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
203 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
|
204 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
205 if (ax.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
206 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
207 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
|
208 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
209 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
|
210 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
211 std::string tmp; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
212 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
213 // 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
|
214 // on, then turn them off. |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
215 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
216 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
|
217 || ap.get_ygrid () == "off" |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
218 || ap.get_zgrid () == "off") |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
219 ? "on" : "off"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
220 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
221 ap.set_xgrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
222 ap.set_ygrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
223 ap.set_zgrid (state); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
224 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
225 redraw (true); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
226 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
227 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
228 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
229 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
230 |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
231 static void |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
232 autoscale_axes (axes::properties& 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 ap.clear_zoom_stack (); |
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 ap.set_xlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
237 ap.set_ylimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
238 ap.set_zlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
239 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
240 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
241 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
242 Canvas::canvasAutoAxes (const graphics_handle& handle) |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
243 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
244 gh_manager::auto_lock lock; |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
245 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
246 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
|
247 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
248 if (go.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
249 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
250 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
|
251 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
252 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
|
253 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
254 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
|
255 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
256 if (ax.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
257 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
258 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
|
259 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
260 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
|
261 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
262 autoscale_axes (ap); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
263 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
264 redraw (true); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
265 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
266 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
267 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
268 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
269 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
270 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
271 Canvas::canvasPaintEvent (void) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 if (! m_redrawBlocked) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 draw (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
279 if (m_mouseMode == ZoomInMode && m_mouseAxes.ok ()) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
280 drawZoomBox (m_mouseAnchor, m_mouseCurrent); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
284 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
285 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
|
286 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
287 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
288 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
289 = 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
|
290 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
291 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
|
292 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
293 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
|
294 } |
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 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
297 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
|
298 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
299 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
300 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
301 = 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
|
302 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
303 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
|
304 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
305 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
|
306 } |
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 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
309 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
|
310 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
311 // Getting rotate mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
312 octave_value ov_rm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
313 = 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
|
314 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
315 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
|
316 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
317 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
|
318 } |
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 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
321 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
|
322 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
323 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
324 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
325 = 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
|
326 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
327 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
|
328 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
329 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
|
330 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
331 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
332 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
333 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
|
334 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
335 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
336 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
337 = 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
|
338 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
339 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
|
340 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
341 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
|
342 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
343 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
344 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
345 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
|
346 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
347 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
348 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
349 = 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
|
350 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
351 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
|
352 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
353 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
|
354 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
355 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
356 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
357 Canvas::canvasMouseMoveEvent (QMouseEvent* event) |
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
|
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 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
|
360 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
|
361 |
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 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
|
363 { |
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 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
|
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 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
|
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 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
|
369 { |
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 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
|
371 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
|
372 |
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 // 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
|
374 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
|
375 |
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 // 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
|
377 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
|
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 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
|
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 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
|
382 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
|
383 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
|
384 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
|
385 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
|
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 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
|
388 { |
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 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
|
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 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
|
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 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
|
394 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
|
395 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
|
396 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
|
397 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
398 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
|
399 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
400 // 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
|
401 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
|
402 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
403 // 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
|
404 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
|
405 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
406 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
407 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
|
408 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
|
409 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
410 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
411 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
|
412 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
413 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
|
414 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
415 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
|
416 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
417 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
|
418 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
419 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
|
420 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
|
421 "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
|
422 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
423 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
424 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19905
diff
changeset
|
425 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
426 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
427 Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
428 { |
20075
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20044
diff
changeset
|
429 // same processing as normal click, but event type is MouseButtonDblClick |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
430 canvasMousePressEvent (event); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
431 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
432 |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
433 static double |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
434 button_number (QMouseEvent *event) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
435 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
436 double retval = 0; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
437 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
438 switch (event->button ()) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
439 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
440 case Qt::LeftButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
441 retval = 1; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
442 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
443 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
444 case Qt::MidButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
445 retval = 2; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
446 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
447 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
448 case Qt::RightButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
449 retval = 3; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
450 break; |
19816
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
451 |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
452 default: |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19799
diff
changeset
|
453 break; |
19799
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 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
456 return retval; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
457 } |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
458 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
459 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
460 Canvas::canvasMousePressEvent (QMouseEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
465 bool isdblclick = (event->type () == QEvent::MouseButtonDblClick); |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
466 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 graphics_object currentObj, axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 QList<graphics_object> axesList; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 Matrix children = obj.get_properties ().get_children (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 octave_idx_type num_children = children.numel (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 for (int i = 0; i < num_children; i++) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
477 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
478 graphics_object childObj (gh_manager::get_object (children(i))); |
18498
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 if (childObj.isa ("axes")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 axesList.append (childObj); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
482 else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel")) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
483 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
484 Matrix bb = childObj.get_properties ().get_boundingbox (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
485 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
|
486 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
487 r.adjust (-5, -5, 5, 5); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
488 if (r.contains (event->posF ())) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
489 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
490 currentObj = childObj; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
491 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
492 } |
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 } |
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 (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 it != axesList.end (); ++it) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 graphics_object go = selectFromAxes (*it, event->pos ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 if (go) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 currentObj = go; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 // FIXME: is this really necessary? the axes object should |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 // have been selected through selectFromAxes anyway |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 else if (it->get_properties ().is_hittest ()) |
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 Matrix bb = it->get_properties ().get_boundingbox (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 if (r.contains (event->posF ())) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 } |
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 (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 if (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 if (axesObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 currentObj = axesObj; |
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 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 currentObj = obj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 if (currentObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 .set_currentobject (currentObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 Utils::properties<figure> (figObj).set_currentobject (octave_NaN); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 MouseMode newMouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 if (fig) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
547 newMouseMode = fig->mouseMode (); |
18498
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 switch (newMouseMode) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
550 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
551 case NoMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
552 gh_manager::post_set (figObj.get_handle (), "selectiontype", |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
553 Utils::figureSelectionType (event, isdblclick), false); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
554 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
555 updateCurrentPoint (figObj, obj, event); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
556 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
557 gh_manager::post_callback (figObj.get_handle (), |
20034
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
20002
diff
changeset
|
558 "windowbuttondownfcn", |
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
20002
diff
changeset
|
559 button_number (event)); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
560 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 gh_manager::post_callback (currentObj.get_handle (), |
20034
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
20002
diff
changeset
|
562 "buttondownfcn", |
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
20002
diff
changeset
|
563 button_number (event)); |
19799
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19796
diff
changeset
|
564 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
565 if (event->button () == Qt::RightButton) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
566 ContextMenu::executeAt (currentObj.get_properties (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
567 event->globalPos ()); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
568 break; |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
569 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
570 case TextMode: |
20115
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
571 { |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
572 QWidget *w = qWidget (); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
573 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
574 if (! w) |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
575 break; |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
576 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
577 bool ok; |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
578 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
579 // FIXME: this dialog should allow multiple line text entry |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
580 // and also provide options for setting text properties of |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
581 // the text annotation. |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
582 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
583 QString text = QInputDialog::getText (w, "Annotation", "", |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
584 QLineEdit::Normal, "", &ok); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
585 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
586 if (! ok || text.isEmpty ()) |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
587 break; |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
588 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
589 Matrix bb = axesObj.get_properties ().get_boundingbox (false); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
590 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
591 QPoint pos = event->pos (); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
592 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
593 Matrix position (1, 4); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
594 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
595 position(0) = pos.x () / bb(2); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
596 position(1) = 1.0 - (pos.y () / bb(3)); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
597 position(2) = pos.x () / bb(2); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
598 position(3) = 1.0 - (pos.y () / bb(3)); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
599 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
600 octave_link::post_event (this, &Canvas::annotation_callback, |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
601 ovl ("textbox", position, |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
602 "string", text.toStdString ())); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20075
diff
changeset
|
603 } |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
604 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
605 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
606 case PanMode: |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
607 case RotateMode: |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
608 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
609 case ZoomOutMode: |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
610 if (axesObj) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
611 { |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
612 bool redraw_figure = true; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
613 |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
614 if (isdblclick) |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
615 { |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
616 if (event->button () == Qt::LeftButton) |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
617 { |
20075
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20044
diff
changeset
|
618 axes::properties& ap = Utils::properties<axes> (axesObj); |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
619 |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
620 autoscale_axes (ap); |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
621 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
622 else |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
623 { |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
624 redraw_figure = false; |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
625 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
626 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
627 else if (event->modifiers () == Qt::NoModifier) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
628 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
629 switch (event->buttons ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
630 { |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
631 case Qt::LeftButton: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
632 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
|
633 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
|
634 m_mouseMode = newMouseMode; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
635 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
636 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
637 case Qt::RightButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
638 Utils::properties<axes> (axesObj).unzoom (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
639 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
640 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
641 case Qt::MidButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
642 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
643 axes::properties& ap = |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
644 Utils::properties<axes> (axesObj); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 |
19905
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19901
diff
changeset
|
646 autoscale_axes (ap); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
647 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
648 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
649 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
650 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
651 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
652 break; |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
653 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
654 } |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
655 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
|
656 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
657 switch (event->buttons ()) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
658 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
659 case Qt::LeftButton: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
660 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
|
661 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
662 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
663 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
664 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
665 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
666 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
667 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
668 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
669 if (redraw_figure) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
670 redraw (false); |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
671 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
672 break; |
19796
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
673 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
674 default: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
675 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
676 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 } |
20044
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20041
diff
changeset
|
678 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
681 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
682 Canvas::canvasMouseReleaseEvent (QMouseEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
684 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
|
685 && m_mouseAxes.ok ()) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 if (ax.valid_object ()) |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
691 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
692 axes::properties& ap = Utils::properties<axes> (ax); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
694 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
|
695 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
696 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
|
697 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
698 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
|
699 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
700 if (m_mouseAnchor == event->pos ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
701 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
702 double factor = m_mouseMode == ZoomInMode ? 2.0 : 0.5; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 |
19929
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19922
diff
changeset
|
704 ColumnVector p1 = ap.pixel2coord (event->x (), event->y ()); |
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19922
diff
changeset
|
705 |
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19922
diff
changeset
|
706 ap.zoom_about_point (zm, p1(0), p1(1), factor); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
707 } |
20075
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20044
diff
changeset
|
708 else if (m_mouseMode == ZoomInMode) |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
709 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
710 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
|
711 m_mouseAnchor.y ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
712 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
|
713 event->y ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
715 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
|
716 Matrix yl (1, 2, 0.0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
717 |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
718 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
|
719 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
|
720 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
|
721 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
|
722 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
723 ap.zoom (zm, xl, yl); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
724 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 |
18726
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
726 redraw (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18646
diff
changeset
|
727 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 else if (m_mouseMode == NoMode) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 |
18646
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
738 updateCurrentPoint (figObj, obj, event); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 gh_manager::post_callback (figObj.get_handle (), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 "windowbuttonupfcn"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 m_mouseAxes = graphics_handle (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 m_mouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
748 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
749 Canvas::canvasWheelEvent (QWheelEvent* event) |
19697
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 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
752 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
|
753 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
754 if (obj.valid_object ()) |
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 std::string mode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
757 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
758 graphics_object axesObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
759 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
760 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
|
761 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
|
762 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
763 for (int i = 0; i < num_children; i++) |
19931
0e0a3bbe142f
Canvas.cc: Replace tabs with spaces.
Rik <rik@octave.org>
parents:
19929
diff
changeset
|
764 { |
0e0a3bbe142f
Canvas.cc: Replace tabs with spaces.
Rik <rik@octave.org>
parents:
19929
diff
changeset
|
765 graphics_object childObj (gh_manager::get_object (children(i))); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
766 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
767 if (childObj.isa ("axes")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
768 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
769 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
|
770 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
771 if (go) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
772 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
773 axesObj = childObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
774 break; |
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 } |
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 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
779 if (axesObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
780 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
781 MouseMode newMouseMode = NoMode; |
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 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
|
784 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
785 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
|
786 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
787 if (fig) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
788 newMouseMode = fig->mouseMode (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
789 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
790 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
|
791 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
792 Utils::properties<figure> (figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
793 .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
|
794 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
795 if (zoom_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
796 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
797 if (event->delta () > 0) |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
798 newMouseMode = ZoomInMode; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
799 else |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
800 newMouseMode = ZoomOutMode; |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
801 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
802 mode = zoom_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
803 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
804 else if (pan_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
805 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
806 newMouseMode = PanMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
807 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
808 mode = pan_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
809 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
810 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
811 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
812 bool redrawFigure = true; |
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 switch (newMouseMode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
815 { |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
816 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
817 case ZoomOutMode: |
19697
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 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
|
820 |
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
|
821 // 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
|
822 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
|
823 |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19715
diff
changeset
|
824 // 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
|
825 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
|
826 ? 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
|
827 : 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
|
828 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
829 // 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
|
830 |
19901
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19816
diff
changeset
|
831 ap.zoom (mode, factor); |
19697
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
832 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
833 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
834 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
835 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
836 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
837 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
|
838 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
839 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
|
840 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
841 ap.pan (mode, factor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
842 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
843 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
844 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
845 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
846 redrawFigure = false; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
847 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
848 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
849 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
850 if (redrawFigure) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
851 redraw (false); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
852 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
853 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
854 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18726
diff
changeset
|
855 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
856 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
857 Canvas::canvasKeyPressEvent (QKeyEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
858 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
859 if (m_eventMask & KeyPress) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
860 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
861 octave_scalar_map eventData = Utils::makeKeyEventStruct (event); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
862 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 gh_manager::post_set (m_handle, "currentcharacter", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
864 eventData.getfield ("Character"), false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
865 gh_manager::post_callback (m_handle, "keypressfcn", eventData); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
866 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
867 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
869 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
870 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
873 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
874 Canvas::canvasKeyReleaseEvent (QKeyEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
875 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
876 if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
877 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 gh_manager::post_callback (m_handle, "keyreleasefcn", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 Utils::makeKeyEventStruct (event)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
880 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
881 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
882 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
883 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
885 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
886 |
20002
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
887 Canvas* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
888 Canvas::create (const std::string& /* name */, QWidget* parent, |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19994
diff
changeset
|
889 const graphics_handle& handle) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
891 // Only OpenGL |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
892 return new GLCanvas (parent, handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
893 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
894 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
895 }; // namespace QtHandles |