annotate libgui/graphics/Canvas.cc @ 19799:134e5bfff5c5

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