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