annotate libgui/graphics/Canvas.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 2011-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27901
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27901
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27901
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27901
diff changeset
7
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
9 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24523
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24523
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
14 (at your option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22413
diff changeset
19 GNU General Public License for more details.
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 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
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24523
diff changeset
23 <https://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21723
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
28 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <QApplication>
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
32 #include <QBitmap>
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
33 #include <QCursor>
20080
908b68a98ba6 initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20040
diff changeset
34 #include <QInputDialog>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QList>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include <QMouseEvent>
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
37 #include <QWheelEvent>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QRectF>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "Canvas.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "ContextMenu.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #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
43 #include "QtHandlesUtils.h"
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
44 #include "qt-graphics-toolkit.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents: 20090
diff changeset
46 #include "annotation-dialog.h"
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
47 #include "octave-qobject.h"
27417
f844b1f03dcc update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
48 #include "qt-interpreter-events.h"
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents: 20090
diff changeset
49
27417
f844b1f03dcc update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
50 #include "builtin-defun-decls.h"
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
51 #include "graphics.h"
27020
30e9204de313 move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
52 #include "interpreter.h"
21196
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 20596
diff changeset
53 #include "oct-opengl.h"
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
54
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
58 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
59 Canvas::redraw (bool sync)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
61 QWidget *w = qWidget ();
19953
ed51e17f6ccf avoid possibly dereferencing invalid pointer
John W. Eaton <jwe@octave.org>
parents: 19896
diff changeset
62
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 if (w)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 if (sync)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 w->repaint ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
67 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 w->update ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
69 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
70 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
71
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
72 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
73 Canvas::blockRedraw (bool block)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
74 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
75 m_redrawBlocked = block;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
76 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
77
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
78 QCursor
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
79 Canvas::make_cursor (const QString& name, int hot_x, int hot_y)
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
80 {
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
81 octave::resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
82
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
83 QIcon icon = rmgr.icon (name);
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
84
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
85 return QCursor (icon.pixmap (22, 22), hot_x, hot_y);
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
86 }
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
87
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
88 void
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
89 Canvas::setCursor (MouseMode mode, std::string fallback,
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
90 QImage cdata, Matrix hotspot)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
91 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 QWidget *w = qWidget ();
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
93 QCursor cursor = Qt::ArrowCursor;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
94 if (w)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
95 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
96 switch (mode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
97 {
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
98 case NoMode:
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
99 {
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
100 cursor = Qt::ArrowCursor;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
101
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
102 if (fallback == "arrow")
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
103 cursor = Qt::ArrowCursor;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
104 else if (fallback == "botl")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
105 cursor = make_cursor ("bottom_left_corner", 5, 16);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
106 else if (fallback == "botr")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
107 cursor = make_cursor ("bottom_right_corner", 16, 16);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
108 else if (fallback == "bottom")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
109 cursor = make_cursor ("bottom_side", 11, 16);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
110 else if (fallback == "circle")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
111 cursor = make_cursor ("circle", 10, 10);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
112 else if (fallback == "cross" || fallback == "crosshair")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
113 cursor = make_cursor ("cross", 10, 10);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
114 else if (fallback == "custom")
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
115 {
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
116 if (hotspot(0) > cdata.width () || hotspot(0) < 1.0
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
117 || hotspot(1) > cdata.height () || hotspot(1) < 1.0)
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
118 hotspot = Matrix (1, 2, 1);
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
119
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
120 cursor = QCursor (QPixmap::fromImage (cdata),
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
121 static_cast<int> (hotspot(1) - 1),
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
122 static_cast<int> (hotspot(0) - 1));
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
123 }
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
124 else if (fallback == "fleur")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
125 cursor = make_cursor ("fleur", 10, 4);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
126 else if (fallback == "hand")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
127 cursor = make_cursor ("hand2", 7, 3);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
128 else if (fallback == "ibeam")
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
129 cursor = Qt::IBeamCursor;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
130 else if (fallback == "left")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
131 cursor = make_cursor ("left_side", 4, 10);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
132 else if (fallback == "right")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
133 cursor = make_cursor ("right_side", 17, 10);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
134 else if (fallback == "top")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
135 cursor = make_cursor ("top_side", 11, 4);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
136 else if (fallback == "topl")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
137 cursor = make_cursor ("top_left_corner", 4, 4);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
138 else if (fallback == "topr")
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
139 cursor = make_cursor ("top_right_corner", 16, 4);
27099
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
140 else if (fallback == "watch")
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
141 cursor = Qt::BusyCursor;
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
142 }
2cd31365c84a Implement "pointer" and related figure properties for Qt toolkit (bug #56347)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27020
diff changeset
143 break;
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
144 case SelectMode:
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
145 cursor = Qt::ArrowCursor;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
146 break;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
147
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
148 case PanMode:
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
149 cursor = make_cursor ("figure-pan");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
150 break;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
151
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
152 case RotateMode:
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
153 cursor = make_cursor ("figure-rotate");
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
154 break;
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
155
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
156 case TextMode:
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
157 cursor = Qt::IBeamCursor;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
158 break;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
159
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
160 case ZoomInMode:
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
161 cursor = make_cursor ("figure-zoom-in", 9, 9);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
162 break;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
163
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
164 case ZoomOutMode:
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27417
diff changeset
165 cursor = make_cursor ("figure-zoom-out", 9, 9);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
166 break;
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19953
diff changeset
167
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
168 default:
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
169 cursor = Qt::ArrowCursor;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
171 }
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26861
diff changeset
172 w->setCursor (cursor);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
173 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
174 }
18612
9597e00ed2dd Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18505
diff changeset
175
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
176 /*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
177 Two updateCurrentPoint() routines are required:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
178 1) Used for QMouseEvents where cursor position data is in callback from Qt.
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
179 2) Used for QKeyEvents where cursor position must be determined.
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
180 */
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
181 void
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
182 Canvas::updateCurrentPoint (const graphics_object& fig,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
183 const graphics_object& obj, QMouseEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
184 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
185 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
186
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
187 octave::autolock guard (gh_mgr.graphics_lock ());
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
188
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
189 emit gh_set_event (fig.get_handle (), "currentpoint",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
190 Utils::figureCurrentPoint (fig, event), false);
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
191
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
192 Matrix children = obj.get_properties ().get_children ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
193 octave_idx_type num_children = children.numel ();
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
194
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
195 for (int i = 0; i < num_children; i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
196 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
197 graphics_object childObj (gh_mgr.get_object (children(i)));
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
198
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
199 if (childObj.isa ("axes"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
200 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
201 axes::properties& ap = Utils::properties<axes> (childObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
202 Matrix x_zlim = ap.get_transform_zlim ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
203 graphics_xform x_form = ap.get_transform ();
20080
908b68a98ba6 initial implementation of text annotations with Qt plotting
John W. Eaton <jwe@octave.org>
parents: 20040
diff changeset
204
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
205 ColumnVector p1 = x_form.untransform (event->x (), event->y (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
206 x_zlim(0));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
207 ColumnVector p2 = x_form.untransform (event->x (), event->y (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
208 x_zlim(1));
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20110
diff changeset
209
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
210 Matrix cp (2, 3, 0.0);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
211
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
212 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
213 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
214
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
215 emit gh_set_event (childObj.get_handle (), "currentpoint", cp,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
216 false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
217 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
218 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
219 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
220
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
221 void
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
222 Canvas::updateCurrentPoint (const graphics_object& fig,
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
223 const graphics_object& obj)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
224 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
225 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
226
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
227 octave::autolock guard (gh_mgr.graphics_lock ());
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
228
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
229 emit gh_set_event (fig.get_handle (), "currentpoint",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
230 Utils::figureCurrentPoint (fig), false);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
231
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
232 Matrix children = obj.get_properties ().get_children ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
233 octave_idx_type num_children = children.numel ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
234
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
235 for (int i = 0; i < num_children; i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
236 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
237 graphics_object childObj (gh_mgr.get_object (children(i)));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
238
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
239 if (childObj.isa ("axes"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
240 {
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
241 // FIXME: QCursor::pos() may give inaccurate results with
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
242 // asynchronous window systems like X11 over ssh.
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
243 QWidget *w = qWidget ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
244 QPoint p = w->mapFromGlobal (QCursor::pos ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
245 axes::properties& ap = Utils::properties<axes> (childObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
246 Matrix x_zlim = ap.get_transform_zlim ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
247 graphics_xform x_form = ap.get_transform ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
248
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
249 ColumnVector p1 = x_form.untransform (p.x (), p.y (), x_zlim(0));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
250 ColumnVector p2 = x_form.untransform (p.x (), p.y (), x_zlim(1));
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
251
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
252 Matrix cp (2, 3, 0.0);
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
253
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
254 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
255 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
256
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
257 emit gh_set_event (childObj.get_handle (), "currentpoint", cp,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
258 false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
259 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
260 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
261 }
19870
815db217f6f4 provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
262
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
263 static void
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
264 autoscale_axes (gh_manager& gh_mgr, axes::properties& ap)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
265 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
266 octave::autolock guard (gh_mgr.graphics_lock ());
26511
7bf8036ad3f6 Fix error when performing autoscale from Qt figures (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
267
7bf8036ad3f6 Fix error when performing autoscale from Qt figures (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
268 // Reset zoom stack
7bf8036ad3f6 Fix error when performing autoscale from Qt figures (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
269 ap.clear_zoom_stack (false);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
270
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
271 ap.set_xlimmode ("auto");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
272 ap.set_ylimmode ("auto");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
273 ap.set_zlimmode ("auto");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
274 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
275
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
276 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
277 Canvas::canvasPaintEvent (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
278 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
279 if (! m_redrawBlocked)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
280 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
281 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
282
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
283 octave::autolock guard (gh_mgr.graphics_lock ());
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
284
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
285 draw (m_handle);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
286
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
287 if ((m_mouseMode == ZoomInMode && m_mouseAxes.ok ()) || m_rectMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
288 drawZoomBox (m_mouseAnchor, m_mouseCurrent);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
289 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
290 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
291
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
292 static bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
293 pan_enabled (const graphics_object figObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
294 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
295 // Getting pan mode property:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
296 octave_value ov_pm
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
297 = Utils::properties<figure> (figObj).get___pan_mode__ ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
298
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
299 octave_scalar_map pm = ov_pm.scalar_map_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
300
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
301 return pm.contents ("Enable").string_value () == "on";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
302 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
303
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
304 static std::string
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
305 pan_mode (const graphics_object figObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
306 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
307 // Getting pan mode property:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
308 octave_value ov_pm
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
309 = Utils::properties<figure> (figObj).get___pan_mode__ ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
310
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
311 octave_scalar_map pm = ov_pm.scalar_map_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
312
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
313 return pm.contents ("Motion").string_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
314 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
315
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
316 static bool
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
317 zoom_enabled (const graphics_object figObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
318 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
319 // Getting zoom mode property:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
320 octave_value ov_zm
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
321 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
322
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
323 octave_scalar_map zm = ov_zm.scalar_map_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
324
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
325 return zm.contents ("Enable").string_value () == "on";
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
326 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
327
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
328 static std::string
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
329 zoom_mode (const graphics_object figObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
330 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
331 // Getting zoom mode property:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
332 octave_value ov_zm
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
333 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
334
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
335 octave_scalar_map zm = ov_zm.scalar_map_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
336
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
337 return zm.contents ("Motion").string_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
338 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
339
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
340 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
341 Canvas::select_object (graphics_object obj, QMouseEvent *event,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23364
diff changeset
342 graphics_object& currentObj, graphics_object& axesObj,
23185
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
343 bool axes_only, std::vector<std::string> omit)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
344 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
345 QList<graphics_object> axesList;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
346 Matrix children = obj.get_properties ().get_all_children ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
347 octave_idx_type num_children = children.numel ();
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
348
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
349 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
350
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
351 for (int i = 0; i < num_children; i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
352 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
353 graphics_object childObj (gh_mgr.get_object (children(i)));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
354
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
355 if (childObj.isa ("axes"))
23185
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
356 {
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
357 auto p = omit.begin ();
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
358 bool omitfound = false;
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
359 while (p != omit.end () && ! omitfound)
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
360 {
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
361 omitfound = (childObj.get ("tag").string_value () == *p);
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
362 p++;
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
363 }
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
364 if (! omitfound)
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
365 axesList.append (childObj);
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
366 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
367 else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel")
26112
36e0e5b428e7 Implement uitable (patch #9084)
Andrew Thornton <art27@cantab.net>
parents: 25951
diff changeset
368 || childObj.isa ("uibuttongroup") || childObj.isa ("uitable"))
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
369 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
370 Matrix bb = childObj.get_properties ().get_boundingbox (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
371 QRectF r (bb(0), bb(1), bb(2), bb(3));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
372
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
373 r.adjust (-5, -5, 5, 5);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
374
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
375 #if defined (HAVE_QMOUSEEVENT_LOCALPOS)
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
376 bool rect_contains_pos = r.contains (event->localPos ());
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
377 #else
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
378 bool rect_contains_pos = r.contains (event->posF ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
379 #endif
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
380 if (rect_contains_pos)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
381 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
382 currentObj = childObj;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
383 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
384 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
385 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
386 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
387
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
388 if (axes_only)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
389 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
390 QPoint pt = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
391
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
392 for (QList<graphics_object>::ConstIterator it = axesList.begin ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
393 it != axesList.end (); ++it)
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
394 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
395 const axes::properties& ap =
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
396 dynamic_cast<const axes::properties&> ((*it).get_properties ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
397
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
398 ColumnVector p0 = ap.pixel2coord (pt.x (), pt.y ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
399 Matrix xlim = ap.get_xlim ().matrix_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
400 Matrix ylim = ap.get_ylim ().matrix_value ();
20245
a5f9bf4df254 Avoid crash when trying to annotate an empty figure (bug #45241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20244
diff changeset
401
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
402 if (xlim(0) < p0(0) && xlim(1) > p0(0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
403 && ylim(0) < p0(1) && ylim(1) > p0(1))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
404 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
405 axesObj = *it;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
406 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
407 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
408 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
409 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
410 else if (! currentObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
411 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
412 for (QList<graphics_object>::ConstIterator it = axesList.begin ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
413 it != axesList.end (); ++it)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
414 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
415 graphics_object go = selectFromAxes (*it, event->pos ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
416
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
417 if (go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
418 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
419 currentObj = go;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
420 axesObj = *it;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
421 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
422 // FIXME: is this really necessary? the axes object should
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
423 // have been selected through selectFromAxes anyway
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
424 else if (it->get_properties ().is_hittest ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
425 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
426 Matrix bb = it->get_properties ().get_boundingbox (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
427 QRectF r (bb(0), bb(1), bb(2), bb(3));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
428
27901
33219a1a6133 Allow Qt selection rectangle to be slightly larger than axes for ease of use (patch #9763)
Rik <rik@octave.org>
parents: 27647
diff changeset
429 // Allow a rectangle (e.g., Zoom box) to be slightly outside
33219a1a6133 Allow Qt selection rectangle to be slightly larger than axes for ease of use (patch #9763)
Rik <rik@octave.org>
parents: 27647
diff changeset
430 // the axes and still select it.
33219a1a6133 Allow Qt selection rectangle to be slightly larger than axes for ease of use (patch #9763)
Rik <rik@octave.org>
parents: 27647
diff changeset
431 r.adjust (-20, -20, 20, 20);
33219a1a6133 Allow Qt selection rectangle to be slightly larger than axes for ease of use (patch #9763)
Rik <rik@octave.org>
parents: 27647
diff changeset
432
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
433 #if defined (HAVE_QMOUSEEVENT_LOCALPOS)
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
434 bool rect_contains_pos = r.contains (event->localPos ());
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24798
diff changeset
435 #else
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
436 bool rect_contains_pos = r.contains (event->posF ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
437 #endif
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
438 if (rect_contains_pos)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
439 axesObj = *it;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
440 }
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
441
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
442 if (axesObj && currentObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
443 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
444 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
445 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
446 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
447
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
448 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
449 Canvas::canvasMouseMoveEvent (QMouseEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
450 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
451 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
452
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
453 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
454
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
455 graphics_object ax = gh_mgr.get_object (m_mouseAxes);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
456
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
457 if (m_mouseMode != NoMode && (ax.valid_object () || m_mouseMode == TextMode))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
458 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
459 switch (m_mouseMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
460 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
461 case RotateMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
462 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
463 axes::properties& ap = Utils::properties<axes> (ax);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
464
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
465 ap.rotate3d (m_mouseCurrent.x (), event->x (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
466 m_mouseCurrent.y (), event->y ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
467
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
468 // Update current mouse position
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
469 m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
470
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
471 // Force immediate redraw
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
472 redraw (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
473 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
474 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
475 case TextMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
476 case ZoomInMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
477 case ZoomOutMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
478 m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
479 redraw (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
480 break;
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
481
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
482 case PanMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
483 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
484 axes::properties& ap = Utils::properties<axes> (ax);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
485
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
486 graphics_object figObj (ax.get_ancestor ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
487
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
488 std::string mode = pan_mode (figObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
489
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
490 ColumnVector p0 = ap.pixel2coord (m_mouseCurrent.x (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
491 m_mouseCurrent.y ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
492 ColumnVector p1 = ap.pixel2coord (event->x (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
493 event->y ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
494
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
495 ap.translate_view (mode, p0(0), p1(0), p0(1), p1(1));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
496
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
497 // Update current mouse position
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
498 m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
499
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
500 // Force immediate redraw
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
501 redraw (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
502 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
503
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
504 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
505 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
506 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
507 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
508 else if (m_mouseMode == NoMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
509 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
510 graphics_object obj = gh_mgr.get_object (m_handle);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
511
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
512 if (obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
513 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
514 graphics_object figObj (obj.get_ancestor ("figure"));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
515
25951
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
516 if (figObj.valid_object ()
7a507e71d922 style fixes
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
517 && ! figObj.get ("windowbuttonmotionfcn").isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
518 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
519 updateCurrentPoint (figObj, obj, event);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
520 emit gh_callback_event (figObj.get_handle (),
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
521 "windowbuttonmotionfcn");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
522 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
523 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
524 }
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
525
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
526 // Update mouse coordinates in the figure window status bar
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
527 graphics_object obj = gh_mgr.get_object (m_handle);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
528 graphics_object figObj = obj.get_ancestor ("figure");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
529
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
530 if (figObj.valid_object () && obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
531 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
532 graphics_object currentObj, axesObj;
23185
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
533 std::vector<std::string> omit = {"legend", "colorbar", "scribeoverlay"};
0032c2f7ee4e Don't display legend, colorbar, and annotation axes coordinates (bug #50272).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23083
diff changeset
534 select_object (obj, event, currentObj, axesObj, true, omit);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
535
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
536 if (axesObj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
537 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
538 // FIXME: should we use signal/slot mechanism instead of
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
539 // directly calling parent fig methods
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
540 Figure *fig =
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
541 dynamic_cast<Figure *> (qt_graphics_toolkit::toolkitObject (figObj));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
542 axes::properties& ap = Utils::properties<axes> (axesObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
543
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
544 if (fig)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
545 fig->updateStatusBar (ap.pixel2coord (event->x (), event->y ()));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
546 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
547 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
548 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
549
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
550 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
551 Canvas::canvasMouseDoubleClickEvent (QMouseEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
552 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
553 // same processing as normal click, but event type is MouseButtonDblClick
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
554 canvasMousePressEvent (event);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
555 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
556
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
557 static double
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
558 button_number (QMouseEvent *event)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
559 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
560 double retval = 0;
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
561
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
562 switch (event->button ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
563 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
564 case Qt::LeftButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
565 retval = 1;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
566 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
567
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
568 case Qt::MidButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
569 retval = 2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
570 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
571
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
572 case Qt::RightButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
573 retval = 3;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
574 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
575
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
576 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
577 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
578 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
579
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
580 return retval;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
581 }
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
582
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
583 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
584 Canvas::canvasMousePressEvent (QMouseEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
585 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
586 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
587
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
588 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
589
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
590 graphics_object obj = gh_mgr.get_object (m_handle);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
591
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
592 bool isdblclick = (event->type () == QEvent::MouseButtonDblClick);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
593
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
594 if (obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
595 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
596 graphics_object figObj (obj.get_ancestor ("figure"));
23360
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
597
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
598 // Any click in a figure canvas makes it current
23360
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
599 if (figObj)
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
600 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
601 graphics_object root = gh_mgr.get_object (0);
23360
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
602 Utils::properties<root_figure> (root)
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
603 .set_currentfigure (figObj.get_handle ().as_octave_value ());
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
604 }
43f549ac6dac Let mouse selection of Qt figures update "currentfigure" (bug #50666)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23219
diff changeset
605
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
606 graphics_object currentObj, axesObj;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
607
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
608 // Retrieve selected object.
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
609 select_object (obj, event, currentObj, axesObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
610
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
611 // currentObj may be invalid if, e.g., all objects under the mouse
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
612 // click had "hittest" -> "off" or "pickableparts" -> "none". In that
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
613 // case, replace with underlying figObj which always accepts mouse
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
614 // clicks.
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
615 if (! currentObj.valid_object ())
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
616 currentObj = figObj;
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
617 else if (! currentObj.get_properties ().is_hittest ())
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
618 {
24672
13c207835e79 Rethrow gl2ps_print exceptions from GUI to interpreter thread (bug #50198)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24636
diff changeset
619 // Objects with "hittest"->"off" pass the mouse event to their
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
620 // parent and so on.
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
621 graphics_object tmpgo;
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
622 tmpgo = gh_mgr.get_object (currentObj.get_parent ());
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
623 while (tmpgo && ! tmpgo.get_properties ().is_hittest ())
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
624 tmpgo = gh_mgr.get_object (tmpgo.get_parent ());
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
625
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
626 if (tmpgo && tmpgo.get_handle () != 0.0)
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
627 currentObj = tmpgo;
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
628 else
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
629 currentObj = graphics_object ();
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
630 }
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
631
26861
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
632 // Make selected axes current
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
633 bool valid_axes = axesObj.valid_object ()
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
634 && axesObj.get_properties ().handlevisibility_is ("on")
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
635 && axesObj.get_properties ().get_tag () != "legend"
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
636 && axesObj.get_properties ().get_tag () != "colorbar";
26995
ab5bfee22d18 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 26869
diff changeset
637
26861
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
638 if (valid_axes)
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
639 Utils::properties<figure> (figObj)
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
640 .set_currentaxes (axesObj.get_handle ().as_octave_value ());
19887
966a1933f3fa respect x- or y-only pan mode when clicking and dragging (bug #44408)
John W. Eaton <jwe@octave.org>
parents: 19870
diff changeset
641
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
642 Figure *fig = dynamic_cast<Figure *> (qt_graphics_toolkit::toolkitObject (figObj));
19765
134e5bfff5c5 * Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents: 19762
diff changeset
643
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
644 MouseMode newMouseMode = NoMode;
19782
98cc7c741c5a avoid GCC warning about enumeration values not handled in switch statement
John W. Eaton <jwe@octave.org>
parents: 19765
diff changeset
645
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
646 if (fig)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
647 newMouseMode = fig->mouseMode ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
649 switch (newMouseMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
650 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
651 case NoMode:
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
652 {
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
653 // Update the figure "currentobject"
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
654 auto& fprop = Utils::properties<figure> (figObj);
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
655
24672
13c207835e79 Rethrow gl2ps_print exceptions from GUI to interpreter thread (bug #50198)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24636
diff changeset
656 if (currentObj
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
657 && currentObj.get_properties ().handlevisibility_is ("on"))
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
658 fprop.set_currentobject (currentObj.get_handle ()
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
659 .as_octave_value ());
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
660 else
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
661 fprop.set_currentobject (Matrix ());
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
662
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
663 // Update figure "selectiontype" and "currentpoint"
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
664 emit gh_set_event (figObj.get_handle (), "selectiontype",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
665 Utils::figureSelectionType (event, isdblclick),
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
666 false);
19765
134e5bfff5c5 * Canvas.cc (button_number): New static function.
John W. Eaton <jwe@octave.org>
parents: 19762
diff changeset
667
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
668 updateCurrentPoint (figObj, obj, event);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
669
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
670 emit gh_callback_event (figObj.get_handle (),
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
671 "windowbuttondownfcn",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
672 button_number (event));
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
673
24743
f7e333b12687 Ignore figure "hittest" for executing "buttondownfcn" (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24672
diff changeset
674 // Execute the "buttondownfcn" of the selected object. If the
f7e333b12687 Ignore figure "hittest" for executing "buttondownfcn" (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24672
diff changeset
675 // latter is empty then execute the figure "buttondownfcn"
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
676 if (currentObj && ! currentObj.get ("buttondownfcn").isempty ())
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
677 emit gh_callback_event (currentObj.get_handle (),
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
678 "buttondownfcn", button_number (event));
24743
f7e333b12687 Ignore figure "hittest" for executing "buttondownfcn" (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24672
diff changeset
679 else if (figObj && ! figObj.get ("buttondownfcn").isempty ())
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
680 emit gh_callback_event (figObj.get_handle (),
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
681 "buttondownfcn", button_number (event));
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
682
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
683 // Show context menu of the selected object
24636
9d01ce02d5cb Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24634
diff changeset
684 if (currentObj && event->button () == Qt::RightButton)
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
685 ContextMenu::executeAt (m_interpreter,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
686 currentObj.get_properties (),
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
687 event->globalPos ());
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24373
diff changeset
688 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
689 break;
20009
f2dea119369e Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents: 20006
diff changeset
690
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
691 case TextMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
692 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
693 if (event->modifiers () == Qt::NoModifier)
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
694 {
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
695 switch (event->buttons ())
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
696 {
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
697 case Qt::LeftButton:
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
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: 19759
diff changeset
699 m_mouseMode = newMouseMode;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
700 m_rectMode = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
701 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
702 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
703 redraw (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
704 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
705 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
706
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
707 case PanMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
708 case RotateMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
709 case ZoomInMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
710 case ZoomOutMode:
26861
6236c790bd1b Disalow zoom/pan/rotate on legend and colorbar axes (bug #55848)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26511
diff changeset
711 if (valid_axes)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
712 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
713 bool redraw_figure = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
714
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
715 if (isdblclick)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
716 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
717 if (event->button () == Qt::LeftButton)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
718 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
719 axes::properties& ap = Utils::properties<axes> (axesObj);
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
720
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
721 autoscale_axes (gh_mgr, ap);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
722 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
723 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
724 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
725 redraw_figure = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
726 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
727 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
728 else if (event->modifiers () == Qt::NoModifier)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
729 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
730 switch (event->buttons ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
731 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
732 case Qt::LeftButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
733 m_mouseAnchor = m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
734 m_mouseAxes = axesObj.get_handle ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
735 m_mouseMode = newMouseMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
736 m_clickMode = newMouseMode == ZoomInMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
737 break;
20090
c6c5cb9c4743 Right-click should zoom out by 2 for Qt toolkit (bug #44304).
Rik <rik@octave.org>
parents: 20080
diff changeset
738
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
739 case Qt::RightButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
740 if (newMouseMode == ZoomInMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
741 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
742 m_mouseAnchor = m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
743 m_mouseAxes = axesObj.get_handle ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
744 m_mouseMode = newMouseMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
745 m_clickMode = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
746 }
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
747
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
748 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
749
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
750 case Qt::MidButton:
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
751 {
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
752 axes::properties& ap =
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
753 Utils::properties<axes> (axesObj);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
754
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
755 autoscale_axes (gh_mgr, ap);
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18612
diff changeset
756 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
757 break;
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
758
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
759 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
760 redraw_figure = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
761 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
762 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
763 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
764 else if (event->modifiers () == Qt::ShiftModifier)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
765 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
766 switch (event->buttons ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
767 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
768 case Qt::LeftButton:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
769 if (newMouseMode == ZoomInMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
770 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
771 m_mouseAnchor = m_mouseCurrent = event->pos ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
772 m_mouseAxes = axesObj.get_handle ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
773 m_mouseMode = newMouseMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
774 m_clickMode = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
775 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
776 break;
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
777
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
778 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
779 redraw_figure = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
780 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
781 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
782 }
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
783
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
784 if (redraw_figure)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
785 redraw (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
786 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
787 break;
19762
eebe8da58f8d allow shift + left button to zoom out (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19759
diff changeset
788
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
789 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
790 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
791 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
792 }
20009
f2dea119369e Qt Canvas: set selection type to 'open' on double click (Bug #44669)
John Donoghue
parents: 20006
diff changeset
793
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
794 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
795
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
796 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
797 Canvas::canvasMouseReleaseEvent (QMouseEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
798 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
799 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
800
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
801 if ((m_mouseMode == ZoomInMode || m_mouseMode == ZoomOutMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
802 && m_mouseAxes.ok ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
803 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
804 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
805
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
806 graphics_object ax = gh_mgr.get_object (m_mouseAxes);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
807
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
808 if (ax.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
809 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
810 axes::properties& ap = Utils::properties<axes> (ax);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
811
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
812 graphics_object obj = gh_mgr.get_object (m_handle);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
813
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
814 graphics_object figObj (obj.get_ancestor ("figure"));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
815
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
816 std::string zm = zoom_mode (figObj);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
817
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
818 if (m_mouseAnchor == event->pos ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
819 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
820 double factor = (m_clickMode ? 2.0 : 0.5);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
821
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
822 ColumnVector p1 = ap.pixel2coord (event->x (), event->y ());
19894
ac18e88ea1bf zoom about point for single clicks
John W. Eaton <jwe@octave.org>
parents: 19887
diff changeset
823
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
824 ap.zoom_about_point (zm, p1(0), p1(1), factor);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
825 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
826 else if (m_mouseMode == ZoomInMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
827 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
828 ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
829 m_mouseAnchor.y ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
830 ColumnVector p1 = ap.pixel2coord (event->x (),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
831 event->y ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
832
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
833 Matrix xl (1, 2, 0.0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
834 Matrix yl (1, 2, 0.0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
835
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
836 xl(0) = std::min (p0(0), p1(0));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
837 xl(1) = std::max (p0(0), p1(0));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
838 yl(0) = std::min (p0(1), p1(1));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
839 yl(1) = std::max (p0(1), p1(1));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
840
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
841 ap.zoom (zm, xl, yl);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
842 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
843
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
844 redraw (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
845 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
846 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
847 else if (m_mouseMode == NoMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
848 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
849 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
850
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
851 graphics_object obj = gh_mgr.get_object (m_handle);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
852
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
853 if (obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
854 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
855 graphics_object figObj (obj.get_ancestor ("figure"));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
856
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
857 updateCurrentPoint (figObj, obj, event);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
858 emit gh_callback_event (figObj.get_handle (), "windowbuttonupfcn");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
859 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
860 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
861 else if (m_mouseMode == TextMode)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
862 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
863 octave::autolock guard (gh_mgr.graphics_lock ());
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20110
diff changeset
864
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
865 graphics_object figObj
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
866 = gh_mgr.get_object (m_handle).get_ancestor ("figure");
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
867
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
868 if (figObj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
869 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
870 QWidget *w = qWidget ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
871 if (w)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
872 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
873 Matrix bb = figObj.get ("position").matrix_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
874 bb(0) = m_mouseAnchor.x () / bb(2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
875 bb(1) = 1.0 - (m_mouseAnchor.y () / bb(3));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
876 bb(2) = (event->x () - m_mouseAnchor.x ()) / bb(2);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
877 bb(3) = (m_mouseAnchor.y () - event->y ()) / bb(3);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
878
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
879 octave_value_list props = ovl ("textbox", bb);
20107
f1f6d5eab46f Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20106
diff changeset
880
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
881 annotation_dialog anno_dlg (m_octave_qobj, w, props);
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20110
diff changeset
882
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
883 if (anno_dlg.exec () == QDialog::Accepted)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
884 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
885 props = anno_dlg.get_properties ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
886 props.prepend (figObj.get_handle ().as_octave_value ());
20107
f1f6d5eab46f Draw a zoom-like box when creating an annotation interactively
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20106
diff changeset
887
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
888 emit interpreter_event
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
889 ([this, props] (octave::interpreter& interp)
27247
9e5a825bb966 replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
890 {
27393
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
891 // INTERPRETER THREAD
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27376
diff changeset
892
27247
9e5a825bb966 replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
893 interp.feval ("annotation", props);
9e5a825bb966 replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
894
9e5a825bb966 replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
895 redraw ();
9e5a825bb966 replace more explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27224
diff changeset
896 });
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
897 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
898 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
899 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
900 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
901 m_rectMode = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
902 m_mouseAxes = graphics_handle ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
903 m_mouseMode = NoMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
904 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
906 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
907 Canvas::canvasWheelEvent (QWheelEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
908 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
909 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
910
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
911 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
912
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
913 graphics_object obj = gh_mgr.get_object (m_handle);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
914
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
915 if (obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
916 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
917 std::string mode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
918
27125
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
919 graphics_object figObj (obj.get_ancestor ("figure"));
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
920
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
921 graphics_object axesObj;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
922
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
923 Matrix children = obj.get_properties ().get_children ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
924 octave_idx_type num_children = children.numel ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
925
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
926 for (int i = 0; i < num_children; i++)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
927 {
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
928 graphics_object childObj (gh_mgr.get_object (children(i)));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
929
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
930 if (childObj.isa ("axes"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
931 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
932 graphics_object go = selectFromAxes (childObj, event->pos ());
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
933
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
934 if (go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
935 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
936 axesObj = childObj;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
937 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
938 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
939 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
940 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
941
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
942 if (axesObj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
943 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
944 MouseMode newMouseMode = NoMode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
945
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
946 Figure *fig = dynamic_cast<Figure *> (qt_graphics_toolkit::toolkitObject (figObj));
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
947
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
948 if (fig)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
949 newMouseMode = fig->mouseMode ();
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
950
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
951 if (axesObj.get_properties ().handlevisibility_is ("on"))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
952 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
953 Utils::properties<figure> (figObj)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
954 .set_currentaxes (axesObj.get_handle ().as_octave_value ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
955
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
956 if (zoom_enabled (figObj))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
957 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
958 if (event->delta () > 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
959 newMouseMode = ZoomInMode;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
960 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
961 newMouseMode = ZoomOutMode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
962
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
963 mode = zoom_mode (figObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
964 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
965 else if (pan_enabled (figObj))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
966 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
967 newMouseMode = PanMode;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
968
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
969 mode = pan_mode (figObj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
970 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
971 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
972
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
973 bool redrawFigure = true;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
974
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
975 switch (newMouseMode)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
976 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
977 case ZoomInMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
978 case ZoomOutMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
979 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
980 axes::properties& ap = Utils::properties<axes> (axesObj);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
981
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
982 // Control how fast to zoom when using scroll wheel.
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
983 double wheel_zoom_speed = ap.get_mousewheelzoom ();
19759
ed1bafbb87ee allow mouse wheel zoom amount to be configurable for qt graphics (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19681
diff changeset
984
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
985 // Determine if we're zooming in or out.
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
986 double factor = (newMouseMode == ZoomInMode
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
987 ? 1 / (1.0 - wheel_zoom_speed)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
988 : 1.0 - wheel_zoom_speed);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
989
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
990 // FIXME: should we zoom about point for 2D plots?
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
991
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
992 ap.zoom (mode, factor);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
993 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
994 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
995
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
996 case PanMode:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
997 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
998 axes::properties& ap = Utils::properties<axes> (axesObj);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
999
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
1000 double factor = (event->delta () > 0 ? 0.1 : -0.1);
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
1001
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1002 if (event->modifiers () == Qt::NoModifier
24372
708b98b4cdd1 Make wheel scroll behave more consistently in pan mode (bug #52588).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23360
diff changeset
1003 && mode != "horizontal")
708b98b4cdd1 Make wheel scroll behave more consistently in pan mode (bug #52588).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23360
diff changeset
1004 ap.pan ("vertical", factor);
24634
ab2321d4ba03 maint: strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1005 else if (event->modifiers () == Qt::ShiftModifier
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1006 && mode != "vertical")
24372
708b98b4cdd1 Make wheel scroll behave more consistently in pan mode (bug #52588).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23360
diff changeset
1007 ap.pan ("horizontal", factor);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1008 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1009 break;
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
1010
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1011 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1012 redrawFigure = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1013 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1014 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
1015
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1016 if (redrawFigure)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1017 redraw (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1018 }
27376
1952e110d346 Allow Qt graphics callbacks to work again (bug #56857)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27335
diff changeset
1019
27125
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
1020 if (! figObj.get ("windowscrollwheelfcn").isempty ())
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
1021 {
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
1022 octave_scalar_map eventData = Utils::makeScrollEventStruct (event);
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1023 emit gh_callback_event (m_handle, "windowscrollwheelfcn",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1024 eventData);
27125
d2d2f66e1cdc Implement figure "windowscrollwheelfcn" property for Qt toolkit (bug #56028).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27099
diff changeset
1025 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1026 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1027 }
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
1028
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1029 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
1030 Canvas::canvasKeyPressEvent (QKeyEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1031 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1032 if (m_eventMask & KeyPress)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1033 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
1034 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1035
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1036 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1037
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1038 graphics_object obj = gh_mgr.get_object (m_handle);
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
1039
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1040 if (obj.valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1041 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1042 graphics_object figObj (obj.get_ancestor ("figure"));
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
1043
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1044 updateCurrentPoint (figObj, obj);
20110
248f2f2e7d48 Return correct x,y coordinates for keystroke with ginput in Qt (bug #44834).
Rik <rik@octave.org>
parents: 20107
diff changeset
1045
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1046 octave_scalar_map eventData = Utils::makeKeyEventStruct (event);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1047
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1048 emit gh_set_event (figObj.get_handle (), "currentcharacter",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1049 eventData.getfield ("Character"), false);
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1050 emit gh_callback_event (figObj.get_handle (), "keypressfcn",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1051 eventData);
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1052 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1053
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1054 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1055 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1056
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1057 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1058 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1059
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1060 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
1061 Canvas::canvasKeyReleaseEvent (QKeyEvent *event)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1062 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1063 if (! event->isAutoRepeat () && (m_eventMask & KeyRelease))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1064 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
1065 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1066
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1067 octave::autolock guard (gh_mgr.graphics_lock ());
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1068
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
1069 graphics_object obj = gh_mgr.get_object (m_handle);
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1070
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1071 if (obj.valid_object ())
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1072 {
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1073 graphics_object figObj (obj.get_ancestor ("figure"));
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1074 emit gh_callback_event (figObj.get_handle (), "keyreleasefcn",
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
1075 Utils::makeKeyEventStruct (event));
27224
9b8903d3e626 Allow figure "keypressfcn" to work with uipanel on the way (bug #56598)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27125
diff changeset
1076 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1077
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1078 return true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1079 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1080
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1081 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1082 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1083
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
1084 Canvas *
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
1085 Canvas::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
1086 const graphics_handle& handle, QWidget *parent,
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
1087 const std::string& /* name */)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1088 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1089 // Only OpenGL
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
1090 return new GLCanvas (oct_qobj, interp, handle, parent);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1091 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
1093 }