Mercurial > octave
annotate libgui/graphics/Canvas.cc @ 22323:bac0d6f07a3e
maint: Update copyright notices for 2016.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Aug 2016 01:05:19 -0400 |
parents | 2fd4f1a3f4a8 |
children | c69805d1fa64 |
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 |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22250
diff
changeset
|
3 Copyright (C) 2011-2016 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 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18498
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> |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
28 #include <QBitmap> |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
29 #include <QCursor> |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
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> |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
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 |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
20090
diff
changeset
|
42 #include "annotation-dialog.h" |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
20090
diff
changeset
|
43 |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
44 #include "gl2ps-print.h" |
21196
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
20596
diff
changeset
|
45 #include "oct-opengl.h" |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
46 #include "octave-qt-link.h" |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
47 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
48 #include "builtin-defun-decls.h" |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
49 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
53 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
54 Canvas::redraw (bool sync) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
19953
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
56 QWidget *w = qWidget (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
57 |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
58 if (w) |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
59 { |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
60 if (sync) |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
61 w->repaint (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
62 else |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
63 w->update (); |
ed51e17f6ccf
avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents:
19896
diff
changeset
|
64 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
67 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
68 Canvas::blockRedraw (bool block) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 m_redrawBlocked = block; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
73 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
74 Canvas::setCursor (MouseMode mode) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
75 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
76 QWidget *w = qWidget (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
77 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
78 if (w) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
79 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
80 static QCursor origCursor = w->cursor (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
81 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
82 switch (mode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
83 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
84 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
85 case RotateMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
86 w->setCursor (Qt::OpenHandCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
87 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
88 |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
89 case ZoomInMode: |
19959
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19954
diff
changeset
|
90 w->setCursor (QPixmap (":/images/zoom-in.png")); |
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19954
diff
changeset
|
91 break; |
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19954
diff
changeset
|
92 |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
93 case ZoomOutMode: |
19959
210b301a3e39
different cursors for zoom in/out on qthandles canvas
Johannes Leuschner <jhnnslschnr@gmail.com>
parents:
19954
diff
changeset
|
94 w->setCursor (QPixmap (":/images/zoom-out.png")); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
95 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
96 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
97 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
98 w->setCursor (origCursor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
99 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
100 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
101 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
102 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
103 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
104 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
105 Canvas::print (const QString& file_cmd, const QString& term) |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
106 { |
19954
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19953
diff
changeset
|
107 gh_manager::auto_lock lock; |
19681
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
108 graphics_object obj = gh_manager::get_object (m_handle); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
109 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
110 if (obj.valid_object ()) |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
111 { |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
112 graphics_object figObj (obj.get_ancestor ("figure")); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
113 |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
114 gl2ps_print (figObj, file_cmd.toStdString (), term.toStdString ()); |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
115 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
116 } |
35bca657d74d
printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
117 |
20110
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
118 /* |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
119 Two updateCurrentPoint() routines are required: |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
120 1) Used for QMouseEvents where cursor position data is in callback from Qt. |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
121 2) Used for QKeyEvents where cursor position must be determined. |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
122 */ |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
123 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
124 Canvas::updateCurrentPoint(const graphics_object& fig, |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
125 const graphics_object& obj, QMouseEvent* event) |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
126 { |
19954
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19953
diff
changeset
|
127 gh_manager::auto_lock lock; |
b6061813a693
always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents:
19953
diff
changeset
|
128 |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
129 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
|
130 Utils::figureCurrentPoint (fig, event), false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
131 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
132 Matrix children = obj.get_properties ().get_children (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
133 octave_idx_type num_children = children.numel (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
134 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
135 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
|
136 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
137 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
|
138 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
139 if (childObj.isa ("axes")) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
140 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
141 axes::properties& ap = Utils::properties<axes> (childObj); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
142 Matrix x_zlim = ap.get_transform_zlim (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
143 graphics_xform x_form = ap.get_transform (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
144 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
145 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
|
146 x_zlim(0)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
147 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
|
148 x_zlim(1)); |
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 Matrix cp (2, 3, 0.0); |
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 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
|
153 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
|
154 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
155 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
|
156 false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
157 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
158 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
159 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
160 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
161 void |
20110
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
162 Canvas::updateCurrentPoint(const graphics_object& fig, |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
163 const graphics_object& obj) |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
164 { |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
165 gh_manager::auto_lock lock; |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
166 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
167 gh_manager::post_set (fig.get_handle (), "currentpoint", |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
168 Utils::figureCurrentPoint (fig), false); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
169 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
170 Matrix children = obj.get_properties ().get_children (); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
171 octave_idx_type num_children = children.numel (); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
172 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
173 for (int i = 0; i < num_children; i++) |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
174 { |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
175 graphics_object childObj (gh_manager::get_object (children(i))); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
176 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
177 if (childObj.isa ("axes")) |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
178 { |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
179 // FIXME: QCursor::pos() may give inaccurate results with asynchronous |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
180 // window systems like X11 over ssh. |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
181 QWidget *w = qWidget (); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
182 QPoint p = w->mapFromGlobal (QCursor::pos ()); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
183 axes::properties& ap = Utils::properties<axes> (childObj); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
184 Matrix x_zlim = ap.get_transform_zlim (); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
185 graphics_xform x_form = ap.get_transform (); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
186 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
187 ColumnVector p1 = x_form.untransform (p.x (), p.y (), x_zlim(0)); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
188 ColumnVector p2 = x_form.untransform (p.x (), p.y (), x_zlim(1)); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
189 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
190 Matrix cp (2, 3, 0.0); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
191 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
192 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
193 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
194 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
195 gh_manager::post_set (childObj.get_handle (), "currentpoint", cp, |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
196 false); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
197 } |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
198 } |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
199 } |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
200 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
201 void |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
202 Canvas::annotation_callback (const octave_value_list& args) |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
203 { |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
204 Ffeval (ovl ("annotation").append (args)); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
205 |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
206 redraw (); |
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
207 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20110
diff
changeset
|
208 |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
209 void |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
210 Canvas::canvasToggleAxes (const graphics_handle& handle) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
211 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
212 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
213 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
214 graphics_object go = gh_manager::get_object (handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
215 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
216 if (go.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
217 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
218 figure::properties& fp = Utils::properties<figure> (go); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
219 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
220 graphics_handle ah = fp.get_currentaxes (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
221 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
222 graphics_object ax = gh_manager::get_object (ah); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
223 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
224 if (ax.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
225 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
226 axes::properties& ap = Utils::properties<axes> (ax); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
227 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
228 if (ap.handlevisibility_is ("on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
229 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
230 ap.set_visible (! ap.is_visible ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
231 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
232 redraw (true); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
233 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
234 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
235 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
236 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
237 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
238 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
239 Canvas::canvasToggleGrid (const graphics_handle& handle) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
240 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
241 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
242 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
243 graphics_object go = gh_manager::get_object (handle); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
244 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
245 if (go.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
246 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
247 figure::properties& fp = Utils::properties<figure> (go); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
248 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
249 graphics_handle ah = fp.get_currentaxes (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
250 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
251 graphics_object ax = gh_manager::get_object (ah); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
252 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
253 if (ax.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
254 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
255 axes::properties& ap = Utils::properties<axes> (ax); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
256 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
257 std::string tmp; |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
258 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
259 // If any grid is off, then turn them all on. If they are all |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
260 // on, then turn them off. |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
261 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
262 std::string state = ((ap.get_xgrid () == "off" |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
263 || ap.get_ygrid () == "off" |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
264 || ap.get_zgrid () == "off") |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
265 ? "on" : "off"); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
266 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
267 ap.set_xgrid (state); |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
268 ap.set_ygrid (state); |
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
269 ap.set_zgrid (state); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
270 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
271 redraw (true); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
272 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
273 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
274 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
275 |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
276 static void |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
277 autoscale_axes (axes::properties& ap) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
278 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
279 ap.clear_zoom_stack (); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
280 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
281 ap.set_xlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
282 ap.set_ylimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
283 ap.set_zlimmode ("auto"); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
284 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
285 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
286 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
287 Canvas::canvasAutoAxes (const graphics_handle& handle) |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
288 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
289 gh_manager::auto_lock lock; |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
290 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
291 graphics_object go = gh_manager::get_object (handle); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
292 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
293 if (go.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
294 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
295 figure::properties& fp = Utils::properties<figure> (go); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
296 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
297 graphics_handle ah = fp.get_currentaxes (); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
298 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
299 graphics_object ax = gh_manager::get_object (ah); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
300 |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
301 if (ax.valid_object ()) |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
302 { |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
303 axes::properties& ap = Utils::properties<axes> (ax); |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
304 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
305 autoscale_axes (ap); |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
306 |
20216
9866b3202c52
Let grid and autoscale buttons work when the axes is invisible (bug #44436)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
307 redraw (true); |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
308 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
309 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
310 } |
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
311 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
312 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
313 Canvas::canvasPaintEvent (void) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 if (! m_redrawBlocked) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 draw (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
321 if ((m_mouseMode == ZoomInMode && m_mouseAxes.ok ()) || m_rectMode) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
322 drawZoomBox (m_mouseAnchor, m_mouseCurrent); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
326 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
327 pan_enabled (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
328 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
329 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
330 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
331 = Utils::properties<figure> (figObj).get___pan_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
332 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
333 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:
18692
diff
changeset
|
334 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
335 return pm.contents ("Enable").string_value () == "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
336 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
337 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
338 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
339 pan_mode (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
340 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
341 // Getting pan mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
342 octave_value ov_pm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
343 = Utils::properties<figure> (figObj).get___pan_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
344 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
345 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:
18692
diff
changeset
|
346 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
347 return pm.contents ("Motion").string_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
348 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
349 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
350 static bool |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
351 zoom_enabled (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
352 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
353 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
354 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
355 = Utils::properties<figure> (figObj).get___zoom_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
356 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
357 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:
18692
diff
changeset
|
358 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
359 return zm.contents ("Enable").string_value () == "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
360 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
361 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
362 static std::string |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
363 zoom_mode (const graphics_object figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
364 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
365 // Getting zoom mode property: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
366 octave_value ov_zm |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
367 = Utils::properties<figure> (figObj).get___zoom_mode__ (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
368 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
369 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:
18692
diff
changeset
|
370 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
371 return zm.contents ("Motion").string_value (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
372 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
373 |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
374 void |
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
375 Canvas::select_object (graphics_object obj, QMouseEvent* event, |
20472
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
376 graphics_object ¤tObj, graphics_object &axesObj, |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
377 bool axes_only) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
378 { |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
379 QList<graphics_object> axesList; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
380 Matrix children = obj.get_properties ().get_all_children (); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
381 octave_idx_type num_children = children.numel (); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
382 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
383 for (int i = 0; i < num_children; i++) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
384 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
385 graphics_object childObj (gh_manager::get_object (children(i))); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
386 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
387 if (childObj.isa ("axes")) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
388 axesList.append (childObj); |
21824
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
21724
diff
changeset
|
389 else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel") |
6780a8657be3
Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
21724
diff
changeset
|
390 || childObj.isa ("uibuttongroup")) |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
391 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
392 Matrix bb = childObj.get_properties ().get_boundingbox (false); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
393 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
394 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
395 r.adjust (-5, -5, 5, 5); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
396 |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
397 #if (HAVE_QT4) |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
398 bool rect_contains_pos = r.contains (event->posF ()); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
399 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
400 bool rect_contains_pos = r.contains (event->localPos ()); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
401 #endif |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
402 if (rect_contains_pos) |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
403 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
404 currentObj = childObj; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
405 break; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
406 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
407 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
408 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
409 |
20472
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
410 if (axes_only) |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
411 { |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
412 QPoint pt = event->pos (); |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
413 |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
414 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
415 it != axesList.end (); ++it) |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
416 { |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
417 const axes::properties& ap = |
20472
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
418 dynamic_cast<const axes::properties&> ((*it).get_properties ()); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
419 |
20472
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
420 ColumnVector p0 = ap.pixel2coord (pt.x (), pt.y ()); |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
421 Matrix xlim = ap.get_xlim ().matrix_value (); |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
422 Matrix ylim = ap.get_ylim ().matrix_value (); |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
423 |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
424 if (xlim(0) < p0(0) && xlim(1) > p0(0) |
20472
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
425 && ylim(0) < p0(1) && ylim(1) > p0(1)) |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
426 { |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
427 axesObj = *it; |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
428 return; |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
429 } |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
430 } |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
431 } |
2d415c68213f
Don't use GL_SELECT to find axes objects in Qt figures (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20292
diff
changeset
|
432 else if (! currentObj) |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
433 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
434 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
435 it != axesList.end (); ++it) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
436 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
437 graphics_object go = selectFromAxes (*it, event->pos ()); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
438 |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
439 if (go) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
440 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
441 currentObj = go; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
442 axesObj = *it; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
443 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
444 // FIXME: is this really necessary? the axes object should |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
445 // have been selected through selectFromAxes anyway |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
446 else if (it->get_properties ().is_hittest ()) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
447 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
448 Matrix bb = it->get_properties ().get_boundingbox (true); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
449 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
450 |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
451 #if defined (HAVE_QT4) |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
452 bool rect_contains_pos = r.contains (event->posF ()); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
453 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
454 bool rect_contains_pos = r.contains (event->localPos ()); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
455 #endif |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
21824
diff
changeset
|
456 if (rect_contains_pos) |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
457 axesObj = *it; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
458 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
459 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
460 if (axesObj && currentObj) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
461 break; |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
462 } |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
463 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
464 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
465 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
466 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
467 Canvas::canvasMouseMoveEvent (QMouseEvent* event) |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
468 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
469 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:
19870
diff
changeset
|
470 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:
19870
diff
changeset
|
471 |
20245
a5f9bf4df254
Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20244
diff
changeset
|
472 if (m_mouseMode != NoMode && (ax.valid_object () || m_mouseMode == TextMode)) |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
473 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
474 switch (m_mouseMode) |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
475 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
476 case RotateMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
477 { |
20245
a5f9bf4df254
Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20244
diff
changeset
|
478 axes::properties& ap = Utils::properties<axes> (ax); |
a5f9bf4df254
Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20244
diff
changeset
|
479 |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
480 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:
19870
diff
changeset
|
481 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:
19870
diff
changeset
|
482 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
483 // 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:
19870
diff
changeset
|
484 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:
19870
diff
changeset
|
485 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
486 // Force immediate redraw |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
487 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
488 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
489 break; |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
490 case TextMode: |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
491 case ZoomInMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
492 case ZoomOutMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
493 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:
19870
diff
changeset
|
494 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
495 break; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
496 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
497 case PanMode: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
498 { |
20245
a5f9bf4df254
Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20244
diff
changeset
|
499 axes::properties& ap = Utils::properties<axes> (ax); |
a5f9bf4df254
Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20244
diff
changeset
|
500 |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
501 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:
19870
diff
changeset
|
502 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
503 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:
19870
diff
changeset
|
504 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
505 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:
19870
diff
changeset
|
506 m_mouseCurrent.y ()); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
507 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:
19870
diff
changeset
|
508 event->y ()); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
509 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
510 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:
19870
diff
changeset
|
511 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
512 // 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:
19870
diff
changeset
|
513 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:
19870
diff
changeset
|
514 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
515 // Force immediate redraw |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
516 redraw (true); |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
517 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
518 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
519 default: |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
520 break; |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
521 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
522 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
523 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:
19870
diff
changeset
|
524 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
525 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:
19870
diff
changeset
|
526 |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
527 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:
19870
diff
changeset
|
528 { |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
529 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:
19870
diff
changeset
|
530 |
20594
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
531 if (figObj.valid_object () && |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
532 ! figObj.get ("windowbuttonmotionfcn").is_empty ()) |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
533 { |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
534 updateCurrentPoint (figObj, obj, event); |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
535 gh_manager::post_callback (figObj.get_handle (), |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
536 "windowbuttonmotionfcn"); |
46edfbd31ad7
Fix execution of "windowbuttonmotionfcn" with uipanels (bug #46151)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20531
diff
changeset
|
537 } |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
538 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
539 } |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
540 |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
541 // Update mouse coordinates in the figure window status bar |
20596
69270256b879
Qt Figure: allow displaying coordinates when hovered axes parent is a uipanel.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20594
diff
changeset
|
542 graphics_object obj = gh_manager::get_object (m_handle); |
69270256b879
Qt Figure: allow displaying coordinates when hovered axes parent is a uipanel.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20594
diff
changeset
|
543 graphics_object figObj = obj.get_ancestor ("figure"); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
544 |
20596
69270256b879
Qt Figure: allow displaying coordinates when hovered axes parent is a uipanel.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20594
diff
changeset
|
545 if (figObj.valid_object () && obj.valid_object ()) |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
546 { |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
547 graphics_object currentObj, axesObj; |
20596
69270256b879
Qt Figure: allow displaying coordinates when hovered axes parent is a uipanel.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20594
diff
changeset
|
548 select_object (obj, event, currentObj, axesObj, true); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
549 |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
550 if (axesObj.valid_object ()) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
551 { |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
552 // FIXME: should we use signal/slot mechanism instead of |
20516
79eb0746b21f
Fix segfault when hovering a Qt figure while it's being drawn (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20472
diff
changeset
|
553 // directly calling parent fig methods |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
554 Figure* fig = |
20516
79eb0746b21f
Fix segfault when hovering a Qt figure while it's being drawn (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20472
diff
changeset
|
555 dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
556 axes::properties& ap = Utils::properties<axes> (axesObj); |
20516
79eb0746b21f
Fix segfault when hovering a Qt figure while it's being drawn (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20472
diff
changeset
|
557 |
79eb0746b21f
Fix segfault when hovering a Qt figure while it's being drawn (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20472
diff
changeset
|
558 if (fig) |
79eb0746b21f
Fix segfault when hovering a Qt figure while it's being drawn (bug #45540)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20472
diff
changeset
|
559 fig->updateStatusBar (ap.pixel2coord (event->x (), event->y ())); |
19887
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
560 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
561 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
562 } |
966a1933f3fa
respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents:
19870
diff
changeset
|
563 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
564 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
565 Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
566 { |
20040
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20009
diff
changeset
|
567 // same processing as normal click, but event type is MouseButtonDblClick |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
568 canvasMousePressEvent (event); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
569 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
570 |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
571 static double |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
572 button_number (QMouseEvent *event) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
573 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
574 double retval = 0; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
575 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
576 switch (event->button ()) |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
577 { |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
578 case Qt::LeftButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
579 retval = 1; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
580 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
581 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
582 case Qt::MidButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
583 retval = 2; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
584 break; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
585 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
586 case Qt::RightButton: |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
587 retval = 3; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
588 break; |
19782
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19765
diff
changeset
|
589 |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19765
diff
changeset
|
590 default: |
98cc7c741c5a
avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents:
19765
diff
changeset
|
591 break; |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
592 } |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
593 |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
594 return retval; |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
595 } |
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
596 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
597 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
598 Canvas::canvasMousePressEvent (QMouseEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
603 bool isdblclick = (event->type () == QEvent::MouseButtonDblClick); |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
604 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 graphics_object currentObj, axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
610 select_object (obj, event, currentObj, axesObj); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
612 if (axesObj) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 { |
21643
9191c24fb329
Fix autoscale affecting legend axes objects (bug #47765).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20520
diff
changeset
|
614 if (axesObj.get_properties ().handlevisibility_is ("on") |
9191c24fb329
Fix autoscale affecting legend axes objects (bug #47765).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20520
diff
changeset
|
615 && axesObj.get_properties ().get_tag () != "legend" |
9191c24fb329
Fix autoscale affecting legend axes objects (bug #47765).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20520
diff
changeset
|
616 && axesObj.get_properties ().get_tag () != "colorbar") |
20270
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
617 Utils::properties<figure> (figObj) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
618 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
619 if (! currentObj) |
062422f2e399
Show axes coordinates in Qt figures (bug #44959)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
620 currentObj = axesObj; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 currentObj = obj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 if (currentObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 .set_currentobject (currentObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 else |
21723
bae585228161
use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents:
21721
diff
changeset
|
630 Utils::properties<figure> (figObj).set_currentobject (octave::numeric_limits<double>::NaN ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 MouseMode newMouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 if (fig) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
637 newMouseMode = fig->mouseMode (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 switch (newMouseMode) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
640 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
641 case NoMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
642 gh_manager::post_set (figObj.get_handle (), "selectiontype", |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
643 Utils::figureSelectionType (event, isdblclick), false); |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
644 |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
645 updateCurrentPoint (figObj, obj, event); |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
646 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
647 gh_manager::post_callback (figObj.get_handle (), |
19999
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
19967
diff
changeset
|
648 "windowbuttondownfcn", |
0376c1225660
Fix ginput to return button number with Qt toolkit (bug #44676).
Rik <rik@octave.org>
parents:
19967
diff
changeset
|
649 button_number (event)); |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
650 |
20520
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
651 if (currentObj.get ("buttondownfcn").is_empty ()) |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
652 { |
20531
dcfbf4c1c3c8
eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents:
20525
diff
changeset
|
653 graphics_object parentObj = |
20520
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
654 gh_manager::get_object (currentObj.get_parent ()); |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
655 |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
656 if (parentObj.valid_object () && parentObj.isa ("hggroup")) |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
657 gh_manager::post_callback (parentObj.get_handle (), |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
658 "buttondownfcn", |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
659 button_number (event)); |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
660 } |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
661 else |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
662 gh_manager::post_callback (currentObj.get_handle (), |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
663 "buttondownfcn", |
7d7c91ddc736
Handle hggroup objects "buttondownfcn" when children are clicked (bug #45621)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20245
diff
changeset
|
664 button_number (event)); |
19765
134e5bfff5c5
* Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents:
19762
diff
changeset
|
665 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
666 if (event->button () == Qt::RightButton) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
667 ContextMenu::executeAt (currentObj.get_properties (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
668 event->globalPos ()); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
669 break; |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
670 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
671 case TextMode: |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
672 { |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
673 if (event->modifiers () == Qt::NoModifier) |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
20090
diff
changeset
|
674 { |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
675 switch (event->buttons ()) |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
676 { |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
677 case Qt::LeftButton: |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
678 m_mouseAnchor = m_mouseCurrent = event->pos (); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
679 m_mouseMode = newMouseMode; |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
680 m_rectMode = true; |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
681 } |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
20090
diff
changeset
|
682 } |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
683 redraw (false); |
20080
908b68a98ba6
initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents:
20040
diff
changeset
|
684 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
685 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
686 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
687 case PanMode: |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
688 case RotateMode: |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
689 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
690 case ZoomOutMode: |
20106
8eb72c4ed457
Add uicontextmenu to annotation objects
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20095
diff
changeset
|
691 if (axesObj && axesObj.get_properties ().handlevisibility_is ("on")) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
692 { |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
693 bool redraw_figure = true; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
694 |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
695 if (isdblclick) |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
696 { |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
697 if (event->button () == Qt::LeftButton) |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
698 { |
20040
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20009
diff
changeset
|
699 axes::properties& ap = Utils::properties<axes> (axesObj); |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
700 |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
701 autoscale_axes (ap); |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
702 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
703 else |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
704 { |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
705 redraw_figure = false; |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
706 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
707 } |
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
708 else if (event->modifiers () == Qt::NoModifier) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
709 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
710 switch (event->buttons ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
711 { |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
712 case Qt::LeftButton: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
713 m_mouseAnchor = m_mouseCurrent = event->pos (); |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
714 m_mouseAxes = axesObj.get_handle (); |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
715 m_mouseMode = newMouseMode; |
20090
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
716 m_clickMode = newMouseMode == ZoomInMode; |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
717 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
718 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
719 case Qt::RightButton: |
20090
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
720 if (newMouseMode == ZoomInMode) |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
721 { |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
722 m_mouseAnchor = m_mouseCurrent = event->pos (); |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
723 m_mouseAxes = axesObj.get_handle (); |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
724 m_mouseMode = newMouseMode; |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
725 m_clickMode = false; |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
726 } |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
727 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
728 break; |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
729 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
730 case Qt::MidButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
731 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
732 axes::properties& ap = |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
733 Utils::properties<axes> (axesObj); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19867
diff
changeset
|
735 autoscale_axes (ap); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
736 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
737 break; |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
738 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
739 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
740 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
741 break; |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
742 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
743 } |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
744 else if (event->modifiers () == Qt::ShiftModifier) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
745 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
746 switch (event->buttons ()) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
747 { |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
748 case Qt::LeftButton: |
20090
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
749 if (newMouseMode == ZoomInMode) |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
750 { |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
751 m_mouseAnchor = m_mouseCurrent = event->pos (); |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
752 m_mouseAxes = axesObj.get_handle (); |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
753 m_mouseMode = newMouseMode; |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
754 m_clickMode = false; |
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
755 } |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
756 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
757 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
758 default: |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
759 redraw_figure = false; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
760 break; |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
761 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
762 } |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
763 |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
764 if (redraw_figure) |
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
765 redraw (false); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
766 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
767 break; |
19762
eebe8da58f8d
allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19759
diff
changeset
|
768 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
769 default: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
770 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
771 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
772 } |
20009
f2dea119369e
Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents:
20006
diff
changeset
|
773 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
775 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
776 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
777 Canvas::canvasMouseReleaseEvent (QMouseEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
778 { |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
779 if ((m_mouseMode == ZoomInMode || m_mouseMode == ZoomOutMode) |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
780 && m_mouseAxes.ok ()) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
781 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
782 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
784 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
785 if (ax.valid_object ()) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
786 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
787 axes::properties& ap = Utils::properties<axes> (ax); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
788 |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
789 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:
18692
diff
changeset
|
790 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
791 graphics_object figObj (obj.get_ancestor ("figure")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
792 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
793 std::string zm = zoom_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
794 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
795 if (m_mouseAnchor == event->pos ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
796 { |
20090
c6c5cb9c4743
Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents:
20080
diff
changeset
|
797 double factor = m_clickMode ? 2.0 : 0.5; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
798 |
19894
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19887
diff
changeset
|
799 ColumnVector p1 = ap.pixel2coord (event->x (), event->y ()); |
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19887
diff
changeset
|
800 |
ac18e88ea1bf
zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents:
19887
diff
changeset
|
801 ap.zoom_about_point (zm, p1(0), p1(1), factor); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
802 } |
20040
055ad6fbc910
Don't zoom in for 'Z-' setting and rectangle drag (bug #44437).
Rik <rik@octave.org>
parents:
20009
diff
changeset
|
803 else if (m_mouseMode == ZoomInMode) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
804 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
805 ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
806 m_mouseAnchor.y ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
807 ColumnVector p1 = ap.pixel2coord (event->x (), |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
808 event->y ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
809 |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
810 Matrix xl (1, 2, 0.0); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
811 Matrix yl (1, 2, 0.0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
812 |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
813 xl(0) = std::min (p0(0), p1(0)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
814 xl(1) = std::max (p0(0), p1(0)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
815 yl(0) = std::min (p0(1), p1(1)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
816 yl(1) = std::max (p0(1), p1(1)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
817 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
818 ap.zoom (zm, xl, yl); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
819 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
820 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
821 redraw (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
822 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 else if (m_mouseMode == NoMode) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
827 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
829 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
830 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
833 updateCurrentPoint (figObj, obj, event); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
834 gh_manager::post_callback (figObj.get_handle (), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
835 "windowbuttonupfcn"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 } |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
838 else if (m_mouseMode == TextMode) |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
839 { |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
840 gh_manager::auto_lock lock; |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20110
diff
changeset
|
841 |
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20110
diff
changeset
|
842 graphics_object figObj = |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
843 gh_manager::get_object (m_handle).get_ancestor ("figure"); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
844 if (figObj.valid_object ()) |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20110
diff
changeset
|
845 { |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
846 QWidget *w = qWidget (); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
847 if (w) |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
848 { |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
849 Matrix bb = figObj.get ("position").matrix_value (); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
850 bb(0) = m_mouseAnchor.x () / bb(2); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
851 bb(1) = 1.0 - (m_mouseAnchor.y () / bb(3)); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
852 bb(2) = (event->x () - m_mouseAnchor.x ()) / bb(2); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
853 bb(3) = (m_mouseAnchor.y () - event->y ()) / bb(3); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
854 |
20244
0bb456e9423b
Allow interactive annotations in other figures than the currentfigure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20216
diff
changeset
|
855 octave_value_list props = ovl ("textbox", bb); |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
856 |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
857 annotation_dialog anno_dlg (w, props); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20110
diff
changeset
|
858 |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
859 if (anno_dlg.exec () == QDialog::Accepted) |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
860 { |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
861 props = anno_dlg.get_properties (); |
20244
0bb456e9423b
Allow interactive annotations in other figures than the currentfigure.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20216
diff
changeset
|
862 props.prepend (figObj.get_handle ().as_octave_value ()); |
20107
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
863 |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
864 octave_link::post_event (this, &Canvas::annotation_callback, |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
865 props); |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
866 } |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
867 } |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
868 } |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
869 } |
f1f6d5eab46f
Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20106
diff
changeset
|
870 m_rectMode = false; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 m_mouseAxes = graphics_handle (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 m_mouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
873 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
874 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
875 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
876 Canvas::canvasWheelEvent (QWheelEvent* event) |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
877 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
878 gh_manager::auto_lock lock; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
879 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:
18692
diff
changeset
|
880 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
881 if (obj.valid_object ()) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
882 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
883 std::string mode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
884 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
885 graphics_object axesObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
886 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
887 Matrix children = obj.get_properties ().get_children (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
888 octave_idx_type num_children = children.numel (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
889 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
890 for (int i = 0; i < num_children; i++) |
19896
0e0a3bbe142f
Canvas.cc: Replace tabs with spaces.
Rik <rik@octave.org>
parents:
19894
diff
changeset
|
891 { |
0e0a3bbe142f
Canvas.cc: Replace tabs with spaces.
Rik <rik@octave.org>
parents:
19894
diff
changeset
|
892 graphics_object childObj (gh_manager::get_object (children(i))); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
893 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
894 if (childObj.isa ("axes")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
895 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
896 graphics_object go = selectFromAxes (childObj, event->pos ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
897 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
898 if (go) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
899 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
900 axesObj = childObj; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
901 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
902 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
903 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
904 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
905 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
906 if (axesObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
907 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
908 MouseMode newMouseMode = NoMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
909 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
910 graphics_object figObj (obj.get_ancestor ("figure")); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
911 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
912 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
913 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
914 if (fig) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
915 newMouseMode = fig->mouseMode (); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
916 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
917 if (axesObj.get_properties ().handlevisibility_is ("on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
918 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
919 Utils::properties<figure> (figObj) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
920 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
921 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
922 if (zoom_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
923 { |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
924 if (event->delta () > 0) |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
925 newMouseMode = ZoomInMode; |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
926 else |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
927 newMouseMode = ZoomOutMode; |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
928 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
929 mode = zoom_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
930 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
931 else if (pan_enabled (figObj)) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
932 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
933 newMouseMode = PanMode; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
934 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
935 mode = pan_mode (figObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
936 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
937 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
938 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
939 bool redrawFigure = true; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
940 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
941 switch (newMouseMode) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
942 { |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
943 case ZoomInMode: |
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
944 case ZoomOutMode: |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
945 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
946 axes::properties& ap = Utils::properties<axes> (axesObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
947 |
19759
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
948 // 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:
19681
diff
changeset
|
949 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:
19681
diff
changeset
|
950 |
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
951 // Determine if we're zooming in or out. |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
952 double factor = (newMouseMode == ZoomInMode |
19759
ed1bafbb87ee
allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents:
19681
diff
changeset
|
953 ? 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:
19681
diff
changeset
|
954 : 1.0 - wheel_zoom_speed); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
955 |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
956 // FIXME: should we zoom about point for 2D plots? |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
957 |
19867
6ba3d0f7c6e8
improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents:
19782
diff
changeset
|
958 ap.zoom (mode, factor); |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
959 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
960 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
961 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
962 case PanMode: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
963 { |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
964 axes::properties& ap = Utils::properties<axes> (axesObj); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
965 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
966 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:
18692
diff
changeset
|
967 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
968 ap.pan (mode, factor); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
969 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
970 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
971 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
972 default: |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
973 redrawFigure = false; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
974 break; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
975 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
976 |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
977 if (redrawFigure) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
978 redraw (false); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
979 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
980 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
981 } |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
18692
diff
changeset
|
982 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
983 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
984 Canvas::canvasKeyPressEvent (QKeyEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
986 if (m_eventMask & KeyPress) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 { |
20110
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
988 gh_manager::auto_lock lock; |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
989 graphics_object obj = gh_manager::get_object (m_handle); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
990 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
991 if (obj.valid_object ()) |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
992 { |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
993 graphics_object figObj (obj.get_ancestor ("figure")); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
994 |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
995 updateCurrentPoint (figObj, obj); |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
996 } |
248f2f2e7d48
Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents:
20107
diff
changeset
|
997 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 octave_scalar_map eventData = Utils::makeKeyEventStruct (event); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
999 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 gh_manager::post_set (m_handle, "currentcharacter", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1001 eventData.getfield ("Character"), false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 gh_manager::post_callback (m_handle, "keypressfcn", eventData); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1003 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1004 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1005 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1006 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1007 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1008 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1009 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
1010 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
1011 Canvas::canvasKeyReleaseEvent (QKeyEvent* event) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1013 if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1014 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1015 gh_manager::post_callback (m_handle, "keyreleasefcn", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1016 Utils::makeKeyEventStruct (event)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1017 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1019 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1020 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1021 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1022 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1023 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
1024 Canvas* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
1025 Canvas::create (const std::string& /* name */, QWidget* parent, |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19959
diff
changeset
|
1026 const graphics_handle& handle) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1027 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1028 // Only OpenGL |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1029 return new GLCanvas (parent, handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1030 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1031 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1032 }; // namespace QtHandles |