37#if defined (HAVE_CONFIG_H)
45#if defined (HAVE_X_WINDOWS)
58# define WIN32_LEAN_AND_MEAN
61#if defined (HAVE_FLTK)
63# include <FL/Fl_Box.H>
64# include <FL/Fl_Button.H>
65# include <FL/Fl_Choice.H>
66# include <FL/Fl_File_Chooser.H>
67# include <FL/Fl_Gl_Window.H>
69# include <FL/Fl_Menu_Bar.H>
70# include <FL/Fl_Menu_Button.H>
71# include <FL/Fl_Output.H>
72# include <FL/Fl_Window.H>
73# include <FL/fl_ask.H>
74# include <FL/fl_draw.H>
92#include "builtin-defun-decls.h"
109#if defined (HAVE_FLTK)
111#define FLTK_GRAPHICS_TOOLKIT_NAME "fltk"
113const char *help_text =
"\
123right drag - rectangle zoom\n\
124left double click - autoscale\n\
127#if ! defined (HAVE_OPENGL)
129OCTAVE_NORETURN
static void
130error_unexpected (
const char *name)
132 error (
"unexpected call to %s when HAVE_OPENGL is not defined - please report this bug", name);
137class OpenGL_fltk :
public Fl_Gl_Window
141 OpenGL_fltk (
int xx,
int yy,
int ww,
int hh,
double num)
142 : Fl_Gl_Window (xx, yy, ww, hh, nullptr), m_number (num),
143 m_glfcns (), m_renderer (m_glfcns), m_in_zoom (false), m_zoom_box ()
145#if defined (HAVE_OPENGL)
148 mode (FL_DEPTH | FL_DOUBLE | FL_MULTISAMPLE);
157 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (OpenGL_fltk)
159 ~OpenGL_fltk () =
default;
168 bool zoom () {
return m_in_zoom; }
169 void set_zoom_box (
const Matrix& zb) { m_zoom_box = zb; }
171 void print (
const std::string& cmd,
const std::string& term)
173 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
175 octave::gl2ps_print (m_glfcns, gh_mgr.
get_object (m_number), cmd, term);
180 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
182 m_renderer.draw (gh_mgr.
get_object (m_number));
184 return m_renderer.get_pixels (w (), h ());
187 void resize (
int xx,
int yy,
int ww,
int hh)
189#if defined (HAVE_OPENGL)
191 Fl_Gl_Window::resize (xx, yy, ww, hh);
195 octave_unused_parameter (xx);
196 octave_unused_parameter (yy);
197 octave_unused_parameter (ww);
198 octave_unused_parameter (hh);
200 error_unexpected (
"OpenGL_fltk::resize");
205 bool renumber (
double new_number)
209 if (m_number != new_number)
211 m_number = new_number;
222 octave::opengl_functions m_glfcns;
223 octave::opengl_renderer m_renderer;
232#if defined (HAVE_OPENGL)
236 m_glfcns.glMatrixMode (GL_PROJECTION);
237 m_glfcns.glLoadIdentity ();
238 m_glfcns.glViewport (0, 0, w (), h ());
241 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
243 m_renderer.draw (gh_mgr.
get_object (m_number));
253 error_unexpected (
"OpenGL_fltk::draw");
260 Matrix overlaycolor (3, 1);
261 overlaycolor(0) = 0.45;
262 overlaycolor(1) = 0.62;
263 overlaycolor(2) = 0.81;
264 double overlayalpha = 0.1;
265 Matrix bordercolor = overlaycolor;
266 double borderalpha = 0.9;
267 double borderwidth = 1.5;
269 m_renderer.draw_zoom_box (w (), h (),
270 m_zoom_box(0), m_zoom_box(1),
271 m_zoom_box(2), m_zoom_box(3),
272 overlaycolor, overlayalpha,
273 bordercolor, borderalpha, borderwidth);
276 int handle (
int event)
278#if defined (HAVE_OPENGL)
283 cursor (FL_CURSOR_CROSS);
287 cursor (FL_CURSOR_DEFAULT);
291 return Fl_Gl_Window::handle (event);
295 octave_unused_parameter (event);
297 error_unexpected (
"OpenGL_fltk::handle");
304script_cb (Fl_Widget *,
void *data)
306 static_cast<uimenu::properties *
> (data)->execute_menuselectedfcn ();
313 fltk_uimenu (
int xx,
int yy,
int ww,
int hh)
314 : m_menubar (new Fl_Menu_Bar (xx, yy, ww, hh))
317 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (fltk_uimenu)
319 ~fltk_uimenu () =
default;
324 int len = m_menubar->size ();
326 for (
int t = 0; t <
len; t++)
328 const Fl_Menu_Item *m
329 =
static_cast<const Fl_Menu_Item *
> (&(m_menubar->menu ()[t]));
331 if (m->label () && m->visible ())
341 m_menubar->redraw ();
347 m_menubar->redraw ();
352 return m_menubar->visible ();
355 int find_index_by_name (
const std::string& findname)
363 std::string menupath;
364 for (
int t = 0; t < m_menubar->size (); t++)
366 Fl_Menu_Item *m =
const_cast<Fl_Menu_Item *
> (&(m_menubar->menu ()[t]));
370 if (! menupath.empty ())
372 menupath += m->label ();
374 if (menupath == findname)
382 std::size_t idx = menupath.find_last_of (
'/');
383 if (idx != std::string::npos)
384 menupath.erase (idx);
390 std::string itempath = menupath;
391 if (! itempath.empty ())
393 itempath += m->label ();
395 if (itempath == findname)
402 Matrix find_uimenu_children (uimenu::properties& uimenup)
const
404 Matrix uimenu_childs = uimenup.get_all_children ();
405 Matrix retval = do_find_uimenu_children (uimenu_childs);
409 Matrix find_uimenu_children (figure::properties& figp)
const
411 Matrix uimenu_childs = figp.get_all_children ();
412 Matrix retval = do_find_uimenu_children (uimenu_childs);
416 Matrix do_find_uimenu_children (
Matrix uimenu_childs)
const
424 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
426 graphics_object kidgo = gh_mgr.
get_object (uimenu_childs (ii));
428 if (kidgo.valid_object () && kidgo.isa (
"uimenu"))
430 uimenu_childs(k) = uimenu_childs(ii);
431 pos(k++) =
dynamic_cast<uimenu::properties&
> (kidgo.get_properties ()).get_position ();
435 uimenu_childs.
resize (k, 1);
442 retval(ii) = uimenu_childs (sidx(ii));
447 void delete_entry (uimenu::properties& uimenup)
449 std::string fltk_label = uimenup.get___fltk_label__ ();
450 int idx = find_index_by_name (fltk_label.c_str ());
453 m_menubar->remove (idx);
456 void update_accelerator (uimenu::properties& uimenup)
458 std::string fltk_label = uimenup.get___fltk_label__ ();
459 if (! fltk_label.empty ())
461 Fl_Menu_Item *item =
const_cast<Fl_Menu_Item *
> (m_menubar->find_item (fltk_label.c_str ()));
465 std::string acc = uimenup.get_accelerator ();
466 if (acc.length () > 0)
468 int key = FL_CTRL + acc[0];
469 item->shortcut (key);
475 void update_menuselectedfcn (uimenu::properties& uimenup)
477 std::string fltk_label = uimenup.get___fltk_label__ ();
478 if (! fltk_label.empty ())
481 =
const_cast<Fl_Menu_Item *
> (m_menubar->find_item (fltk_label.c_str ()));
484 if (! uimenup.get_menuselectedfcn ().isempty ())
485 item->callback (
static_cast<Fl_Callback *
> (script_cb),
486 static_cast<void *
> (&uimenup));
488 item->callback (
nullptr,
static_cast<void *
> (
nullptr));
493 void update_enable (uimenu::properties& uimenup)
495 std::string fltk_label = uimenup.get___fltk_label__ ();
496 if (! fltk_label.empty ())
499 =
const_cast<Fl_Menu_Item *
> (m_menubar->find_item (fltk_label.c_str ()));
502 if (uimenup.is_enable ())
510 void update_foregroundcolor (uimenu::properties& uimenup)
512 std::string fltk_label = uimenup.get___fltk_label__ ();
513 if (! fltk_label.empty ())
516 =
const_cast<Fl_Menu_Item *
> (m_menubar->find_item (fltk_label.c_str ()));
519 Matrix rgb = uimenup.get_foregroundcolor_rgb ();
521 uchar r =
static_cast<uchar
> (std::floor (rgb (0) * 255));
522 uchar g =
static_cast<uchar
> (std::floor (rgb (1) * 255));
523 uchar b =
static_cast<uchar
> (std::floor (rgb (2) * 255));
525 item->labelcolor (fl_rgb_color (r, g, b));
530 void update_seperator (
const uimenu::properties& uimenup)
535 std::string fltk_label = uimenup.get___fltk_label__ ();
536 if (! fltk_label.empty ())
538 int itemflags = 0, idx;
539 int curr_idx = find_index_by_name (fltk_label.c_str ());
541 for (idx = curr_idx - 1; idx >= 0; idx--)
544 =
const_cast<Fl_Menu_Item *
> (&m_menubar->menu () [idx]);
545 itemflags = item->flags;
550 if (idx >= 0 && idx < m_menubar->size ())
552 if (uimenup.is_separator ())
554 if (! (itemflags & FL_SUBMENU))
555 m_menubar->mode (idx, itemflags | FL_MENU_DIVIDER);
558 m_menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER));
563 void update_visible (uimenu::properties& uimenup)
565 std::string fltk_label = uimenup.get___fltk_label__ ();
566 if (! fltk_label.empty ())
569 =
const_cast<Fl_Menu_Item *
> (m_menubar->find_item (fltk_label.c_str ()));
572 if (uimenup.is_visible ())
580 void update_position (uimenu::properties& uimenup,
int pos)
582 uimenup.get_property (
"position").set (
octave_value (
static_cast<double> (pos)),
586 void add_entry (uimenu::properties& uimenup)
589 std::string fltk_label = uimenup.get___fltk_label__ ();
591 if (! fltk_label.empty ())
593 bool item_added =
false;
596 const Fl_Menu_Item *item
597 = m_menubar->find_item (fltk_label.c_str ());
602 std::size_t idx1 = fltk_label.find_last_of (
'(');
603 std::size_t idx2 = fltk_label.find_last_of (
')');
604 int len = idx2 - idx1;
608 std::string valstr = fltk_label.substr (idx1 + 1,
len - 1);
609 fltk_label.erase (idx1,
len + 1);
618 val = std::stoi (valstr);
620 if (val > 0 && val < 99)
623 catch (
const std::invalid_argument&) { }
624 catch (
const std::out_of_range&) { }
626 std::ostringstream valstream;
628 fltk_label +=
'(' + valstream.str () +
')';
632 Matrix uimenu_ch = find_uimenu_children (uimenup);
637 if (
len == 0 && uimenup.is_checked ())
638 flags += FL_MENU_TOGGLE + FL_MENU_VALUE;
639 m_menubar->add (fltk_label.c_str (),
640 0,
nullptr,
nullptr, flags);
644 while (! item_added);
645 uimenup.set___fltk_label__ (fltk_label);
649 void add_to_menu (uimenu::properties& uimenup)
651 std::vector<int> delayed_menus;
652 Matrix kids = find_uimenu_children (uimenup);
654 std::string fltk_label = uimenup.get___fltk_label__ ();
658 update_foregroundcolor (uimenup);
659 update_menuselectedfcn (uimenup);
660 update_accelerator (uimenup);
661 update_enable (uimenup);
662 update_visible (uimenup);
663 update_seperator (uimenup);
665 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
669 graphics_object kgo = gh_mgr.
get_object (kids (
len - (ii + 1)));
671 if (kgo.valid_object ())
673 uimenu::properties& kprop
674 =
dynamic_cast<uimenu::properties&
> (kgo.get_properties ());
677 int pos = kprop.get_position ();
679 delayed_menus.push_back ((
len - (ii + 1)));
688 for (std::size_t ii = 0; ii < delayed_menus.size (); ii++)
690 graphics_object kgo = gh_mgr.
get_object (kids (delayed_menus[ii]));
692 if (kgo.valid_object ())
694 uimenu::properties& kprop
695 =
dynamic_cast<uimenu::properties&
> (kgo.get_properties ());
697 update_position (kprop, ++count);
702 void add_to_menu (figure::properties& figp)
704 std::vector<int> delayed_menus;
705 Matrix kids = find_uimenu_children (figp);
711 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
715 graphics_object kgo = gh_mgr.
get_object (kids (
len - (ii + 1)));
717 if (kgo.valid_object ())
719 uimenu::properties& kprop
720 =
dynamic_cast<uimenu::properties&
> (kgo.get_properties ());
723 int pos = kprop.get_position ();
725 delayed_menus.push_back ((
len - (ii + 1)));
729 update_position (kprop, ++count);
735 for (std::size_t ii = 0; ii < delayed_menus.size (); ii++)
737 graphics_object kgo = gh_mgr.
get_object (kids (delayed_menus[ii]));
739 if (kgo.valid_object ())
741 uimenu::properties& kprop
742 =
dynamic_cast<uimenu::properties&
> (kgo.get_properties ());
744 update_position (kprop, ++count);
749 template <
typename T_prop>
750 void remove_from_menu (T_prop& prop)
753 std::string type = prop.get_type ();
754 kids = find_uimenu_children (prop);
757 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
761 graphics_object kgo = gh_mgr.
get_object (kids (
len - (ii + 1)));
763 if (kgo.valid_object ())
765 uimenu::properties& kprop
766 =
dynamic_cast<uimenu::properties&
> (kgo.get_properties ());
767 remove_from_menu (kprop);
771 if (type ==
"uimenu")
772 delete_entry (
dynamic_cast<uimenu::properties&
> (prop));
773 else if (type ==
"figure")
779 Fl_Menu_Bar *m_menubar;
782#if defined (HAVE_X_WINDOWS)
784xerror_handler (Display *, XErrorEvent *)
790class plot_window :
public Fl_Window
792 friend class fltk_uimenu;
796 plot_window (
int xx,
int yy,
int ww,
int hh, figure::properties& xfp,
798 : Fl_Window (xx, yy, ww, hh + MENU_H + STATUS_H + 2,
"octave"),
799 m_window_label (), m_fp (xfp), m_uimenu (nullptr), m_canvas (nullptr),
800 m_autoscale (nullptr), m_togglegrid (nullptr), m_panzoom (nullptr),
801 m_rotate (nullptr), m_help (nullptr), m_status (nullptr),
802 m_resize_dummy (nullptr), m_ax_obj (), m_pos_x (0), m_pos_y (0)
804 callback (window_close,
static_cast<void *
> (
this));
808 m_resize_dummy =
new Fl_Box (5 * STATUS_H, MENU_H,
809 ww - 5 * STATUS_H, hh);
813 resizable (m_resize_dummy);
823 m_uimenu =
new fltk_uimenu (0, 0, ww, MENU_H);
824 m_canvas =
new OpenGL_fltk (0, MENU_H, ww, hh, number ());
830 int toolbar_y = MENU_H + hh + 1;
831 m_status =
new Fl_Output (5 * STATUS_H, toolbar_y,
832 ww - 5 * STATUS_H, STATUS_H,
"");
834 m_status->textcolor (FL_BLACK);
835 m_status->color (FL_GRAY);
836 m_status->textfont (FL_COURIER);
837 m_status->textsize (10);
838 m_status->box (FL_ENGRAVED_BOX);
840 m_autoscale =
new Fl_Button (0, toolbar_y, STATUS_H, STATUS_H,
"A");
841 m_autoscale->callback (button_callback,
static_cast<void *
> (
this));
842 m_autoscale->tooltip (
"Autoscale");
844 m_togglegrid =
new Fl_Button (STATUS_H, toolbar_y, STATUS_H, STATUS_H,
"G");
845 m_togglegrid->callback (button_callback,
static_cast<void *
> (
this));
846 m_togglegrid->tooltip (
"Toggle Grid");
848 m_panzoom =
new Fl_Button (2* STATUS_H, toolbar_y, STATUS_H, STATUS_H,
"P");
849 m_panzoom->callback (button_callback,
static_cast<void *
> (
this));
850 m_panzoom->tooltip (
"Mouse Pan/Zoom");
852 m_rotate =
new Fl_Button (3 * STATUS_H, toolbar_y, STATUS_H, STATUS_H,
"R");
853 m_rotate->callback (button_callback,
static_cast<void *
> (
this));
854 m_rotate->tooltip (
"Mouse Rotate");
856 m_help =
new Fl_Button (4 * STATUS_H, toolbar_y, STATUS_H, STATUS_H,
"?");
857 m_help->callback (button_callback,
static_cast<void *
> (
this));
858 m_help->tooltip (
"Help");
863 m_uimenu->add_to_menu (m_fp);
864 if (m_fp.menubar_is (
"none") || ! m_uimenu->items_to_show ())
867 update_boundingbox (internal);
869 if (m_fp.is_visible ())
881#if defined (HAVE_X_WINDOWS)
882 std::string show_gui_msgs
883 = octave::sys::env::getenv (
"OCTAVE_SHOW_GUI_MESSAGES");
886 if (show_gui_msgs.empty ())
887 XSetErrorHandler (xerror_handler);
890 if (m_fp.get_currentaxes ().ok ())
897 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (plot_window)
909 double number () {
return m_fp.get___myhandle__ ().value (); }
911 void renumber (
double new_number)
914 error (
"unable to renumber figure");
916 if (m_canvas->renumber (new_number))
920 void print (
const std::string& cmd,
const std::string& term)
922 m_canvas->print (cmd, term);
927 return m_canvas->get_pixels ();
933 update_toolbar_position ();
939 update_toolbar_position ();
944 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
946 graphics_object uimenu_obj = gh_mgr.
get_object (gh);
948 if (uimenu_obj.valid_object () && uimenu_obj.isa (
"uimenu"))
950 uimenu::properties& uimenup
951 =
dynamic_cast<uimenu::properties&
> (uimenu_obj.get_properties ());
952 std::string fltk_label = uimenup.get___fltk_label__ ();
953 graphics_object fig = uimenu_obj.get_ancestor (
"figure");
954 figure::properties& figp
955 =
dynamic_cast<figure::properties&
> (fig.get_properties ());
959 case base_properties::ID_BEINGDELETED:
960 m_uimenu->remove_from_menu (uimenup);
963 case base_properties::ID_VISIBLE:
964 m_uimenu->update_visible (uimenup);
967 case uimenu::properties::ID_ACCELERATOR:
968 m_uimenu->update_accelerator (uimenup);
971 case uimenu::properties::ID_MENUSELECTEDFCN:
972 m_uimenu->update_menuselectedfcn (uimenup);
975 case uimenu::properties::ID_CHECKED:
976 m_uimenu->add_to_menu (figp);
979 case uimenu::properties::ID_ENABLE:
980 m_uimenu->update_enable (uimenup);
983 case uimenu::properties::ID_FOREGROUNDCOLOR:
984 m_uimenu->update_foregroundcolor (uimenup);
987 case uimenu::properties::ID_LABEL:
988 m_uimenu->add_to_menu (figp);
991 case uimenu::properties::ID_POSITION:
992 m_uimenu->add_to_menu (figp);
995 case uimenu::properties::ID_SEPARATOR:
996 m_uimenu->update_seperator (uimenup);
1000 if (m_uimenu->items_to_show ())
1009 if (! m_canvas->can_do ())
1010 error (
"unable to plot due to insufficient OpenGL support");
1011 else if (m_fp.is_visible ())
1014 m_canvas->make_current ();
1027 void update_toolbar_position ()
1029 int old_canvas_h = m_canvas->h ();
1032 update_boundingbox (
true);
1033 m_canvas->resize (0, menu_dy (), w (), old_canvas_h);
1035 int toolbar_y = m_canvas->h () + menu_dy () + 1;
1036 m_autoscale->position (0, toolbar_y);
1037 m_togglegrid->position (STATUS_H, toolbar_y);
1038 m_panzoom->position (2 * STATUS_H, toolbar_y);
1039 m_rotate->position (3 * STATUS_H, toolbar_y);
1040 m_help->position (4 * STATUS_H, toolbar_y);
1041 m_status->resize (5 * STATUS_H, toolbar_y,
1042 w () - 5 * STATUS_H, STATUS_H);
1050 pos(1) += menu_dy ();
1051 pos(3) -= menu_dy () + STATUS_H + 2;
1058 outerpos(1) -= menu_dy ();
1059 outerpos(3) += menu_dy () + STATUS_H + 2;
1068 void update_boundingbox (
bool internal)
1070 Matrix bb = m_fp.get_boundingbox (internal);
1072 bb = position2outerposition (bb);
1073 resize (bb(0), bb(1), bb(2), bb(3));
1076 void mark_modified ()
1078 m_canvas->redraw ();
1083 m_window_label = m_fp.get_title ();
1084 label (m_window_label.c_str ());
1091 std::string m_window_label;
1094 figure::properties& m_fp;
1097 static const int STATUS_H = 20;
1100 static const int MENU_H = 25;
1102 fltk_uimenu *m_uimenu;
1104 OpenGL_fltk *m_canvas;
1106 Fl_Button *m_autoscale;
1107 Fl_Button *m_togglegrid;
1108 Fl_Button *m_panzoom;
1109 Fl_Button *m_rotate;
1111 Fl_Output *m_status;
1113 Fl_Box *m_resize_dummy;
1115 graphics_object m_ax_obj;
1121 static void window_close (Fl_Widget *,
void *data)
1126 args(0) =
static_cast<plot_window *
> (data)->number ();
1128 interp.
feval (
"close", args);
1132 static void button_callback (Fl_Widget *ww,
void *data)
1134 static_cast<plot_window *
> (data)->button_press (ww, data);
1137 void button_press (Fl_Widget *widg,
void *)
1139 if (widg == m_autoscale)
1141 else if (widg == m_togglegrid)
1143 else if (widg == m_panzoom)
1144 m_fp.set___mouse_mode__ (
"pan");
1145 else if (widg == m_rotate)
1146 m_fp.set___mouse_mode__ (
"rotate");
1147 else if (widg == m_help)
1148 fl_message (
"%s", help_text);
1151 void set_on_ax_obj (
const std::string& name,
const std::string& value)
1154 if (m_ax_obj && m_ax_obj.isa (
"axes")
1155 && m_ax_obj.get_properties ().get_tag () !=
"legend"
1156 && m_ax_obj.get_properties ().get_tag () !=
"colorbar")
1158 axes::properties& ap
1159 =
dynamic_cast<axes::properties&
> (m_ax_obj.get_properties ());
1160 ap.set (name, value);
1167 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1171 axes::properties& ap
1172 =
dynamic_cast<axes::properties&
> (go.get_properties ());
1174 ap.set (name, value);
1182 if (m_fp.get_currentaxes ().ok ())
1186 args(0) = m_fp.get_currentaxes ().as_octave_value ();
1189 interp.
feval (
"axis", args);
1200 if (m_fp.get_currentaxes ().ok ())
1201 args(0) = m_fp.get_currentaxes ().as_octave_value ();
1203 interp.
feval (
"grid", args);
1208 void pixel2pos (
const graphics_handle& ax,
int px,
int py,
double& xx,
1211 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1213 pixel2pos (gh_mgr.
get_object (ax), px, py, xx, yy);
1216 void pixel2pos (graphics_object ax,
int px,
int py,
double& xx,
1219 if (ax && ax.isa (
"axes"))
1221 axes::properties& ap
1222 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
1231 Matrix kids = m_fp.get_children ();
1234 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1236 for (
int k = 0; k <
len; k++)
1242 graphics_object kid = gh_mgr.
get_object (hnd);
1244 if (kid.valid_object () && kid.isa (
"axes"))
1246 Matrix bb = kid.get_properties ().get_boundingbox (
false);
1248 if (bb(0) <= px && px < (bb(0)+bb(2))
1249 && bb(1) <= py && py < (bb(1)+bb(3)))
1256 return m_fp.get_currentaxes ();
1260 int px1 = -1,
int py1 = -1)
1262 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1264 pixel2status (gh_mgr.
get_object (ax), px0, py0, px1, py1);
1267 void pixel2status (graphics_object ax,
int px0,
int py0,
1268 int px1 = -1,
int py1 = -1)
1270 double x0, y0, x1, y1;
1271 x0 = y0 = x1 = y1 = octave::numeric_limits<double>::NaN ();
1272 std::stringstream cbuf;
1275 pixel2pos (ax, px0, py0, x0, y0);
1276 cbuf <<
'[' << x0 <<
", " << y0 <<
']';
1279 pixel2pos (ax, px1, py1, x1, y1);
1280 cbuf <<
" -> ["<< x1 <<
", " << y1 <<
']';
1283 m_status->value (cbuf.str ().c_str ());
1286 void view2status (graphics_object ax)
1288 if (ax && ax.isa (
"axes"))
1290 axes::properties& ap
1291 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
1292 std::stringstream cbuf;
1296 v = ap.get (
"view").matrix_value ();
1297 cbuf <<
"[azimuth: " << v(0) <<
", elevation: " << v(1) <<
']';
1299 m_status->value (cbuf.str ().c_str ());
1303 void set_currentpoint (
int px,
int py)
1305 if (! m_fp.is_beingdeleted ())
1307 Matrix pos = m_fp.map_from_boundingbox (px, py);
1308 m_fp.set_currentpoint (pos);
1310 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1312 graphics_object robj = gh_mgr.
get_object (m_fp.get_parent ());
1314 root_figure::properties& rp
1315 =
dynamic_cast<root_figure::properties&
> (robj.get_properties ());
1317 rp.set_currentfigure (m_fp.get___myhandle__ ().value ());
1321 void set_axes_currentpoint (graphics_object ax,
int px,
int py)
1323 if (ax.valid_object () && ax.isa (
"axes"))
1325 axes::properties& ap
1326 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
1328 Matrix x_zlim = ap.get_transform_zlim ();
1332 ColumnVector tmp = ap.get_transform ().untransform (px, py, x_zlim(0));
1338 tmp = ap.get_transform ().untransform (px, py, x_zlim(1));
1343 ap.set_currentpoint (pos);
1344 if (ap.get_tag () !=
"legend" && ap.get_tag () !=
"colorbar")
1345 m_fp.set_currentaxes (ap.get___myhandle__ ().value ());
1351 if (m_uimenu->is_visible ())
1365 std::string key_str;
1366 std::ostringstream tmp_str;
1368 if (e_key == FL_Escape)
1370 else if (e_key == FL_Tab)
1372 else if (e_key == FL_Caps_Lock)
1373 key_str =
"capslock";
1374 else if (e_key == FL_Shift_L || e_key == FL_Shift_R)
1376 else if (e_key == FL_Control_L || e_key == FL_Control_R)
1377 key_str =
"control";
1378 else if (e_key == FL_Meta_L || e_key == FL_Meta_R)
1379 key_str =
"windows";
1380 else if (e_key == FL_Alt_L || e_key == FL_Alt_R)
1382 else if (e_key == 32)
1384 else if (e_key == FL_Enter)
1386 else if (e_key == FL_BackSpace)
1387 key_str =
"backspace";
1388 else if (e_key == FL_Print)
1389 key_str =
"printscreen";
1390 else if (e_key == FL_Pause)
1392 else if (e_key == FL_Home)
1394 else if (e_key == FL_End)
1396 else if (e_key == FL_Insert)
1398 else if (e_key == FL_Page_Up)
1400 else if (e_key == FL_Delete)
1402 else if (e_key == FL_Page_Down)
1403 key_str =
"pagedown";
1404 else if (e_key == FL_Left)
1405 key_str =
"leftarrow";
1406 else if (e_key == FL_Up)
1407 key_str =
"uparrow";
1408 else if (e_key == FL_Right)
1409 key_str =
"rightarrow";
1410 else if (e_key == FL_Down)
1411 key_str =
"downarrow";
1412 else if (e_key == FL_Num_Lock)
1413 key_str =
"numlock";
1414 else if (e_key == 0xffaf)
1416 else if (e_key == 0xffaa)
1417 key_str =
"multiply";
1418 else if (e_key == 0xffad)
1419 key_str =
"subtract";
1420 else if (e_key == 0xffab)
1422 else if (e_key == 0xff8d)
1424 else if (e_key == 0xffac)
1425 key_str =
"separator";
1426 else if (e_key >= 0xffb0 && e_key <= 0xffb9)
1428 tmp_str <<
"numpad" << (e_key - 0xffb0);
1429 key_str = tmp_str.str ();
1431 else if (e_key >= (FL_F + 1) && e_key <= (FL_F + 12))
1433 tmp_str <<
'f' << (e_key - FL_F);
1434 key_str = tmp_str.str ();
1436 else if (e_key ==
',')
1438 else if (e_key ==
'.')
1440 else if (e_key ==
'-')
1442 else if (e_key ==
'^' || e_key ==
'+' || e_key ==
'#'
1443 || e_key ==
'<' || e_key == 0xfe03 )
1445 else if (isalnum (e_key))
1446 key_str = std::tolower (e_key);
1447 else if (isprint (e_text[0]))
1454 Cell modifier2cell (
int e_state)
1458 if (e_state & FL_SHIFT)
1460 if (e_state & FL_CTRL)
1462 if (e_state & FL_ALT)
1464 if (e_state & FL_COMMAND)
1469 void resize (
int xx,
int yy,
int ww,
int hh)
1471 Fl_Window::resize (xx, yy, ww, hh);
1480 m_fp.set_boundingbox (bb,
false,
false);
1483 m_fp.set_boundingbox (outerposition2position (bb),
true,
false);
1496 std::string pan_mode ()
1506 bool rotate_enabled ()
1516 int handle (
int event)
1518 if (event == FL_FOCUS)
1523 if (! m_fp.is_beingdeleted ())
1528 static bool key_resent_detected =
false;
1530 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1537 static int last_event_key = 0;
1538 static char last_event_text = 0;
1540 int e_key = Fl::event_key ();
1541 char e_text = Fl::event_text ()[0];
1542 key_resent_detected = (e_key == last_event_key
1543 && std::tolower (last_event_text) == std::tolower (e_text)
1544 && ((islower (last_event_text) && isupper (e_text))
1545 || (isupper (last_event_text) && islower (e_text))));
1547 last_event_key = e_key;
1548 last_event_text = e_text;
1554 int e_key = Fl::event_key ();
1555 const char *e_text = Fl::event_text ();
1556 int e_state = Fl::event_state ();
1559 m_fp.set_currentcharacter (std::string (e_text));
1561 if (! m_fp.get_keypressfcn ().isempty ()
1565 if (Fl::event_inside (m_canvas))
1567 m_pos_x = Fl::event_x ();
1568 m_pos_y = Fl::event_y () - menu_dy ();
1570 set_currentpoint (m_pos_x, m_pos_y);
1572 gh = pixel2axes_or_ca (m_pos_x, m_pos_y);
1577 set_axes_currentpoint (m_ax_obj, m_pos_x, m_pos_y);
1581 m_fp.execute_keypressfcn (evt);
1599 m_fp.set___mouse_mode__ (
"pan");
1604 m_fp.set___mouse_mode__ (
"rotate");
1612 int e_key = Fl::event_key ();
1613 int e_state = Fl::event_state ();
1615 if (key_resent_detected && Fl::event_length () == 1)
1620 tmp_e_text[0] = Fl::event_text ()[0];
1623 if (std::islower (tmp_e_text[0]))
1624 tmp_e_text[0] = std::toupper (tmp_e_text[0]);
1626 tmp_e_text[0] = std::tolower (tmp_e_text[0]);
1627 evt = format_key_event (e_key, tmp_e_text, e_state);
1631 const char *e_text = Fl::event_text ();
1632 evt = format_key_event (e_key, e_text, e_state);
1635 if (! m_fp.get_keyreleasefcn ().isempty ()
1637 m_fp.execute_keyreleasefcn (evt);
1644 if (Fl::event_inside (m_canvas))
1648 pixel2status (pixel2axes_or_ca (Fl::event_x (),
1649 Fl::event_y () - menu_dy ()),
1650 Fl::event_x (), Fl::event_y () - menu_dy ());
1654 m_pos_x = Fl::event_x ();
1655 m_pos_y = Fl::event_y () - menu_dy ();
1657 set_currentpoint (m_pos_x, m_pos_y);
1659 if (Fl::event_clicks ())
1660 m_fp.set_selectiontype (
"open");
1661 else if (Fl::event_button () == FL_MIDDLE_MOUSE
1662 || (Fl::event_button () == FL_LEFT_MOUSE
1663 && Fl::event_shift ()))
1664 m_fp.set_selectiontype (
"extend");
1665 else if (Fl::event_button () == FL_RIGHT_MOUSE
1666 || (Fl::event_button () == FL_LEFT_MOUSE
1667 && Fl::event_ctrl ()))
1668 m_fp.set_selectiontype (
"alt");
1670 m_fp.set_selectiontype (
"normal");
1672 gh = pixel2axes_or_ca (m_pos_x, m_pos_y);
1677 set_axes_currentpoint (m_ax_obj, m_pos_x, m_pos_y);
1682 if (! m_fp.get_windowbuttondownfcn ().isempty ())
1683 m_fp.execute_windowbuttondownfcn (Fl::event_button ());
1687 m_fp.set_currentobject (m_ax_obj.get_handle ().value ());
1689 base_properties& props = m_ax_obj.get_properties ();
1690 if (! props.get_buttondownfcn ().isempty ())
1691 props.execute_buttondownfcn (Fl::event_button ());
1695 else if (! m_fp.get_buttondownfcn ().isempty ())
1696 m_fp.execute_buttondownfcn (Fl::event_button ());
1701 if (! m_fp.get_windowbuttonmotionfcn ().isempty ())
1703 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1704 m_fp.execute_windowbuttonmotionfcn ();
1707 if (Fl::event_button () == 1)
1709 if (m_ax_obj && m_ax_obj.isa (
"axes"))
1711 axes::properties& ap =
dynamic_cast<axes::properties&
> (m_ax_obj.get_properties ());
1714 if (ap.get_tag () !=
"legend")
1716 if (rotate_enabled ())
1717 view2status (m_ax_obj);
1719 pixel2status (m_ax_obj, m_pos_x, m_pos_y,
1721 Fl::event_y () - menu_dy ());
1723 double x0, y0, x1, y1;
1724 Matrix pos = m_fp.get_boundingbox (
true);
1725 pixel2pos (m_ax_obj, m_pos_x, m_pos_y, x0, y0);
1726 pixel2pos (m_ax_obj, Fl::event_x (),
1727 Fl::event_y () - menu_dy (),
1732 std::string mode = pan_mode ();
1734 ap.translate_view (mode, x0, x1, y0, y1);
1736 else if (rotate_enabled ())
1739 daz = (Fl::event_x () - m_pos_x) / pos(2) * 360;
1740 del = (Fl::event_y () - menu_dy () - m_pos_y)
1742 ap.rotate_view (del, daz);
1748 Matrix pos = ap.get_position ().matrix_value ();
1749 pos(0) +=
double (Fl::event_x () - m_pos_x)
1751 pos(1) -=
double (Fl::event_y () - menu_dy () - m_pos_y)
1753 ap.set_position (pos);
1756 m_pos_x = Fl::event_x ();
1757 m_pos_y = Fl::event_y () - menu_dy ();
1762 else if (Fl::event_button () == 3)
1764 pixel2status (m_ax_obj, m_pos_x, m_pos_y,
1765 Fl::event_x (), Fl::event_y () - menu_dy ());
1766 Matrix zoom_box (1, 4, 0);
1767 zoom_box(0) = m_pos_x;
1768 zoom_box(1) = m_pos_y;
1769 zoom_box(2) = Fl::event_x ();
1770 zoom_box(3) = Fl::event_y () - menu_dy ();
1771 m_canvas->set_zoom_box (zoom_box);
1772 m_canvas->zoom (
true);
1782 = gh_mgr.
get_object (pixel2axes_or_ca (Fl::event_x (),
1785 if (ax && ax.isa (
"axes"))
1787 axes::properties& ap
1788 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
1791 double wheel_zoom_speed = ap.get_mousewheelzoom ();
1794 const double factor = (Fl::event_dy () < 0
1795 ? 1 / (1.0 - wheel_zoom_speed)
1796 : 1.0 - wheel_zoom_speed);
1800 pixel2pos (ax, Fl::event_x (), Fl::event_y () - menu_dy (),
1805 ap.zoom_about_point (
"both", x1, y1, factor,
false);
1814 if (! m_fp.get_windowbuttonupfcn ().isempty ())
1816 set_currentpoint (Fl::event_x (),
1817 Fl::event_y () - menu_dy ());
1818 m_fp.execute_windowbuttonupfcn ();
1821 if ((Fl::event_button () == 1) && Fl::event_clicks ())
1824 set_on_ax_obj (
"xlimmode",
"auto");
1825 set_on_ax_obj (
"ylimmode",
"auto");
1826 set_on_ax_obj (
"zlimmode",
"auto");
1830 if (Fl::event_button () == 3)
1833 if (m_canvas->zoom ())
1835 m_canvas->zoom (
false);
1836 double x0, y0, x1, y1;
1837 if (m_ax_obj && m_ax_obj.isa (
"axes"))
1839 axes::properties& ap =
dynamic_cast<axes::properties&
>
1840 (m_ax_obj.get_properties ());
1841 pixel2pos (m_ax_obj, m_pos_x, m_pos_y, x0, y0);
1842 int pos_x1 = Fl::event_x ();
1843 int pos_y1 = Fl::event_y () - menu_dy ();
1844 pixel2pos (m_ax_obj, pos_x1, pos_y1, x1, y1);
1847 int dx =
abs (m_pos_x - pos_x1);
1848 int dy =
abs (m_pos_y - pos_y1);
1850 if ((dx > 4) && (dy > 4))
1872 ap.zoom (
"both", xl, yl);
1883 return Fl_Window::handle (event);
1891 figure_manager () =
default;
1895 OCTAVE_DISABLE_COPY_MOVE (figure_manager)
1902 static bool instance_ok ()
1907 s_instance =
new figure_manager ();
1912 static void close_all ()
1915 s_instance->do_close_all ();
1918 static void new_window (figure::properties& fp)
1921 s_instance->do_new_window (fp);
1924 static void delete_window (
int idx)
1927 s_instance->do_delete_window (idx);
1930 static void delete_window (
const std::string& idx_str)
1932 delete_window (str2idx (idx_str));
1935 static void renumber_figure (
const std::string& idx_str,
double new_number)
1938 s_instance->do_renumber_figure (str2idx (idx_str), new_number);
1941 static void toggle_window_visibility (
int idx,
bool is_visible)
1944 s_instance->do_toggle_window_visibility (idx, is_visible);
1947 static void toggle_window_visibility (
const std::string& idx_str,
1950 toggle_window_visibility (str2idx (idx_str), is_visible);
1953 static void mark_modified (
int idx)
1956 s_instance->do_mark_modified (idx);
1961 mark_modified (hnd2idx (gh));
1964 static void set_name (
int idx)
1967 s_instance->do_set_name (idx);
1970 static void set_name (
const std::string& idx_str)
1972 set_name (str2idx (idx_str));
1975 static Matrix get_size (
int idx)
1977 return instance_ok () ? s_instance->do_get_size (idx) :
Matrix ();
1982 return get_size (hnd2idx (gh));
1986 const std::string& term)
1989 s_instance->do_print (hnd2idx (gh), cmd, term);
1996 retval = s_instance->do_get_pixels (hnd2idx (gh));
2005 s_instance->do_uimenu_update (hnd2idx (figh), uimenuh,
id);
2012 s_instance->do_update_canvas (hnd2idx (gh), ca);
2015 static void update_boundingbox (
const std::string& fig_idx_str,
2019 s_instance->do_update_boundingbox (str2idx (fig_idx_str), internal);
2022 static void toggle_menubar_visibility (
const std::string& fig_idx_str,
2023 bool menubar_is_figure)
2026 s_instance->do_toggle_menubar_visibility (str2idx (fig_idx_str),
2032 static figure_manager *s_instance;
2036 static int s_curr_index;
2038 typedef std::map<int, plot_window *> window_map;
2040 typedef window_map::iterator wm_iterator;
2042 window_map m_windows;
2044 static std::string s_fltk_idx_header;
2046 void do_close_all ()
2048 for (
auto& win : m_windows)
2053 void do_new_window (figure::properties& fp)
2055 int idx = figprops2idx (fp);
2057 if (idx >= 0 && m_windows.find (idx) == m_windows.end ())
2059 Matrix pos = fp.get_outerposition ().matrix_value ();
2060 bool internal =
false;
2062 if (pos(2) != -1.0 && pos(3) != -1.0)
2064 pos = fp.get_boundingbox (internal);
2070 pos = fp.get_boundingbox (internal);
2073 idx2figprops (s_curr_index, fp);
2075 m_windows[s_curr_index++] =
new plot_window (pos(0), pos(1), pos(2), pos(3),
2080 void do_delete_window (
int idx)
2082 wm_iterator win = m_windows.find (idx);
2084 if (win != m_windows.end ())
2087 m_windows.erase (win);
2091 void do_renumber_figure (
int idx,
double new_number)
2093 wm_iterator win = m_windows.find (idx);
2095 if (win != m_windows.end ())
2096 win->second->renumber (new_number);
2099 void do_toggle_window_visibility (
int idx,
bool is_visible)
2101 wm_iterator win = m_windows.find (idx);
2103 if (win != m_windows.end ())
2107 win->second->show ();
2108 win->second->show_canvas ();
2111 win->second->hide ();
2116 void do_toggle_menubar_visibility (
int fig_idx,
bool menubar_is_figure)
2118 wm_iterator win = m_windows.find (fig_idx);
2120 if (win != m_windows.end ())
2122 if (menubar_is_figure)
2123 win->second->show_menubar ();
2125 win->second->hide_menubar ();
2127 win->second->redraw ();
2131 void do_mark_modified (
int idx)
2133 wm_iterator win = m_windows.find (idx);
2135 if (win != m_windows.end ())
2137 win->second->mark_modified ();
2141 void do_set_name (
int idx)
2143 wm_iterator win = m_windows.find (idx);
2145 if (win != m_windows.end ())
2146 win->second->set_name ();
2149 Matrix do_get_size (
int idx)
2153 wm_iterator win = m_windows.find (idx);
2155 if (win != m_windows.end ())
2157 sz(0) = win->second->w ();
2158 sz(1) = win->second->h ();
2164 void do_print (
int idx,
const std::string& cmd,
const std::string& term)
2166 wm_iterator win = m_windows.find (idx);
2168 if (win != m_windows.end ())
2169 win->second->print (cmd, term);
2175 wm_iterator win = m_windows.
find (idx);
2177 if (win != m_windows.end ())
2178 retval = win->second->get_pixels ();
2185 wm_iterator win = m_windows.
find (idx);
2187 if (win != m_windows.end ())
2188 win->second->uimenu_update (gh,
id);
2193 wm_iterator win = m_windows.
find (idx);
2195 if (win != m_windows.end ())
2198 win->second->show_canvas ();
2200 win->second->hide_canvas ();
2204 void do_update_boundingbox (
int idx,
bool internal)
2206 wm_iterator win = m_windows.
find (idx);
2208 if (win != m_windows.end ())
2209 win->second->update_boundingbox (internal);
2215 if (clstr.find (s_fltk_idx_header, 0) == 0)
2217 std::istringstream istr (clstr.substr (s_fltk_idx_header.size ()));
2222 error (
"figure_manager: could not recognize fltk index");
2225 void idx2figprops (
int idx, figure::properties& fp)
2227 std::ostringstream ind_str;
2228 ind_str << s_fltk_idx_header << idx;
2229 fp.set___plot_stream__ (ind_str.str ());
2232 static int figprops2idx (
const figure::properties& fp)
2234 if (fp.get___graphics_toolkit__ () == FLTK_GRAPHICS_TOOLKIT_NAME)
2243 error (
"figure_manager: figure is not fltk");
2246 static int hnd2idx (
double h)
2248 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2250 graphics_object fobj = gh_mgr.
get_object (h);
2252 if (fobj && fobj.isa (
"figure"))
2254 figure::properties& fp
2255 =
dynamic_cast<figure::properties&
> (fobj.get_properties ());
2256 return figprops2idx (fp);
2259 error (
"figure_manager: H (= %g) is not a figure", h);
2264 return hnd2idx (fh.
value ());
2268figure_manager *figure_manager::s_instance =
nullptr;
2270std::string figure_manager::s_fltk_idx_header=
"fltk index=";
2271int figure_manager::s_curr_index = 1;
2273static bool toolkit_loaded =
false;
2275class fltk_graphics_toolkit :
public octave::base_graphics_toolkit
2279 fltk_graphics_toolkit (octave::interpreter& interp)
2281 m_interpreter (interp), m_input_event_hook_fcn_id ()
2283 static bool warned =
false;
2288 (
"Octave:fltk-graphics",
2289 "using the fltk graphics toolkit is discouraged\n\
2291The FLTK graphics toolkit is not actively maintained and has a number\n\
2292of limitations that are unlikely to be fixed.\n\
2293The qt toolkit is recommended instead.\n");
2298 Fl::visual (FL_RGB);
2301 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (fltk_graphics_toolkit)
2303 ~fltk_graphics_toolkit () =
default;
2305 bool is_valid ()
const {
return true; }
2307 bool initialize (
const graphics_object& go)
2309 if (go.isa (
"figure")
2310 || go.isa (
"uimenu"))
2312 if (go.isa (
"uimenu"))
2313 update (go, uimenu::properties::ID_LABEL);
2321 void finalize (
const graphics_object& go)
2323 if (go.isa (
"figure"))
2332 void uimenu_set___fltk_label__ (graphics_object uimenu_obj)
2334 if (uimenu_obj.valid_object ())
2336 uimenu::properties& uimenup
2337 =
dynamic_cast<uimenu::properties&
> (uimenu_obj.get_properties ());
2338 std::string fltk_label = uimenup.get_label ();
2340 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
2342 graphics_object go = gh_mgr.
get_object (uimenu_obj.get_parent ());
2344 if (go.isa (
"uimenu"))
2345 fltk_label =
dynamic_cast<const uimenu::properties&
>
2346 (go.get_properties ()).get___fltk_label__ ()
2349 else if (go.isa (
"figure") || go.isa (
"uicontextmenu"))
2352 error (
"invalid parent object\n");
2354 uimenup.set___fltk_label__ (fltk_label);
2358 void update (
const graphics_object& go,
int id)
2360 if (go.isa (
"figure"))
2366 const figure::properties& fp
2367 =
dynamic_cast<const figure::properties&
> (go.get_properties ());
2371 case base_properties::ID_VISIBLE:
2372 figure_manager::toggle_window_visibility (ov.
string_value (),
2376 case figure::properties::ID_MENUBAR:
2377 figure_manager::toggle_menubar_visibility
2381 case figure::properties::ID_CURRENTAXES:
2382 figure_manager::update_canvas (go.get_handle (),
2383 fp.get_currentaxes ());
2386 case figure::properties::ID_NAME:
2387 case figure::properties::ID_NUMBERTITLE:
2391 case figure::properties::ID_INTEGERHANDLE:
2395 figure_manager::renumber_figure (tmp, gh.
value ());
2396 figure_manager::set_name (tmp);
2400 case figure::properties::ID_POSITION:
2401 figure_manager::update_boundingbox (ov.
string_value (),
true);
2404 case figure::properties::ID_OUTERPOSITION:
2405 figure_manager::update_boundingbox (ov.
string_value (),
false);
2410 else if (go.isa (
"uimenu"))
2412 if (
id == uimenu::properties::ID_LABEL)
2413 uimenu_set___fltk_label__ (go);
2415 graphics_object fig = go.get_ancestor (
"figure");
2416 figure_manager::uimenu_update (fig.get_handle (), go.get_handle (),
id);
2420 void redraw_figure (
const graphics_object& go)
const
2424 gh_manager& gh_mgr = m_interpreter.get_gh_manager ();
2428 if (obj && obj.isa (
"root"))
2430 base_properties& props = obj.get_properties ();
2431 Matrix children = props.get_all_children ();
2435 graphics_object fobj = gh_mgr.
get_object (children (n));
2437 if (fobj && fobj.isa (
"figure"))
2439 figure::properties& fp
2440 =
dynamic_cast<figure::properties&
> (fobj.get_properties ());
2442 if (fp.get___graphics_toolkit__ ()
2443 == FLTK_GRAPHICS_TOOLKIT_NAME)
2444 figure_manager::new_window (fp);
2449 figure_manager::mark_modified (go.get_handle ());
2453 void print_figure (
const graphics_object& go,
2454 const std::string& term,
2455 const std::string& file_cmd,
2456 const std::string& )
const
2458 figure_manager::print (go.get_handle (), file_cmd, term);
2461 uint8NDArray get_pixels (
const graphics_object& go)
const
2463 return figure_manager::get_pixels (go.get_handle ());
2468 return figure_manager::get_size (fh);
2482 Matrix get_screen_size ()
const
2494 m_interpreter.munlock (
"__init_fltk__");
2498 Fremove_input_event_hook (m_interpreter, args);
2501 figure_manager::close_all ();
2507 m_input_event_hook_fcn_id = id;
2512 octave::interpreter& m_interpreter;
2525#if defined (HAVE_FLTK)
2533 octave_unused_parameter (interp);
2547#if defined (HAVE_FLTK)
2548 octave::display_info& dpy_info = interp.get_display_info ();
2550 if (! dpy_info.display_available ())
2551 error (
"__init_fltk__: no graphics DISPLAY available");
2552 else if (! toolkit_loaded)
2556 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
2558 fltk_graphics_toolkit *fltk =
new fltk_graphics_toolkit (interp);
2559 octave::graphics_toolkit tk (fltk);
2560 gtk_mgr.load_toolkit (tk);
2561 toolkit_loaded =
true;
2567 ovl (fcn_handle), 1);
2569 fltk->set_input_event_hook_id (
id);
2575 octave_unused_parameter (interp);
2586OCTAVE_END_NAMESPACE(octave)
octave_value_list F__fltk_check__(octave::interpreter &, const octave_value_list &, int)
N Dimensional Array with copy-on-write semantics.
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
graphics_object get_object(double val) const
graphics_handle lookup(double val) const
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
const octave_value & contents(const_iterator p) const
void assign(const std::string &k, const octave_value &val)
octave_value_list & append(const octave_value &val)
octave_scalar_map scalar_map_value() const
std::string string_value(bool force=false) const
octave_idx_type length() const
string_vector & append(const std::string &s)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD_DLD(name, interp_name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin method.
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
octave_value_list Fdrawnow(octave::interpreter &interp, const octave_value_list &args, int)
interpreter & __get_interpreter__()
void draw(QDomElement &parent_elt, pdfpainter &painter)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
template int8_t abs(int8_t)