Mercurial > octave
annotate libgui/graphics/Canvas.cc @ 18692:fe0e34be5576
maint: untabify recently added code files.
* Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, Canvas.h,
CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc,
Figure.h, GLCanvas.h, ListBoxControl.cc, Menu.cc, MouseModeActionGroup.cc,
Object.cc, Object.h, ObjectFactory.cc, ObjectProxy.cc, Panel.cc,
PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc,
QtHandlesUtils.h, RadioButtonControl.cc, SliderControl.cc, TextControl.cc,
ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc,
__init_qt__.cc, pt-jit.cc, ov-classdef.cc, ov-classdef.h: Untabify code.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 27 Apr 2014 18:02:47 -0700 |
parents | 9597e00ed2dd |
children | dfea01b3425f |
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> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include <QList> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <QMouseEvent> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <QRectF> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include "Backend.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "Canvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "ContextMenu.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #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
|
36 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 void Canvas::redraw (bool sync) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 if (sync) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 qWidget ()->repaint (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 qWidget ()->update (); |
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 void Canvas::blockRedraw (bool block) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 m_redrawBlocked = block; |
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 |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
54 void Canvas::updateCurrentPoint(const graphics_object& fig, |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
55 const graphics_object& obj, QMouseEvent* event) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
56 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
57 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
|
58 Utils::figureCurrentPoint (fig, event), false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
59 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
60 Matrix children = obj.get_properties ().get_children (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
61 octave_idx_type num_children = children.numel (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
62 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
63 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
|
64 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
65 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
|
66 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
67 if (childObj.isa ("axes")) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
68 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
69 axes::properties& ap = Utils::properties<axes> (childObj); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
70 Matrix x_zlim = ap.get_transform_zlim (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
71 graphics_xform x_form = ap.get_transform (); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
72 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
73 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
|
74 x_zlim(0)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
75 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
|
76 x_zlim(1)); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
77 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
78 Matrix cp (2, 3, 0.0); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
79 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
80 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
|
81 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
|
82 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
83 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
|
84 false); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
85 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
86 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
87 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
88 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 void Canvas::canvasPaintEvent (void) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 if (! m_redrawBlocked) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 draw (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 if (m_mouseMode == ZoomMode && m_mouseAxes.ok ()) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
98 drawZoomBox (m_mouseAnchor, m_mouseCurrent); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 void Canvas::canvasMouseMoveEvent (QMouseEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 if (m_mouseMode != NoMode && ax.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 axes::properties& ap = Utils::properties<axes> (ax); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 switch (m_mouseMode) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
112 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
113 case RotateMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
114 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
115 Matrix bb = ap.get_boundingbox (true); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
116 Matrix view = ap.get_view ().matrix_value (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
118 // Compute new view angles |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
119 view(0) += ((m_mouseCurrent.x () - event->x ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
120 * (180.0 / bb(2))); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
121 view(1) += ((event->y () - m_mouseCurrent.y ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
122 * (180.0 / bb(3))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
124 // Clipping |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
125 view(1) = std::min (view(1), 90.0); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
126 view(1) = std::max (view(1), -90.0); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
127 if (view(0) > 180.0) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
128 view(0) -= 360.0; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
129 else if (view(0) < -180.0) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
130 view(0) += 360.0; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
132 // Snapping |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
133 double snapMargin = 1.0; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
134 for (int a = -90; a <= 90; a += 90) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
135 if ((a - snapMargin) < view(1) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
136 && view(1) < (a + snapMargin)) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
137 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
138 view(1) = a; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
139 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
140 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
141 for (int a = -180; a <= 180; a += 180) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
142 if ((a - snapMargin) < view(0) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
143 && view(0) < (a + snapMargin)) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
144 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
145 if (a == 180) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
146 view(0) = -180; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
147 else |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
148 view(0) = a; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
149 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
150 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
152 // Update axes properties |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
153 ap.set_view (view); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
155 // Update current mouse position |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
156 m_mouseCurrent = event->pos (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
158 // Force immediate redraw |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
159 redraw (true); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
160 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
161 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
162 case ZoomMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
163 m_mouseCurrent = event->pos(); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
164 redraw (true); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
165 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
166 case PanMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
167 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
168 default: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
169 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
170 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 } |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
172 else if (m_mouseMode == NoMode) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
173 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
174 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
|
175 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
176 if (obj.valid_object ()) |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
177 { |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
178 graphics_object figObj (obj.get_ancestor ("figure")); |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
179 |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
180 updateCurrentPoint (figObj, obj, event); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
181 gh_manager::post_callback (figObj.get_handle (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
182 "windowbuttonmotionfcn"); |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
183 } |
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
184 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 void Canvas::canvasMousePressEvent (QMouseEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 graphics_object currentObj, axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 QList<graphics_object> axesList; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 Matrix children = obj.get_properties ().get_children (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 octave_idx_type num_children = children.numel (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 for (int i = 0; i < num_children; i++) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
202 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
203 graphics_object childObj (gh_manager::get_object (children(i))); |
18498
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 if (childObj.isa ("axes")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 axesList.append (childObj); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
207 else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel")) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
208 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
209 Matrix bb = childObj.get_properties ().get_boundingbox (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
210 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
|
211 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
212 r.adjust (-5, -5, 5, 5); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
213 if (r.contains (event->posF ())) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
214 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
215 currentObj = childObj; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
216 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
217 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
218 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
219 } |
18498
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 if (! currentObj) |
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 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 it != axesList.end (); ++it) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 graphics_object go = selectFromAxes (*it, event->pos ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 if (go) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 currentObj = go; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 // FIXME: is this really necessary? the axes object should |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 // have been selected through selectFromAxes anyway |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 else if (it->get_properties ().is_hittest ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 Matrix bb = it->get_properties ().get_boundingbox (true); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 QRectF r (bb(0), bb(1), bb(2), bb(3)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 if (r.contains (event->posF ())) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 axesObj = *it; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 if (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 if (axesObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 if (axesObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 .set_currentaxes (axesObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 currentObj = axesObj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 if (! currentObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 currentObj = obj; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 if (currentObj.get_properties ().handlevisibility_is ("on")) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 Utils::properties<figure> (figObj) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 .set_currentobject (currentObj.get_handle ().as_octave_value ()); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 Utils::properties<figure> (figObj).set_currentobject (octave_NaN); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 MouseMode newMouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 if (fig) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
272 newMouseMode = fig->mouseMode (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 switch (newMouseMode) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
275 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
276 case NoMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
277 gh_manager::post_set (figObj.get_handle (), "selectiontype", |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
278 Utils::figureSelectionType (event), false); |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
279 updateCurrentPoint (figObj, obj, event); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
280 gh_manager::post_callback (figObj.get_handle (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
281 "windowbuttondownfcn"); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 gh_manager::post_callback (currentObj.get_handle (), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 "buttondownfcn"); |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
284 if (event->button () == Qt::RightButton) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
285 ContextMenu::executeAt (currentObj.get_properties (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
286 event->globalPos ()); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
287 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
288 case RotateMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
289 case ZoomMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
290 case PanMode: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
291 if (axesObj) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
292 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
293 if (event->buttons () == Qt::LeftButton |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
294 && event->modifiers () == Qt::NoModifier) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
295 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
296 m_mouseAnchor = m_mouseCurrent = event->pos (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
297 m_mouseAxes = axesObj.get_handle (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
298 m_mouseMode = newMouseMode; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
299 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
300 else if (newMouseMode == ZoomMode |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
301 && event->modifiers () == Qt::NoModifier) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
302 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
303 switch (event->buttons ()) |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
304 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
305 case Qt::RightButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
306 Utils::properties<axes> (axesObj).unzoom (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
307 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
308 case Qt::MidButton: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
309 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
310 axes::properties& ap = |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
311 Utils::properties<axes> (axesObj); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
313 ap.clear_zoom_stack (); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
314 ap.set_xlimmode ("auto"); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
315 ap.set_ylimmode ("auto"); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
316 ap.set_zlimmode ("auto"); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
317 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
318 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
319 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
320 redraw (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
321 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
322 } |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
323 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
324 default: |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
325 break; |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
326 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 void Canvas::canvasMouseReleaseEvent (QMouseEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 if (m_mouseMode == ZoomMode |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 && m_mouseAxes.ok () |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 && m_mouseAnchor != event->pos ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 graphics_object ax = gh_manager::get_object (m_mouseAxes); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 if (ax.valid_object ()) |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
340 { |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
341 axes::properties& ap = Utils::properties<axes> (ax); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
343 ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
344 m_mouseAnchor.y ()); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
345 ColumnVector p1 = ap.pixel2coord (event->x (), |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
346 event->y ()); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
348 Matrix xl (1, 2, 0.0); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
349 Matrix yl (1, 2, 0.0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
351 xl(0) = std::min (p0(0), p1(0)); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
352 xl(1) = std::max (p0(0), p1(0)); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
353 yl(0) = std::min (p0(1), p1(1)); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
354 yl(1) = std::max (p0(1), p1(1)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
356 ap.zoom (xl, yl); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
358 redraw (false); |
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
359 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 else if (m_mouseMode == NoMode) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 gh_manager::auto_lock lock; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 graphics_object obj = gh_manager::get_object (m_handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 if (obj.valid_object ()) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 graphics_object figObj (obj.get_ancestor ("figure")); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 |
18612
9597e00ed2dd
Add support for "windowbuttonmotionfcn" and "currentpoint"
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18505
diff
changeset
|
370 updateCurrentPoint (figObj, obj, event); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 gh_manager::post_callback (figObj.get_handle (), |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 "windowbuttonupfcn"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 m_mouseAxes = graphics_handle (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 m_mouseMode = NoMode; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 bool Canvas::canvasKeyPressEvent (QKeyEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 if (m_eventMask & KeyPress) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 octave_scalar_map eventData = Utils::makeKeyEventStruct (event); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 gh_manager::post_set (m_handle, "currentcharacter", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 eventData.getfield ("Character"), false); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 gh_manager::post_callback (m_handle, "keypressfcn", eventData); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 bool Canvas::canvasKeyReleaseEvent (QKeyEvent* event) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 gh_manager::post_callback (m_handle, "keyreleasefcn", |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 Utils::makeKeyEventStruct (event)); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 return true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 Canvas* Canvas::create (const std::string& /* name */, QWidget* parent, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18612
diff
changeset
|
410 const graphics_handle& handle) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 // Only OpenGL |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 return new GLCanvas (parent, handle); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 }; // namespace QtHandles |