annotate src/DLD-FUNCTIONS/fltk_backend.cc @ 9758:09da0bd91412

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