Mercurial > octave
annotate src/DLD-FUNCTIONS/fltk_backend.cc @ 10009:360de61b2722
corrected redundency in title setting introduced in previous changeset
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Sun, 20 Dec 2009 23:07:31 +0200 |
parents | b6261d776a82 |
children | 4b270d1540f7 |
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 | 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 | 36 #if defined (HAVE_FLTK) |
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 | 52 #ifdef min |
53 #undef min | |
54 #undef max | |
55 #endif | |
56 | |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
57 #include "cmd-edit.h" |
9652
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
58 #include "lo-ieee.h" |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
59 |
7954 | 60 #include "defun-dld.h" |
61 #include "error.h" | |
62 #include "gl-render.h" | |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
63 #include "gl2ps-renderer.h" |
7954 | 64 #include "graphics.h" |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
65 #include "parse.h" |
9991
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
66 #include "toplev.h" |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
67 #include "variables.h" |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
68 |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
69 #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
|
70 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
71 // Give FLTK no more than 0.01 sec to do its stuff. |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
72 static double fltk_maxtime = 1e-2; |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
73 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
74 const char* help_text = "\ |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
75 Keyboard Shortcuts\n\ |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
76 a - autoscale\n\ |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
77 g - toggle grid\n\ |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
78 \n\ |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
79 Mouse\n\ |
9455 | 80 left drag - pan\n\ |
81 mouse wheel - zoom\n\ | |
82 right drag - rectangle zoom\n\ | |
83 left double click - autoscale\n\ | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
84 "; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
85 |
9455 | 86 |
7869 | 87 class OpenGL_fltk : public Fl_Gl_Window |
88 { | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
89 public: |
7869 | 90 OpenGL_fltk (int xx, int yy, int ww, int hh, double num) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
91 : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), in_zoom (false), |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
92 print_filename ("") |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
93 { |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
94 // Ask for double buffering and a depth buffer. |
7869 | 95 mode (FL_DEPTH | FL_DOUBLE); |
96 } | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
97 |
7869 | 98 ~OpenGL_fltk (void) { } |
99 | |
9640 | 100 void zoom (bool z) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
101 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
102 in_zoom = z; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
103 if (! in_zoom) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
104 hide_overlay (); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
105 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
106 |
7869 | 107 bool zoom (void) { return in_zoom; } |
108 void set_zoom_box (const Matrix& zb) { zoom_box = zb; } | |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
109 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
110 void print (const std::string& filename) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
111 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
112 print_filename = filename; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
113 } |
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
|
114 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
115 private: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
116 double number; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
117 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
|
118 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
|
119 // (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
|
120 Matrix zoom_box; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
121 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
122 std::string print_filename; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
123 |
7869 | 124 void setup_viewport (int _w, int _h) |
125 { | |
126 glMatrixMode (GL_PROJECTION); | |
127 glLoadIdentity (); | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
128 glViewport (0, 0, _w, _h); |
7869 | 129 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
130 |
7869 | 131 void draw (void) |
132 { | |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
133 if (! valid ()) |
7869 | 134 { |
135 valid (1); | |
136 setup_viewport (w (), h ()); | |
137 } | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
138 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
139 if (! print_filename.empty ()) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
140 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
141 opengl_renderer *rend = new glps_renderer (print_filename); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
142 rend->draw (gh_manager::lookup (number)); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
143 print_filename = ""; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
144 delete rend; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
145 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
146 else |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
147 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
148 renderer.draw (gh_manager::lookup (number)); |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
149 |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
150 if (zoom ()) |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
151 overlay (); |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
152 } |
7869 | 153 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
154 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
155 void resize (int _x, int _y, int _w, int _h) |
7869 | 156 { |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
157 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
|
158 setup_viewport (_w, _h); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
159 redraw (); |
7869 | 160 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
161 |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
162 void zoom_box_vertex (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
|
163 { |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
164 glVertex2d (zoom_box(0), h () - zoom_box(1)); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
165 glVertex2d (zoom_box(0), h () - zoom_box(3)); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
166 glVertex2d (zoom_box(2), h () - zoom_box(3)); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
167 glVertex2d (zoom_box(2), h () - zoom_box(1)); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
168 glVertex2d (zoom_box(0), h () - zoom_box(1)); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
169 } |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
170 |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
171 void overlay (void) |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
172 { |
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
|
173 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
|
174 |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
175 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
|
176 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
|
177 |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
182 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
|
183 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
|
184 |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
185 glBegin (GL_POLYGON); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
186 glColor4f (0.45, 0.62, 0.81, 0.1); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
187 zoom_box_vertex (); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
188 glEnd (); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
189 |
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
|
190 glBegin (GL_LINE_STRIP); |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
191 glLineWidth (1.5); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
192 glColor4f (0.45, 0.62, 0.81, 0.9); |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
193 zoom_box_vertex (); |
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
|
194 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
|
195 |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
196 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
|
197 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
|
198 } |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
199 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
200 int handle (int event) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
201 { |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
202 int retval = Fl_Gl_Window::handle (event); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
203 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
204 switch (event) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
205 { |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
206 case FL_ENTER: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
207 window ()->cursor (FL_CURSOR_CROSS); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
208 return 1; |
7869 | 209 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
210 case FL_LEAVE: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
211 window ()->cursor (FL_CURSOR_DEFAULT); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
212 return 1; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
213 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
214 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
215 return retval; |
7869 | 216 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
217 }; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
218 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
219 // Parameter controlling how fast we zoom when using the scrool wheel. |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
220 static double wheel_zoom_speed = 0.05; |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
221 |
7869 | 222 class plot_window : public Fl_Window |
223 { | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
224 public: |
7869 | 225 plot_window (int _x, int _y, int _w, int _h, figure::properties& _fp) |
226 : 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
|
227 { |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
228 callback (window_close, static_cast<void*> (this)); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
229 |
7869 | 230 begin (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
231 { |
7869 | 232 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
|
233 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
|
234 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
235 autoscale = new |
7869 | 236 Fl_Button (0, |
237 _h - status_h, | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
238 status_h, |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
239 status_h, |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
240 "A"); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
241 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
|
242 |
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
|
243 togglegrid = new |
7869 | 244 Fl_Button (status_h, |
245 _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
|
246 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
|
247 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
|
248 "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
|
249 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
|
250 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
251 help = new |
7869 | 252 Fl_Button (2*status_h, |
253 _h - status_h, | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
254 status_h, |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
255 status_h, |
9455 | 256 "?"); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
257 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
|
258 |
7869 | 259 status = new |
260 Fl_Output (3*status_h, | |
261 _h - status_h, | |
262 _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
|
263 status_h, ""); |
7869 | 264 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
265 status->textcolor (FL_BLACK); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
266 status->color (FL_GRAY); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
267 status->textfont (FL_COURIER); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
268 status->textsize (10); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
269 status->box (FL_ENGRAVED_BOX); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
270 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
271 // This allows us to have a valid OpenGL context right away. |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
272 canvas->mode (FL_DEPTH | FL_DOUBLE ); |
9973
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
273 if (fp.is_visible ()) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
274 { |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
275 show (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
276 canvas->show (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
277 canvas->make_current (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
278 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
279 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
280 end (); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
281 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
282 status->show (); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
283 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
|
284 togglegrid->show (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
285 |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
286 set_name (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
287 resizable (canvas); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
288 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
|
289 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
290 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
291 |
7869 | 292 ~plot_window (void) |
293 { | |
294 canvas->hide (); | |
295 status->hide (); | |
296 this->hide (); | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
297 delete canvas; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
298 delete status; |
7869 | 299 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
300 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
301 // FIXME -- this could change. |
7869 | 302 double number (void) { return fp.get___myhandle__ ().value (); } |
303 | |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
304 void print (const std::string& fname) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
305 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
306 canvas->print (fname); |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
307 |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
308 // Print immediately so the output file will exist when the drawnow |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
309 // command is done. |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
310 mark_modified (); |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
311 Fl::wait (fltk_maxtime); |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
312 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
313 |
7869 | 314 void mark_modified (void) |
315 { | |
316 damage (FL_DAMAGE_ALL); | |
317 canvas->damage (FL_DAMAGE_ALL); | |
7840
2c8f693c32fd
convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents:
7839
diff
changeset
|
318 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
319 |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
320 void set_name (void) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
321 { |
10009
360de61b2722
corrected redundency in title setting introduced in previous changeset
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10008
diff
changeset
|
322 window_label = fp.get_title (); |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
323 label (window_label.c_str ()); |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
324 } |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
325 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
326 private: |
9973
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
327 // window name -- this must exists for the duration of the window's |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
328 // life |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
329 std::string window_label; |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
330 |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
331 // Figure properties. |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
332 figure::properties& fp; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
333 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
334 // Status area height. |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
335 static const int status_h = 20; |
7869 | 336 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
337 // Window callback. |
7869 | 338 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
|
339 { |
7869 | 340 octave_value_list args; |
341 args(0) = static_cast<plot_window*> (data)->number (); | |
342 feval ("close", args); | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
343 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
344 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
345 // Button callbacks. |
7869 | 346 static void button_callback (Fl_Widget* ww, void* data) |
347 { | |
348 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
|
349 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
350 |
7869 | 351 void button_press (Fl_Widget* widg) |
352 { | |
353 if (widg == autoscale) | |
354 axis_auto (); | |
355 | |
356 if (widg == togglegrid) | |
357 toggle_grid (); | |
358 | |
359 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
|
360 fl_message ("%s", help_text); |
7869 | 361 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
362 |
7869 | 363 OpenGL_fltk* canvas; |
364 Fl_Button* autoscale; | |
365 Fl_Button* togglegrid; | |
366 Fl_Button* help; | |
367 Fl_Output* status; | |
368 | |
369 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
|
370 { |
7869 | 371 octave_value_list args; |
9974
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
372 args(0) = fp.get_currentaxes ().as_octave_value (); |
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
373 args(1) = "auto"; |
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
374 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
|
375 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
|
376 } |
4dc3e0ff730a
Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7842
diff
changeset
|
377 |
7869 | 378 void toggle_grid (void) |
379 { | |
9974
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
380 octave_value_list args; |
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
381 args(0) = fp.get_currentaxes ().as_octave_value (); |
118158f10628
fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9973
diff
changeset
|
382 feval ("grid", args); |
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
|
383 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
|
384 } |
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
|
385 |
9640 | 386 void pixel2pos |
387 (graphics_handle ax, int px, int py, double& xx, double& yy) const | |
7869 | 388 { |
9640 | 389 pixel2pos ( gh_manager::get_object (ax), px, py, xx, yy); |
390 } | |
7869 | 391 |
9640 | 392 void pixel2pos |
393 (graphics_object ax, int px, int py, double& xx, double& yy) const | |
394 { | |
7869 | 395 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
|
396 { |
7869 | 397 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
|
398 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
|
399 ColumnVector pp = ap.pixel2coord (px, py); |
7869 | 400 xx = pp(0); |
401 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
|
402 } |
7869 | 403 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
404 |
9455 | 405 graphics_handle pixel2axes_or_ca (int px, int py ) |
7869 | 406 { |
407 Matrix kids = fp.get_children (); | |
9455 | 408 int len = kids.length (); |
9442
2d73b19c5507
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
409 |
9455 | 410 for (int k = 0; k < len; k++) |
9443 | 411 { |
9455 | 412 graphics_handle hnd = gh_manager::lookup (kids(k)); |
413 | |
414 if (hnd.ok ()) | |
9443 | 415 { |
9455 | 416 graphics_object kid = gh_manager::get_object (hnd); |
417 | |
418 if (kid.valid_object () && kid.isa ("axes")) | |
419 { | |
420 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
|
421 |
9455 | 422 if (bb(0) <= px && px < (bb(0)+bb(2)) |
423 && bb(1) <= py && py < (bb(1)+bb(3))) | |
424 { | |
425 return hnd; | |
426 } | |
427 } | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
428 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
429 } |
9455 | 430 return fp.get_currentaxes (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
431 } |
9455 | 432 |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
433 void pixel2status (graphics_handle ax, int px0, int py0, |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
434 int px1 = -1, int py1 = -1) |
9640 | 435 { |
436 pixel2status (gh_manager::get_object (ax), px0, py0, px1, py1); | |
437 } | |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
438 |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
439 void pixel2status (graphics_object ax, int px0, int py0, |
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
440 int px1 = -1, int py1 = -1) |
7869 | 441 { |
442 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
|
443 std::stringstream cbuf; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
444 |
9640 | 445 pixel2pos (ax, px0, py0, x0, y0); |
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 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
|
447 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
|
448 { |
9640 | 449 pixel2pos (ax, px1, py1, 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
|
450 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
|
451 } |
7840
2c8f693c32fd
convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents:
7839
diff
changeset
|
452 |
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
|
453 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
|
454 status->redraw (); |
7869 | 455 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
456 |
7869 | 457 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
|
458 { |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
459 Fl_Window::resize (_x, _y, _w, _h); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
460 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
461 Matrix pos (1,4,0); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
462 pos(0) = _x; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
463 pos(1) = _y; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
464 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
|
465 pos(3) = _h - status_h; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
466 |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
467 fp.set_position (pos); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
468 } |
7839
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
469 |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
470 void draw (void) |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
471 { |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
472 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
|
473 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
|
474 |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
475 return Fl_Window::draw (); |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
476 } |
7869 | 477 |
478 int handle (int event) | |
479 { | |
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
|
480 static int px0,py0; |
9640 | 481 static graphics_object ax0; |
482 | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
483 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
484 int retval = Fl_Window::handle (event); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
485 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
486 // We only handle events which are in the canvas area. |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
487 if (Fl::event_y () >= h() - status_h) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
488 return retval; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
489 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
490 switch (event) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
491 { |
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
|
492 case FL_KEYDOWN: |
7869 | 493 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
|
494 { |
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
|
495 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
|
496 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
|
497 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
|
498 break; |
7869 | 499 |
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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 } |
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
|
505 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
|
506 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
507 case FL_MOVE: |
9640 | 508 pixel2status (pixel2axes_or_ca (Fl::event_x (), Fl::event_y ()), |
509 Fl::event_x (), Fl::event_y ()); | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
510 break; |
7869 | 511 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
512 case FL_PUSH: |
9455 | 513 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
|
514 { |
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
|
515 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
|
516 py0 = Fl::event_y (); |
9640 | 517 ax0 = gh_manager::get_object (pixel2axes_or_ca (px0, py0)); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
518 return 1; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
519 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
520 break; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
521 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
522 case FL_DRAG: |
9640 | 523 pixel2status (ax0, 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
|
524 if (Fl::event_button () == 1) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
525 { |
9640 | 526 if (ax0 && ax0.isa ("axes")) |
9455 | 527 { |
528 axes::properties& ap = | |
9640 | 529 dynamic_cast<axes::properties&> (ax0.get_properties ()); |
9455 | 530 |
531 double x0, y0, x1, y1; | |
9640 | 532 pixel2pos (ax0, px0, py0, x0, y0); |
533 pixel2pos (ax0, Fl::event_x (), Fl::event_y (), x1, y1); | |
9455 | 534 px0 = Fl::event_x (); |
535 py0 = Fl::event_y (); | |
536 | |
537 ap.translate_view (x0 - x1, y0 - y1); | |
538 mark_modified (); | |
539 } | |
540 return 1; | |
541 } | |
542 else if (Fl::event_button () == 3) | |
543 { | |
9443 | 544 Matrix zoom_box (1,4,0); |
545 zoom_box (0) = px0; | |
546 zoom_box (1) = py0; | |
547 zoom_box (2) = Fl::event_x (); | |
548 zoom_box (3) = Fl::event_y (); | |
549 canvas->set_zoom_box (zoom_box); | |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
550 canvas->zoom (true); |
9802
9b4a301d88ed
fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
551 canvas->redraw (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
552 } |
9455 | 553 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
554 break; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
555 |
9455 | 556 case FL_MOUSEWHEEL: |
557 { | |
558 graphics_object ax = | |
559 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (), | |
560 Fl::event_y ())); | |
561 if (ax && ax.isa ("axes")) | |
562 { | |
563 axes::properties& ap = | |
564 dynamic_cast<axes::properties&> (ax.get_properties ()); | |
565 | |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
566 // Determine if we're zooming in or out. |
9455 | 567 const double factor = |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
568 (Fl::event_dy () > 0) ? 1.0 + wheel_zoom_speed : 1.0 - wheel_zoom_speed; |
9455 | 569 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
570 // Get the point we're zooming about. |
9455 | 571 double x1, y1; |
9640 | 572 pixel2pos (ax, Fl::event_x (), Fl::event_y (), x1, y1); |
9455 | 573 |
574 ap.zoom_about_point (x1, y1, factor, false); | |
575 mark_modified (); | |
576 } | |
577 } | |
578 return 1; | |
579 | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
580 case FL_RELEASE: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
581 if (Fl::event_button () == 1) |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
582 { |
9455 | 583 if ( Fl::event_clicks () == 1) |
584 { | |
9640 | 585 if (ax0 && ax0.isa ("axes")) |
9455 | 586 { |
587 axes::properties& ap = | |
9640 | 588 dynamic_cast<axes::properties&> (ax0.get_properties ()); |
9455 | 589 ap.set_xlimmode("auto"); |
590 ap.set_ylimmode("auto"); | |
591 ap.set_zlimmode("auto"); | |
592 mark_modified (); | |
593 } | |
594 } | |
595 } | |
596 if (Fl::event_button () == 3) | |
597 { | |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
598 // End of drag -- zoom. |
9443 | 599 if (canvas->zoom ()) |
600 { | |
601 canvas->zoom (false); | |
602 double x0,y0,x1,y1; | |
9640 | 603 if (ax0 && ax0.isa ("axes")) |
9443 | 604 { |
605 axes::properties& ap = | |
9640 | 606 dynamic_cast<axes::properties&> (ax0.get_properties ()); |
607 pixel2pos (ax0, px0, py0, x0, y0); | |
608 pixel2pos (ax0, Fl::event_x (), Fl::event_y (), x1, y1); | |
9443 | 609 Matrix xl (1,2,0); |
610 Matrix yl (1,2,0); | |
611 if (x0 < x1) | |
612 { | |
613 xl(0) = x0; | |
614 xl(1) = x1; | |
615 } | |
616 else | |
617 { | |
618 xl(0) = x1; | |
619 xl(1) = x0; | |
620 } | |
621 if (y0 < y1) | |
622 { | |
623 yl(0) = y0; | |
624 yl(1) = y1; | |
625 } | |
626 else | |
627 { | |
628 yl(0) = y1; | |
629 yl(1) = y0; | |
630 } | |
631 ap.zoom (xl, yl); | |
632 mark_modified (); | |
633 } | |
634 } | |
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
|
635 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
636 break; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
637 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
638 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
639 return retval; |
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 }; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
642 |
7869 | 643 class figure_manager |
644 { | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
645 public: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
646 |
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
|
647 static bool instance_ok (void) |
7869 | 648 { |
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
|
649 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
|
650 |
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
|
651 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
|
652 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
|
653 |
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 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
|
655 { |
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 ::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
|
657 |
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
|
658 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
|
659 } |
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
|
660 |
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
|
661 return retval; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
662 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
663 |
7869 | 664 ~figure_manager (void) |
665 { | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
666 close_all (); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
667 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
668 |
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
|
669 static void close_all (void) |
7869 | 670 { |
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
|
671 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
|
672 instance->do_close_all (); |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
673 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
674 |
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
|
675 static void new_window (figure::properties& fp) |
7869 | 676 { |
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
|
677 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
|
678 instance->do_new_window (fp); |
7869 | 679 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
680 |
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
|
681 static void delete_window (int idx) |
7869 | 682 { |
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
|
683 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
|
684 instance->do_delete_window (idx); |
7869 | 685 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
686 |
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
|
687 static void delete_window (std::string idx_str) |
7869 | 688 { |
689 delete_window (str2idx (idx_str)); | |
690 } | |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
691 |
9973
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
692 static void toggle_window_visibility (int idx, bool is_visible) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
693 { |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
694 if (instance_ok ()) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
695 instance->do_toggle_window_visibility (idx, is_visible); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
696 } |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
697 |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
698 static void toggle_window_visibility (std::string idx_str, bool is_visible) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
699 { |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
700 toggle_window_visibility (str2idx (idx_str), is_visible); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
701 } |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
702 |
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
|
703 static void mark_modified (int idx) |
7869 | 704 { |
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
|
705 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
|
706 instance->do_mark_modified (idx); |
7869 | 707 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
708 |
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
|
709 static void mark_modified (const graphics_handle& gh) |
7869 | 710 { |
711 mark_modified (hnd2idx (gh)); | |
712 } | |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
713 |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
714 static void set_name (int idx) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
715 { |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
716 if (instance_ok ()) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
717 instance->do_set_name (idx); |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
718 } |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
719 |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
720 static void set_name (std::string idx_str) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
721 { |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
722 set_name (str2idx (idx_str)); |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
723 } |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
724 |
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
|
725 static Matrix get_size (int idx) |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
726 { |
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
|
727 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
|
728 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
729 |
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
|
730 static Matrix get_size (const graphics_handle& gh) |
7869 | 731 { |
732 return get_size (hnd2idx (gh)); | |
733 } | |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
734 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
735 static void print (const graphics_handle& gh , const std::string& filename) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
736 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
737 if (instance_ok ()) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
738 instance->do_print (hnd2idx(gh), filename); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
739 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
740 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
741 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
|
742 |
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
|
743 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
|
744 |
7869 | 745 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
|
746 |
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
|
747 // 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
|
748 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
|
749 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
|
750 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
751 // Singelton -- hide all of the above. |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
752 |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 window_map windows; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
757 |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
758 static std::string fltk_idx_header; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
759 |
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
|
760 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
|
761 { |
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
|
762 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
|
763 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
|
764 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
|
765 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
|
766 } |
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
|
767 |
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
|
768 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
|
769 { |
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
|
770 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
|
771 |
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
|
772 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
|
773 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
|
774 { |
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 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
|
776 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
|
777 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
|
778 } |
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 } |
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
|
780 |
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
|
781 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
|
782 { |
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 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
|
784 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
|
785 { |
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
|
786 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
|
787 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
|
788 } |
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
|
789 } |
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
|
790 |
9973
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
791 void do_toggle_window_visibility (int idx, bool is_visible) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
792 { |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
793 wm_iterator win; |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
794 if ((win = windows.find (idx)) != windows.end ()) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
795 { |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
796 if (is_visible) |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
797 win->second->show (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
798 else |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
799 win->second->hide (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
800 |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
801 win->second->redraw (); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
802 } |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
803 } |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
804 |
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
|
805 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
|
806 { |
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
|
807 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
|
808 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
|
809 { |
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
|
810 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
|
811 } |
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
|
812 } |
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
|
813 |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
814 void do_set_name (int idx) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
815 { |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
816 wm_iterator win; |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
817 if ((win = windows.find (idx)) != windows.end ()) |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
818 { |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
819 win->second->set_name (); |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
820 } |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
821 } |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
822 |
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
|
823 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
|
824 { |
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
|
825 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
|
826 |
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
|
827 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
|
828 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
|
829 { |
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
|
830 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
|
831 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
|
832 } |
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
|
833 |
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
|
834 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
|
835 } |
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 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
837 void do_print (int idx, const std::string& filename) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
838 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
839 wm_iterator win; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
840 if ((win = windows.find (idx)) != windows.end ()) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
841 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
842 win->second->print (filename); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
843 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
844 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
845 |
8268
738c5d74fcfc
fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents:
8267
diff
changeset
|
846 // FIXME -- default size should be configurable. |
7869 | 847 void default_size (int& x, int& y, int& w, int& h) |
848 { | |
8268
738c5d74fcfc
fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents:
8267
diff
changeset
|
849 x = 0; |
738c5d74fcfc
fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents:
8267
diff
changeset
|
850 y = 0; |
738c5d74fcfc
fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents:
8267
diff
changeset
|
851 w = 640; |
738c5d74fcfc
fltk_backend.cc (figure_manager::default_size): increase default window size
John W. Eaton <jwe@octave.org>
parents:
8267
diff
changeset
|
852 h = 480; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
853 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
854 |
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
|
855 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
|
856 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
857 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
|
858 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
|
859 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
860 std::istringstream istr (clstr.substr (fltk_idx_header.size ())); |
7869 | 861 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
|
862 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
|
863 } |
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
|
864 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
|
865 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
|
866 } |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
867 |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
868 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
|
869 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
870 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
|
871 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
|
872 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
|
873 } |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
874 |
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
|
875 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
|
876 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
877 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
|
878 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
879 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
|
880 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
|
881 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
|
882 else |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
883 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
|
884 } |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
885 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
|
886 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
|
887 } |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
888 |
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
|
889 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
|
890 { |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
891 graphics_object fobj = gh_manager::get_object (h); |
7869 | 892 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
|
893 { |
7869 | 894 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
|
895 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
|
896 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
|
897 } |
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
898 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
|
899 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
|
900 } |
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
|
901 |
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
|
902 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
|
903 { |
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
|
904 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
|
905 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
906 }; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
907 |
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
|
908 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
|
909 |
7841
c643e5c520f5
fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7840
diff
changeset
|
910 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
|
911 int figure_manager::curr_index = 1; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
912 |
9652
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
913 static bool backend_registered = false; |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
914 |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
915 static int |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
916 __fltk_redraw__ (void) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
917 { |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
918 if (backend_registered) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
919 { |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
920 // we scan all figures and add those which use FLTK as a backend |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
921 graphics_object obj = gh_manager::get_object (0); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
922 if (obj && obj.isa ("root")) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
923 { |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
924 base_properties& props = obj.get_properties (); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
925 Matrix children = props.get_children (); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
926 |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
927 for (octave_idx_type n = 0; n < children.numel (); n++) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
928 { |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
929 graphics_object fobj = gh_manager::get_object (children (n)); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
930 if (fobj && fobj.isa ("figure")) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
931 { |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
932 figure::properties& fp = |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
933 dynamic_cast<figure::properties&> (fobj.get_properties ()); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
934 if (fp.get___backend__ () == FLTK_BACKEND_NAME) |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
935 figure_manager::new_window (fp); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
936 } |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
937 } |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
938 } |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
939 |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
940 Fl::wait (fltk_maxtime); |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
941 } |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
942 |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
943 return 0; |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
944 } |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
945 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
946 class fltk_backend : public base_graphics_backend |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
947 { |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
948 public: |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
949 fltk_backend (void) |
7869 | 950 : base_graphics_backend (FLTK_BACKEND_NAME) { } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
951 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
952 ~fltk_backend (void) { } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
953 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
954 bool is_valid (void) const { return true; } |
7869 | 955 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
956 void object_destroyed (const graphics_object& go) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
957 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
958 if (go.isa ("figure")) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
959 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
960 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
|
961 figure_manager::delete_window (ov.string_value ()); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
962 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
963 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
964 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
965 void property_changed (const graphics_object& go, int id) |
7869 | 966 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
967 if (go.isa ("figure")) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
968 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
969 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
|
970 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
971 if (! ov.is_empty ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
972 { |
9973
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
973 const figure::properties& fp = |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
974 dynamic_cast<const figure::properties&> (go.get_properties ()); |
cd8f355157b8
Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9951
diff
changeset
|
975 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
976 switch (id) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
977 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
978 case base_properties::VISIBLE: |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
979 figure_manager::toggle_window_visibility (ov.string_value (), fp.is_visible ()); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
980 break; |
10008
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
981 |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
982 case figure::properties::NAME: |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
983 case figure::properties::NUMBERTITLE: |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
984 figure_manager::set_name (ov.string_value ()); |
b6261d776a82
handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9991
diff
changeset
|
985 break; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
986 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
987 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
7965
diff
changeset
|
988 } |
7869 | 989 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
990 |
8077 | 991 void redraw_figure (const graphics_object& go) const |
7869 | 992 { |
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
|
993 figure_manager::mark_modified (go.get_handle ()); |
9652
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
994 |
ecdb275bd41b
make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents:
9640
diff
changeset
|
995 __fltk_redraw__ (); |
7869 | 996 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
997 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
998 void print_figure (const graphics_object& go, |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
999 const std::string& term, |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
1000 const std::string& file, bool mono, |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
1001 const std::string& debug_file) const |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
1002 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
1003 figure_manager::print (go.get_handle (), file); |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9758
diff
changeset
|
1004 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1005 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1006 Matrix get_canvas_size (const graphics_handle& fh) const |
7869 | 1007 { |
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
|
1008 return figure_manager::get_size (fh); |
7869 | 1009 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1010 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1011 double get_screen_resolution (void) const |
7869 | 1012 { |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1013 // FLTK doesn't give this info. |
7869 | 1014 return 72.0; |
1015 } | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1016 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1017 Matrix get_screen_size (void) const |
7869 | 1018 { |
1019 Matrix sz (1, 2, 0.0); | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1020 sz(0) = Fl::w (); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1021 sz(1) = Fl::h (); |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1022 return sz; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1023 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1024 }; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1025 |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1026 DEFUN_DLD (__fltk_redraw__, , , "") |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1027 { |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1028 __fltk_redraw__ (); |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1029 |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1030 return octave_value (); |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1031 } |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1032 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1033 // Initialize the fltk backend. |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1034 |
7869 | 1035 DEFUN_DLD (__init_fltk__, , , "") |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1036 { |
9991
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1037 static bool remove_fltk_registered = false; |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1038 |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1039 if (! backend_registered) |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1040 { |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1041 mlock (); |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1042 |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1043 graphics_backend::register_backend (new fltk_backend); |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1044 backend_registered = true; |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1045 |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1046 octave_value_list args; |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1047 args(0) = "__fltk_redraw__"; |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1048 feval ("add_input_event_hook", args, 0); |
9991
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1049 |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1050 if (! remove_fltk_registered) |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1051 { |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1052 octave_add_atexit_function ("__remove_fltk__"); |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1053 |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1054 remove_fltk_registered = true; |
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1055 } |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1056 } |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1057 |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1058 octave_value retval; |
7869 | 1059 return retval; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1060 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1061 |
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
|
1062 |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1063 // Delete the fltk backend. |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1064 |
7869 | 1065 DEFUN_DLD (__remove_fltk__, , , "") |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1066 { |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1067 if (backend_registered) |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1068 { |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1069 munlock ("__init_fltk__"); |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1070 |
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
|
1071 figure_manager::close_all (); |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1072 graphics_backend::unregister_backend (FLTK_BACKEND_NAME); |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1073 backend_registered = false; |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1074 |
9216
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1075 octave_value_list args; |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1076 args(0) = "__fltk_redraw__"; |
9d4b84b14bf0
call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents:
9060
diff
changeset
|
1077 feval ("remove_input_event_hook", args, 0); |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1078 |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1079 // FIXME ??? |
9991
1300d9ced492
F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents:
9974
diff
changeset
|
1080 Fl::wait (fltk_maxtime); |
8060
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1081 } |
09f32aac8fbc
Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1082 |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1083 octave_value retval; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1084 return retval; |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1085 } |
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1086 |
7869 | 1087 DEFUN_DLD (__fltk_maxtime__, args, ,"") |
7839
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1088 { |
7869 | 1089 octave_value retval = fltk_maxtime; |
7839
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1090 |
7869 | 1091 if (args.length () == 1) |
7839
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1092 { |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1093 if (args(0).is_real_scalar ()) |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1094 fltk_maxtime = args(0).double_value (); |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1095 else |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1096 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
|
1097 } |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1098 |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1099 return retval; |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1100 } |
71eb1793f0db
fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1101 |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1102 DEFUN_DLD (fltk_mouse_wheel_zoom, args, , |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1103 "-*- texinfo -*-\n\ |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1104 @deftypefn {Built-in Function} {} fltk_mouse_wheel_zoom ([@var{speed}])\n\ |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9668
diff
changeset
|
1105 Returns the current mouse wheel zoom factor in the fltk backend. If\n\ |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1106 the @var{speed} argument is given, set the mouse zoom factor to this\n\ |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1107 value.\n\ |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1108 @end deftypefn") |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1109 { |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1110 octave_value retval = wheel_zoom_speed; |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1111 |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1112 if (args.length () == 1) |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1113 { |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1114 if (args(0).is_real_scalar ()) |
9951
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1115 wheel_zoom_speed = args(0).double_value (); |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1116 else |
d64d15e12e6b
print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9802
diff
changeset
|
1117 error ("argument must be a real scalar"); |
9668
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1118 } |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1119 |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1120 return retval; |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1121 } |
6291b69cf2d2
imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9652
diff
changeset
|
1122 |
7954 | 1123 #endif |
1124 | |
7874
e3a502930e2a
eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents:
7869
diff
changeset
|
1125 /* |
e3a502930e2a
eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents:
7869
diff
changeset
|
1126 ;;; Local Variables: *** |
e3a502930e2a
eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents:
7869
diff
changeset
|
1127 ;;; mode: C++ *** |
e3a502930e2a
eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents:
7869
diff
changeset
|
1128 ;;; End: *** |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff
changeset
|
1129 */ |