annotate src/DLD-FUNCTIONS/fltk_backend.cc @ 9455:ee8a035f3997

imported patch fltk_zoom
author shaia@mars.bioc
date Thu, 23 Jul 2009 15:46:42 -0400
parents 8f9d8776d11c
children 110863cd3371
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1 /*
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2
9245
16f53d29049f update copyright notices
John W. Eaton <jwe@octave.org>
parents: 9216
diff changeset
3 Copyright (C) 2007, 2008, 2009 Shai Ayal
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
4
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
5 This file is part of Octave.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
6
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
10 option) any later version.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
11
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
15 for more details.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
16
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
20
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
21 */
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
22
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
23 /*
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
24
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
25 To initialize:
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
26
8270
5a2e45facabe fltk_backend.cc: update initialization comment
John W. Eaton <jwe@octave.org>
parents: 8268
diff changeset
27 backend ("fltk");
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
28 plot (randn (1e3, 1));
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
29
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
30 */
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
31
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
32 #ifdef HAVE_CONFIG_H
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
33 #include <config.h>
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
34 #endif
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
35
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
36 #if defined (HAVE_FLTK)
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
37
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
38 #include <map>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
39 #include <set>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
40 #include <sstream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
41 #include <iostream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
42
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
43 #include <FL/Fl.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
44 #include <FL/Fl_Window.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
45 #include <FL/Fl_Output.H>
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
46 #include <FL/Fl_Button.H>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
47 #include <FL/Fl_Gl_Window.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
48 #include <FL/fl_ask.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
49 #include <FL/fl_draw.H>
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
50 #include <FL/gl.h>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
51
7965
6a6a030a3517 Fix compilation under MSVC
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
52 #ifdef min
6a6a030a3517 Fix compilation under MSVC
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
53 #undef min
6a6a030a3517 Fix compilation under MSVC
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
54 #undef max
6a6a030a3517 Fix compilation under MSVC
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
55 #endif
6a6a030a3517 Fix compilation under MSVC
John W. Eaton <jwe@octave.org>
parents: 7954
diff changeset
56
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
57 #include "cmd-edit.h"
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
58 #include "defun-dld.h"
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
59 #include "error.h"
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
60 #include "gl-render.h"
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
61 #include "graphics.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
62 #include "parse.h"
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
63 #include "variables.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
64
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
65 #define FLTK_BACKEND_NAME "fltk"
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
66
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
67 const char* help_text = "\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
68 Keyboard Shortcuts\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
69 a - autoscale\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
70 g - toggle grid\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
71 \n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
72 Mouse\n\
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
73 left drag - pan\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
74 mouse wheel - zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
75 right drag - rectangle zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
76 left double click - autoscale\n\
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
77 ";
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
78
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
79
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
80 class OpenGL_fltk : public Fl_Gl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
81 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
82 public:
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
83 OpenGL_fltk (int xx, int yy, int ww, int hh, double num)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
84 : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), in_zoom (false)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
85 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
86 // ask for double buffering and a depth buffer
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
87 mode (FL_DEPTH | FL_DOUBLE);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
88 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
89
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
90 ~OpenGL_fltk (void) { }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
91
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
92 void zoom (bool z) { in_zoom = z; }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
93 bool zoom (void) { return in_zoom; }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
94 void set_zoom_box (const Matrix& zb) { zoom_box = zb; }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
95
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
96 private:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
97 double number;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
98 opengl_renderer renderer;
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
99 bool in_zoom;
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
100
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
101 // (x1,y1,x2,y2)
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
102 Matrix zoom_box;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
103
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
104 void setup_viewport (int _w, int _h)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
105 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
106 glMatrixMode (GL_PROJECTION);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
107 glLoadIdentity ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
108 glViewport (0, 0, _w, _h);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
109 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
110
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
111 void draw (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
112 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
113 if (!valid ())
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
114 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
115 valid (1);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
116 setup_viewport (w (), h ());
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
117 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
118
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
119 renderer.draw (gh_manager::lookup (number));
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
120 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
121
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
122 void resize (int _x,int _y,int _w,int _h)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
123 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
124 Fl_Gl_Window::resize (_x, _y, _w, _h);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
125 setup_viewport (_w, _h);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
126 redraw ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
127 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
128
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
129 void draw_overlay (void)
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
130 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
131 if (!in_zoom)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
132 return;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
133
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
134 if (!valid())
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
135 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
136 valid(1);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
137 setup_viewport (w (), h ());
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
138 }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
139
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
140 glPushMatrix ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
141
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
142 glMatrixMode (GL_MODELVIEW);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
143 glLoadIdentity ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
144
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
145 glMatrixMode (GL_PROJECTION);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
146 glLoadIdentity ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
147 gluOrtho2D (0.0, w (), 0.0, h ());
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
148
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
149 glPushAttrib (GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
150 glDisable (GL_DEPTH_TEST);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
151
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
152 glLineWidth (1);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
153 glBegin (GL_LINE_STRIP);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
154 gl_color(0);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
155 glVertex2d (zoom_box(0), h () - zoom_box(1));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
156 glVertex2d (zoom_box(0), h () - zoom_box(3));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
157 glVertex2d (zoom_box(2), h () - zoom_box(3));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
158 glVertex2d (zoom_box(2), h () - zoom_box(1));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
159 glVertex2d (zoom_box(0), h () - zoom_box(1));
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
160 glEnd ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
161
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
162 glPopAttrib ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
163 glPopMatrix ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
164 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
165
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
166 int handle (int event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
167 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
168 int retval = Fl_Gl_Window::handle (event);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
169
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
170 switch (event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
171 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
172 case FL_ENTER:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
173 window ()->cursor (FL_CURSOR_CROSS);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
174 return 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
175
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
176 case FL_LEAVE:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
177 window ()->cursor (FL_CURSOR_DEFAULT);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
178 return 1;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
179 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
180
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
181 return retval;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
182 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
183 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
184
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
185 class plot_window : public Fl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
186 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
187 public:
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
188 plot_window (int _x, int _y, int _w, int _h, figure::properties& _fp)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
189 : Fl_Window (_x, _y, _w, _h, "octave"), fp (_fp)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
190 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
191 callback (window_close, static_cast<void*> (this));
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
192
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
193 begin ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
194 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
195 canvas = new
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
196 OpenGL_fltk (0, 0, _w , _h - status_h, number ());
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
197
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
198 autoscale = new
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
199 Fl_Button (0,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
200 _h - status_h,
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
201 status_h,
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
202 status_h,
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
203 "A");
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
204 autoscale->callback (button_callback, static_cast<void*> (this));
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
205
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
206 togglegrid = new
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
207 Fl_Button (status_h,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
208 _h - status_h,
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
209 status_h,
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
210 status_h,
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
211 "G");
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
212 togglegrid->callback (button_callback, static_cast<void*> (this));
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
213
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
214 help = new
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
215 Fl_Button (2*status_h,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
216 _h - status_h,
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
217 status_h,
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
218 status_h,
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
219 "?");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
220 help->callback (button_callback, static_cast<void*> (this));
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
221
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
222 status = new
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
223 Fl_Output (3*status_h,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
224 _h - status_h,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
225 _w > 2*status_h ? _w - status_h : 0,
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
226 status_h, "");
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
227
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
228 status->textcolor (FL_BLACK);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
229 status->color (FL_GRAY);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
230 status->textfont (FL_COURIER);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
231 status->textsize (10);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
232 status->box (FL_ENGRAVED_BOX);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
233
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
234 // This allows us to have a valid OpenGL context right away
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
235 canvas->mode (FL_DEPTH | FL_DOUBLE );
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
236 show ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
237 canvas->show ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
238 canvas->make_current ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
239 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
240 end ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
241
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
242 status->show ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
243 autoscale->show ();
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
244 togglegrid->show ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
245
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
246 resizable (canvas);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
247 size_range (4*status_h, 2*status_h);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
248
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
249 std::stringstream name;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
250 name << "octave: figure " << number ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
251 label (name.str ().c_str ());
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
252 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
253
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
254 ~plot_window (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
255 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
256 canvas->hide ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
257 status->hide ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
258 this->hide ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
259 delete canvas;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
260 delete status;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
261 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
262
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
263 // FIXME -- this could change
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
264 double number (void) { return fp.get___myhandle__ ().value (); }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
265
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
266 void mark_modified (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
267 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
268 damage (FL_DAMAGE_ALL);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
269 canvas->damage (FL_DAMAGE_ALL);
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
270 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
271
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
272 private:
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
273 // figure properties
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
274 figure::properties& fp;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
275
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
276 // status area height
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
277 static const int status_h = 20;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
278
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
279 // window callback
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
280 static void window_close (Fl_Widget*, void* data)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
281 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
282 octave_value_list args;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
283 args(0) = static_cast<plot_window*> (data)->number ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
284 feval ("close", args);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
285 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
286
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
287 // button callbacks
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
288 static void button_callback (Fl_Widget* ww, void* data)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
289 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
290 static_cast<plot_window*> (data)->button_press (ww);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
291 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
292
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
293 void button_press (Fl_Widget* widg)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
294 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
295 if (widg == autoscale)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
296 axis_auto ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
297
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
298 if (widg == togglegrid)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
299 toggle_grid ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
300
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
301 if (widg == help)
9060
de7cef39f505 fltk_backend.cc: don't pass arbitrary string as format
John W. Eaton <jwe@octave.org>
parents: 8333
diff changeset
302 fl_message ("%s", help_text);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
303 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
304
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
305 OpenGL_fltk* canvas;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
306 Fl_Button* autoscale;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
307 Fl_Button* togglegrid;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
308 Fl_Button* help;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
309 Fl_Output* status;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
310
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
311 void axis_auto (void)
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
312 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
313 octave_value_list args;
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
314 args(0) = "auto";
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
315 feval ("axis",args);
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
316 mark_modified ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
317 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
318
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
319 void toggle_grid (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
320 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
321 feval ("grid");
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
322 mark_modified ();
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
323 }
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
324
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
325 void pixel2pos (int px, int py, double& xx, double& yy) const
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
326 {
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
327 graphics_object ax = gh_manager::get_object (fp.get_currentaxes ());
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
328
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
329 if (ax && ax.isa ("axes"))
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
330 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
331 axes::properties& ap =
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
332 dynamic_cast<axes::properties&> (ax.get_properties ());
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
333 ColumnVector pp = ap.pixel2coord (px, py);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
334 xx = pp(0);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
335 yy = pp(1);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
336 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
337 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
338
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
339 graphics_handle pixel2axes_or_ca (int px, int py )
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
340 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
341 Matrix kids = fp.get_children ();
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
342 int len = kids.length ();
9442
2d73b19c5507 improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
343
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
344 for (int k = 0; k < len; k++)
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
345 {
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
346 graphics_handle hnd = gh_manager::lookup (kids(k));
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
347
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
348 if (hnd.ok ())
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
349 {
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
350 graphics_object kid = gh_manager::get_object (hnd);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
351
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
352 if (kid.valid_object () && kid.isa ("axes"))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
353 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
354 Matrix bb = kid.get_properties ().get_boundingbox (true);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
355
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
356 if (bb(0) <= px && px < (bb(0)+bb(2))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
357 && bb(1) <= py && py < (bb(1)+bb(3)))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
358 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
359 return hnd;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
360 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
361 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
362 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
363 }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
364 return fp.get_currentaxes ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
365 }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
366
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
367 void pixel2status (int px0, int py0, int px1 = -1, int py1 = -1)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
368 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
369 double x0, y0, x1, y1;
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
370 std::stringstream cbuf;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
371
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
372 pixel2pos (px0, py0, x0, y0);
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
373 cbuf << "[" << x0 << ", " << y0 << "]";
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
374 if (px1 >= 0)
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
375 {
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
376 pixel2pos (px1, py1, x1, y1);
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
377 cbuf << " -> ["<< x1 << ", " << y1 << "]";
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
378 }
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
379
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
380 status->value (cbuf.str ().c_str ());
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
381 status->redraw ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
382 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
383
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
384 void resize (int _x,int _y,int _w,int _h)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
385 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
386 Fl_Window::resize (_x, _y, _w, _h);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
387
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
388 Matrix pos (1,4,0);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
389 pos(0) = _x;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
390 pos(1) = _y;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
391 pos(2) = _w;
7861
7397a0026ca8 make the fltk_backend canvas the size of figure.position
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7858
diff changeset
392 pos(3) = _h - status_h;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
393
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
394 fp.set_position (pos);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
395 }
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
396
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
397 void draw (void)
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
398 {
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
399 Matrix pos = fp.get_position ().matrix_value ();
7861
7397a0026ca8 make the fltk_backend canvas the size of figure.position
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7858
diff changeset
400 Fl_Window::resize (pos(0), pos(1) , pos(2), pos(3) + status_h);
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
401
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
402 return Fl_Window::draw ();
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
403 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
404
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
405 int handle (int event)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
406 {
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
407 static int px0,py0;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
408
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
409 int retval = Fl_Window::handle (event);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
410
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
411 // we only handle events which are in the canvas area
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
412 if (Fl::event_y () >= h() - status_h)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
413 return retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
414
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
415 switch (event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
416 {
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
417 case FL_KEYDOWN:
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
418 switch(Fl::event_key ())
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
419 {
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
420 case 'a':
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
421 case 'A':
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
422 axis_auto ();
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
423 break;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
424
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
425 case 'g':
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
426 case 'G':
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
427 toggle_grid ();
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
428 break;
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
429 }
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
430 break;
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
431
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
432 case FL_MOVE:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
433 pixel2status (Fl::event_x (), Fl::event_y ());
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
434 break;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
435
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
436 case FL_PUSH:
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
437 if (Fl::event_button () == 1 || Fl::event_button () == 3)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
438 {
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
439 px0 = Fl::event_x ();
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
440 py0 = Fl::event_y ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
441 return 1;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
442 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
443 break;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
444
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
445 case FL_DRAG:
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
446 pixel2status (px0, py0, Fl::event_x (), Fl::event_y ());
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
447 if (Fl::event_button () == 1)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
448 {
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
449 graphics_object ax =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
450 gh_manager::get_object (pixel2axes_or_ca (px0, py0));
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
451 if (ax && ax.isa ("axes"))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
452 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
453 axes::properties& ap =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
454 dynamic_cast<axes::properties&> (ax.get_properties ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
456 double x0, y0, x1, y1;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
457 pixel2pos (px0, py0, x0, y0);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
458 pixel2pos (Fl::event_x (), Fl::event_y (), x1, y1);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
459 px0 = Fl::event_x ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
460 py0 = Fl::event_y ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
461
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
462 ap.translate_view (x0 - x1, y0 - y1);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
463 mark_modified ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
464 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
465 return 1;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
466 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
467 else if (Fl::event_button () == 3)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
468 {
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
469 canvas->zoom (true);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
470 Matrix zoom_box (1,4,0);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
471 zoom_box (0) = px0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
472 zoom_box (1) = py0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
473 zoom_box (2) = Fl::event_x ();
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
474 zoom_box (3) = Fl::event_y ();
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
475 canvas->set_zoom_box (zoom_box);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
476 canvas->redraw_overlay ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
477 }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
478
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
479 break;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
480
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
481 case FL_MOUSEWHEEL:
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
482 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
483 // Parameter controlling how fast we zoom. FIXME: Should
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
484 // this be user tweakable?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
485 const double zoom_speed = 0.05;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
486
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
487 graphics_object ax =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
488 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
489 Fl::event_y ()));
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
490 if (ax && ax.isa ("axes"))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
491 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
492 axes::properties& ap =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
493 dynamic_cast<axes::properties&> (ax.get_properties ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
494
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
495 // Determine if we're zooming in or out
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
496 const double factor =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
497 (Fl::event_dy () > 0) ? 1.0 + zoom_speed : 1.0 - zoom_speed;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
498
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
499 // Get the point we're zooming about
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
500 double x1, y1;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
501 pixel2pos (Fl::event_x (), Fl::event_y (), x1, y1);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
502
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
503 ap.zoom_about_point (x1, y1, factor, false);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
504 mark_modified ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
505 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
506 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
507 return 1;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
508
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
509 case FL_RELEASE:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
510 if (Fl::event_button () == 1)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
511 {
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
512 if ( Fl::event_clicks () == 1)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
513 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
514 graphics_object ax =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
515 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
516 Fl::event_y ()));
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
517 if (ax && ax.isa ("axes"))
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
518 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
519 axes::properties& ap =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
520 dynamic_cast<axes::properties&> (ax.get_properties ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
521 ap.set_xlimmode("auto");
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
522 ap.set_ylimmode("auto");
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
523 ap.set_zlimmode("auto");
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
524 mark_modified ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
525 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
526 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
527 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
528 if (Fl::event_button () == 3)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
529 {
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
530 // end of drag -- zoom
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
531 if (canvas->zoom ())
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
532 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
533 canvas->zoom (false);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
534 double x0,y0,x1,y1;
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
535 graphics_object ax =
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
536 gh_manager::get_object (pixel2axes_or_ca (px0, py0));
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
537 if (ax && ax.isa ("axes"))
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
538 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
539 axes::properties& ap =
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
540 dynamic_cast<axes::properties&> (ax.get_properties ());
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
541 pixel2pos (px0, py0, x0, y0);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
542 pixel2pos (Fl::event_x (), Fl::event_y (), x1, y1);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
543 Matrix xl (1,2,0);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
544 Matrix yl (1,2,0);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
545 if (x0 < x1)
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
546 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
547 xl(0) = x0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
548 xl(1) = x1;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
549 }
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
550 else
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
551 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
552 xl(0) = x1;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
553 xl(1) = x0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
554 }
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
555 if (y0 < y1)
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
556 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
557 yl(0) = y0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
558 yl(1) = y1;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
559 }
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
560 else
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
561 {
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
562 yl(0) = y1;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
563 yl(1) = y0;
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
564 }
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
565 ap.zoom (xl, yl);
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
566 mark_modified ();
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
567 }
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
568 }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
569 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
570 break;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
571 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
572
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
573 return retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
574 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
575 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
576
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
577 class figure_manager
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
578 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
579 public:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
580
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
581 static bool instance_ok (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
582 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
583 bool retval = true;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
584
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
585 if (! instance)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
586 instance = new figure_manager ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
587
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
588 if (! instance)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
589 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
590 ::error ("unable to create figure_manager object!");
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
591
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
592 retval = false;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
593 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
594
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
595 return retval;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
596 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
597
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
598 ~figure_manager (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
599 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
600 close_all ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
601 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
602
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
603 static void close_all (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
604 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
605 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
606 instance->do_close_all ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
607 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
608
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
609 static void new_window (figure::properties& fp)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
610 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
611 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
612 instance->do_new_window (fp);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
613 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
614
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
615 static void delete_window (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
616 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
617 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
618 instance->do_delete_window (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
619 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
620
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
621 static void delete_window (std::string idx_str)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
622 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
623 delete_window (str2idx (idx_str));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
624 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
625
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
626 static void mark_modified (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
627 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
628 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
629 instance->do_mark_modified (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
630 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
631
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
632 static void mark_modified (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
633 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
634 mark_modified (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
635 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
636
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
637 static Matrix get_size (int idx)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
638 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
639 return instance_ok () ? instance->do_get_size (idx) : Matrix ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
640 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
641
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
642 static Matrix get_size (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
643 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
644 return get_size (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
645 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
646
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
647 private:
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
648
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
649 static figure_manager *instance;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
650
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
651 figure_manager (void) { }
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
652
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
653 // No copying!
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
654 figure_manager (const figure_manager&);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
655 figure_manager& operator = (const figure_manager&);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
656
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
657 // singelton -- hide all of the above
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
658
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
659 static int curr_index;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
660 typedef std::map<int, plot_window*> window_map;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
661 typedef window_map::iterator wm_iterator;;
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
662 window_map windows;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
663
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
664 static std::string fltk_idx_header;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
665
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
666 void do_close_all (void)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
667 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
668 wm_iterator win;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
669 for (win = windows.begin (); win != windows.end (); win++)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
670 delete win->second;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
671 windows.clear ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
672 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
673
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
674 void do_new_window (figure::properties& fp)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
675 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
676 int x, y, w, h;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
677
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
678 int idx = figprops2idx (fp);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
679 if (idx >= 0 && windows.find (idx) == windows.end ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
680 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
681 default_size (x, y, w, h);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
682 idx2figprops (curr_index , fp);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
683 windows[curr_index++] = new plot_window (x, y, w, h, fp);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
684 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
685 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
686
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
687 void do_delete_window (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
688 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
689 wm_iterator win;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
690 if ((win = windows.find (idx)) != windows.end ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
691 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
692 delete win->second;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
693 windows.erase (win);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
694 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
695 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
696
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
697 void do_mark_modified (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
698 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
699 wm_iterator win;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
700 if ((win = windows.find (idx)) != windows.end ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
701 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
702 win->second->mark_modified ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
703 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
704 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
705
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
706 Matrix do_get_size (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
707 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
708 Matrix sz (1, 2, 0.0);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
709
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
710 wm_iterator win;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
711 if ((win = windows.find (idx)) != windows.end ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
712 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
713 sz(0) = win->second->w ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
714 sz(1) = win->second->h ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
715 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
716
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
717 return sz;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
718 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
719
8268
738c5d74fcfc fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents: 8267
diff changeset
720 // FIXME -- default size should be configurable.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
721 void default_size (int& x, int& y, int& w, int& h)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
722 {
8268
738c5d74fcfc fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents: 8267
diff changeset
723 x = 0;
738c5d74fcfc fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents: 8267
diff changeset
724 y = 0;
738c5d74fcfc fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents: 8267
diff changeset
725 w = 640;
738c5d74fcfc fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents: 8267
diff changeset
726 h = 480;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
727 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
728
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
729 static int str2idx (const caseless_str clstr)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
730 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
731 int ind;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
732 if (clstr.find (fltk_idx_header,0) == 0)
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
733 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
734 std::istringstream istr (clstr.substr (fltk_idx_header.size ()));
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
735 if (istr >> ind)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
736 return ind;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
737 }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
738 error ("fltk_backend: could not recognize fltk index");
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
739 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
740 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
741
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
742 void idx2figprops (int idx, figure::properties& fp)
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
743 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
744 std::ostringstream ind_str;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
745 ind_str << fltk_idx_header << idx;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
746 fp.set___plot_stream__ (ind_str.str ());
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
747 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
748
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
749 static int figprops2idx (const figure::properties& fp)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
750 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
751 if (fp.get___backend__ () == FLTK_BACKEND_NAME)
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
752 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
753 octave_value ps = fp.get___plot_stream__ ();
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
754 if (ps.is_string ())
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
755 return str2idx (ps.string_value ());
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
756 else
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
757 return 0;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
758 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
759 error ("fltk_backend:: figure is not fltk");
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
760 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
761 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
762
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
763 static int hnd2idx (const double h)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
764 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
765 graphics_object fobj = gh_manager::get_object (h);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
766 if (fobj && fobj.isa ("figure"))
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
767 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
768 figure::properties& fp =
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
769 dynamic_cast<figure::properties&> (fobj.get_properties ());
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
770 return figprops2idx (fp);
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
771 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
772 error ("fltk_backend:: not a figure");
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
773 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
774 }
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
775
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
776 static int hnd2idx (const graphics_handle& fh)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
777 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
778 return hnd2idx (fh.value ());
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
779 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
780 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
781
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
782 figure_manager *figure_manager::instance = 0;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
783
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
784 std::string figure_manager::fltk_idx_header="fltk index=";
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
785 int figure_manager::curr_index = 1;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
786
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
787 class fltk_backend : public base_graphics_backend
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
788 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
789 public:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
790 fltk_backend (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
791 : base_graphics_backend (FLTK_BACKEND_NAME) { }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
792
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
793 ~fltk_backend (void) { }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
794
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
795 bool is_valid (void) const { return true; }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
796
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
797 void object_destroyed (const graphics_object& go)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
798 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
799 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
800 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
801 octave_value ov = go.get (caseless_str ("__plot_stream__"));
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
802 figure_manager::delete_window (ov.string_value ());
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
803 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
804 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
805
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
806 void property_changed (const graphics_object& go, int id)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
807 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
808 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
809 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
810 octave_value ov = go.get (caseless_str ("__plot_stream__"));
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
811
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
812 if (! ov.is_empty ())
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
813 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
814 switch (id)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
815 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
816 case base_properties::VISIBLE:
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8270
diff changeset
817 // FIXME -- something to do here.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
818 break;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
819 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
820 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
821 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
822 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
823
8077
a4e03f9b4b8a Fix FLTK backend update
Michael Goffioul
parents: 8060
diff changeset
824 void redraw_figure (const graphics_object& go) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
825 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
826 figure_manager::mark_modified (go.get_handle ());
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
827 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
828
8077
a4e03f9b4b8a Fix FLTK backend update
Michael Goffioul
parents: 8060
diff changeset
829 void print_figure (const graphics_object& /*go*/,
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
830 const std::string& /*term*/,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
831 const std::string& /*file*/, bool /*mono*/,
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
832 const std::string& /*debug_file*/) const { }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
833
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
834 Matrix get_canvas_size (const graphics_handle& fh) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
835 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
836 return figure_manager::get_size (fh);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
837 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
838
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
839 double get_screen_resolution (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
840 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
841 // FLTK doesn't give this info
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
842 return 72.0;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
843 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
844
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
845 Matrix get_screen_size (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
846 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
847 Matrix sz (1, 2, 0.0);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
848 sz(0) = Fl::w ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
849 sz(1) = Fl::h ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
850 return sz;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
851 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
852 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
853
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
854 static bool backend_registered = false;
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
855 // give FLTK no more than 0.01 sec to do it's stuff
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
856 static double fltk_maxtime = 1e-2;
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
857
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
858 static int
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
859 __fltk_redraw__ (void)
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
860 {
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
861 if (backend_registered)
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
862 {
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
863 // we scan all figures and add those which use FLTK as a backend
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
864 graphics_object obj = gh_manager::get_object (0);
8263
22c078fd926b make fltk backend figures work again
John W. Eaton <jwe@octave.org>
parents: 8077
diff changeset
865 if (obj && obj.isa ("root"))
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
866 {
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
867 base_properties& props = obj.get_properties ();
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
868 Matrix children = props.get_children ();
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
869
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
870 for (octave_idx_type n = 0; n < children.numel (); n++)
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
871 {
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
872 graphics_object fobj = gh_manager::get_object (children (n));
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
873 if (fobj && fobj.isa ("figure"))
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
874 {
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
875 figure::properties& fp =
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
876 dynamic_cast<figure::properties&> (fobj.get_properties ());
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
877 if (fp.get___backend__ () == FLTK_BACKEND_NAME)
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
878 figure_manager::new_window (fp);
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
879 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
880 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
881 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
882
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
883 Fl::wait (fltk_maxtime);
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
884 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
885
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
886 return 0;
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
887 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
888
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
889 DEFUN_DLD (__fltk_redraw__, , , "")
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
890 {
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
891 __fltk_redraw__ ();
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
892
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
893 return octave_value ();
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
894 }
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
895
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
896 // call this to init the fltk backend
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
897 DEFUN_DLD (__init_fltk__, , , "")
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
898 {
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
899 if (! backend_registered)
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
900 {
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
901 mlock ();
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
902
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
903 graphics_backend::register_backend (new fltk_backend);
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
904 backend_registered = true;
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
905
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
906 octave_value_list args;
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
907 args(0) = "__fltk_redraw__";
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
908 feval ("add_input_event_hook", args, 0);
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
909 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
910
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
911 octave_value retval;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
912 return retval;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
913 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
914
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
915
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
916 // call this to delete the fltk backend
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
917 DEFUN_DLD (__remove_fltk__, , , "")
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
918 {
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
919 if (backend_registered)
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
920 {
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
921 munlock ("__init_fltk__");
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
922
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
923 figure_manager::close_all ();
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
924 graphics_backend::unregister_backend (FLTK_BACKEND_NAME);
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
925 backend_registered = false;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
926
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
927 octave_value_list args;
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
928 args(0) = "__fltk_redraw__";
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
929 feval ("remove_input_event_hook", args, 0);
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
930
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
931 // FIXME ???
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
932 // give FLTK 10 seconds to wrap it up
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
933 Fl::wait(10);
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
934 }
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
935
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
936 octave_value retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
937 return retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
938 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
939
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
940 DEFUN_DLD (__fltk_maxtime__, args, ,"")
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
941 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
942 octave_value retval = fltk_maxtime;
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
943
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
944 if (args.length () == 1)
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
945 {
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
946 if (args(0).is_real_scalar ())
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
947 fltk_maxtime = args(0).double_value ();
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
948 else
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
949 error ("argument must be a real scalar");
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
950 }
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
951
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
952 return retval;
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
953 }
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
954
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
955 #endif
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
956
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
957 /*
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
958 ;;; Local Variables: ***
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
959 ;;; mode: C++ ***
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
960 ;;; End: ***
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
961 */