GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Figure.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <QAction>
31 #include <QActionEvent>
32 #include <QApplication>
33 #include <QClipboard>
34 #include <QEvent>
35 #include <QFileDialog>
36 #include <QFileInfo>
37 #include <QFrame>
38 #include <QImage>
39 #include <QMainWindow>
40 #include <QMenu>
41 #include <QMenuBar>
42 #include <QMessageBox>
43 #include <QtDebug>
44 #include <QTimer>
45 #include <QToolBar>
46 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
47 # include <QWindow>
48 # include <QScreen>
49 #endif
50 
51 #include "Canvas.h"
52 #include "Container.h"
53 #include "Figure.h"
54 #include "FigureWindow.h"
55 #include "QtHandlesUtils.h"
56 
57 #include "gui-preferences-global.h"
58 #include "qt-interpreter-events.h"
59 
60 #include "file-ops.h"
61 #include "unwind-prot.h"
62 #include "utils.h"
63 #include "version.h"
64 
65 #include "builtin-defun-decls.h"
66 #include "interpreter.h"
67 
68 namespace QtHandles
69 {
70 
72 
73  static QRect
75  {
76  QRect r;
77 
78  if (bb.numel () == 4)
79  {
80  r = QRect (octave::math::round (bb(0)), octave::math::round (bb(1)),
81  octave::math::round (bb(2)), octave::math::round (bb(3)));
82  if (! r.isValid ())
83  r = QRect ();
84  }
85 
86  return r;
87  }
88 
89  static QImage
90  pointer_to_qimage (const Matrix& cdata)
91  {
92  QImage retval (cdata.rows (), cdata.columns (), QImage::Format_ARGB32);
93  QColor tmp ("White");
94  QColor black ("Black");
95  QColor white ("White");
96  for (octave_idx_type ii = 0; ii < cdata.rows (); ii++)
97  for (octave_idx_type jj = 0; jj < cdata.columns (); jj++)
98  {
99  if (cdata(ii,jj) == 1.0)
100  tmp = black;
101  else if (cdata(ii,jj) == 2.0)
102  tmp = white;
103  else
104  tmp.setAlpha (0);
105 
106  retval.setPixel (jj, ii, tmp.rgba ());
107  }
108 
109  return retval;
110  }
111 
112  Figure*
114  const graphics_object& go)
115  {
116  return new Figure (oct_qobj, interp, go, new FigureWindow ());
117  }
118 
120  const graphics_object& go, FigureWindow *win)
121  : Object (oct_qobj, interp, go, win), m_blockUpdates (false),
122  m_figureToolBar (nullptr), m_menuBar (nullptr), m_innerRect (),
123  m_outerRect (), m_previousHeight (0), m_resizable (true)
124  {
125  m_container = new Container (win, oct_qobj, interp);
126  win->setCentralWidget (m_container);
127 
128  connect (m_container, SIGNAL (interpeter_event (const fcn_callback&)),
129  this, SIGNAL (interpeter_event (const fcn_callback&)));
130 
131  connect (m_container, SIGNAL (interpeter_event (const meth_callback&)),
132  this, SIGNAL (interpeter_event (const meth_callback&)));
133 
134  figure::properties& fp = properties<figure> ();
135 
136  // Adjust figure position
139 
141 
142  // Menubar
143  m_menuBar = new MenuBar (win);
144  win->setMenuBar (m_menuBar);
145  m_menuBar->addReceiver (this);
146  m_menuBar->setStyleSheet (m_menuBar->styleSheet () + global_menubar_style);
147 
148 
149  // Status bar
150  m_statusBar = win->statusBar ();
151  m_statusBar->setVisible (false);
152 
153  if (fp.toolbar_is ("figure")
154  || (fp.toolbar_is ("auto") && fp.menubar_is ("figure")))
155  showFigureStatusBar (true);
156 
157  // Enable mouse tracking unconditionally
159 
160  // When this constructor gets called all properties are already
161  // set, even non default. We force "update" here to get things right.
162 
163  // Figure title
164  update (figure::properties::ID_NUMBERTITLE);
165 
166  // Decide what keyboard events we listen to
168  update (figure::properties::ID_KEYPRESSFCN);
169  update (figure::properties::ID_KEYRELEASEFCN);
170 
171  // modal style
172  update (figure::properties::ID_WINDOWSTYLE);
173 
174  // Handle resizing constraints
175  update (figure::properties::ID_RESIZE);
176 
177  // Custom pointer data
178  update (figure::properties::ID_POINTERSHAPECDATA);
179 
180  // Visibility
181  update (figure::properties::ID_VISIBLE);
182 
183  connect (this, SIGNAL (asyncUpdate (void)),
184  this, SLOT (updateContainer (void)));
185 
186  // Register for the signal that indicates when a window has moved
187  // to a different screen
188  connect (win, SIGNAL (figureWindowShown ()),
189  this, SLOT (figureWindowShown ()));
190 
191  win->addReceiver (this);
192  m_container->addReceiver (this);
193  }
194 
196  { }
197 
198  QString
200  {
202 
203  octave::autolock guard (gh_mgr.graphics_lock ());
204 
205  const figure::properties& fp = properties<figure> ();
206 
207  std::string name = fp.get_filename ();
208 
209  return QString::fromStdString (name);
210  }
211 
212  void
213  Figure::setFileName (const QString& name)
214  {
216 
217  octave::autolock guard (gh_mgr.graphics_lock ());
218 
219  figure::properties& fp = properties<figure> ();
220 
221  fp.set_filename (name.toStdString ());
222  }
223 
224  MouseMode
226  {
228 
229  octave::autolock guard (gh_mgr.graphics_lock ());
230 
231  const figure::properties& fp = properties<figure> ();
232 
233  std::string mode = fp.get___mouse_mode__ ();
234 
235  if (mode == "zoom")
236  {
237  octave_scalar_map zm = fp.get___zoom_mode__ ().scalar_map_value ();
238 
239  std::string direction = zm.getfield ("Direction").string_value ();
240 
241  mode += ' ' + direction;
242  }
243 
244  if (mode == "rotate")
245  return RotateMode;
246  else if (mode == "zoom in")
247  return ZoomInMode;
248  else if (mode == "zoom out")
249  return ZoomOutMode;
250  else if (mode == "pan")
251  return PanMode;
252  else if (mode == "text")
253  return TextMode;
254 
255  return NoMode;
256  }
257 
258  void
260  {
261  QMainWindow *win = qWidget<QMainWindow> ();
262 
263  if (! m_resizable)
264  {
265  win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
266  win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
267  }
268 
269  // Unlock window if it is maximized or full-screen
270  int state = win->windowState ();
271  if (state == Qt::WindowFullScreen || state == Qt::WindowMaximized)
272  win->setWindowState (Qt::WindowNoState);
273 
274  win->setGeometry (r);
275 
276  if (! m_resizable)
277  {
278  win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
279  win->setFixedSize(win->size ());
280  }
281  }
282 
283  Container*
285  {
286  return m_container;
287  }
288 
289  void
291  {
292  Canvas *canvas = m_container->canvas (m_handle);
293 
294  if (canvas)
295  canvas->redraw ();
296 
297  for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
298  {
299  if (qobj->objectName () == "UIPanel"
300  || qobj->objectName () == "UIButtonGroup"
301  || qobj->objectName () == "UIControl"
302  || qobj->objectName () == "UITable")
303  {
304  Object *obj = Object::fromQObject (qobj);
305 
306  if (obj)
307  obj->slotRedraw ();
308  }
309  }
310  }
311 
312  void
314  {
315  QWidget *win = qWidget<QWidget> ();
316 
317  win->activateWindow ();
318  win->raise ();
319  }
320 
321  void
322  Figure::print (const QString& file_cmd, const QString& term)
323  {
324  Canvas *canvas = m_container->canvas (m_handle);
325 
326  if (canvas)
327  canvas->print (file_cmd, term);
328  }
329 
332  {
334  Canvas *canvas = m_container->canvas (m_handle);
335 
336  if (canvas)
337  {
339 
340  gh_mgr.process_events ();
341  octave::autolock guard (gh_mgr.graphics_lock ());
342  retval = canvas->getPixels ();
343  }
344 
345  return retval;
346  }
347 
348  void
350  {
351  Canvas *canvas = m_container->canvas (m_handle.value (), false);
352 
353  if (canvas)
354  canvas->blockRedraw (true);
355 
356  m_container->removeReceiver (this);
357  qWidget<FigureWindow> ()->removeReceiver (this);
358  }
359 
360  void
361  Figure::update (int pId)
362  {
363  if (m_blockUpdates)
364  return;
365 
366  figure::properties& fp = properties<figure> ();
367 
368  if (fp.is___printing__ ())
369  return;
370 
371  QMainWindow *win = qWidget<QMainWindow> ();
372 
373  // If the window doesn't exist, there's nothing we can do.
374  if (! win)
375  return;
376 
377  m_blockUpdates = true;
378 
379  switch (pId)
380  {
381  case figure::properties::ID_POSITION:
382  {
384  int toffset = 0;
385  int boffset = 0;
386 
387  for (auto *tb : win->findChildren<QToolBar*> ())
388  if (! tb->isHidden ())
389  toffset += tb->sizeHint ().height ();
390 
391  if (! m_menuBar->isHidden ())
392  toffset += m_menuBar->sizeHint ().height ();
393 
394  if (! m_statusBar->isHidden ())
395  boffset += m_statusBar->sizeHint ().height ();
396 
397  set_geometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
398  }
399  break;
400 
401  case figure::properties::ID_NAME:
402  case figure::properties::ID_NUMBERTITLE:
403  win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
404  break;
405 
406  case figure::properties::ID_VISIBLE:
407  if (fp.is_visible ())
408  {
409  QTimer::singleShot (0, win, SLOT (show ()));
410  if (! fp.is___gl_window__ ())
411  {
413 
414  octave::autolock guard (gh_mgr.graphics_lock ());
415  fp.set ("__gl_window__", "on");
416  }
417  }
418  else
419  win->hide ();
420  break;
421 
422  case figure::properties::ID_RESIZE:
423  if (fp.is_resize ())
424  {
425  win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
426  win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
427  m_resizable = true;
428  }
429  else
430  {
431  win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
432  win->setFixedSize(win->size ());
433  m_resizable = false;
434  }
435  break;
436 
437  case figure::properties::ID_MENUBAR:
438  case figure::properties::ID_TOOLBAR:
439  if (fp.toolbar_is ("none"))
440  showFigureStatusBar (false);
441  else if (fp.toolbar_is ("figure"))
442  showFigureStatusBar (true);
443  else // "auto"
444  showFigureStatusBar (fp.menubar_is ("figure"));
445  break;
446 
447  case figure::properties::ID_KEYPRESSFCN:
448  if (fp.get_keypressfcn ().isempty ())
450  else
452  // Signal the change to uipanels as well
453  for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
454  {
455  if (qobj->objectName () == "UIPanel")
456  {
457  Object *obj = Object::fromQObject (qobj);
458 
459  if (obj)
460  {
461  if (fp.get_keypressfcn ().isempty ())
462  obj->innerContainer ()->canvas (m_handle)->
463  clearEventMask (Canvas::KeyPress);
464  else
465  obj->innerContainer ()->canvas (m_handle)->
466  addEventMask (Canvas::KeyPress);
467  }
468  }
469  }
470  break;
471 
472  case figure::properties::ID_KEYRELEASEFCN:
473  if (fp.get_keyreleasefcn ().isempty ())
475  else
477  break;
478  // Signal the change to uipanels as well
479  for (auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
480  {
481  if (qobj->objectName () == "UIPanel")
482  {
483  Object *obj = Object::fromQObject (qobj);
484 
485  if (obj)
486  {
487  if (fp.get_keypressfcn ().isempty ())
488  obj->innerContainer ()->canvas (m_handle)->
489  clearEventMask (Canvas::KeyRelease);
490  else
491  obj->innerContainer ()->canvas (m_handle)->
492  addEventMask (Canvas::KeyRelease);
493  }
494  }
495  }
496  break;
497 
498  case figure::properties::ID_WINDOWSTYLE:
499  if (fp.windowstyle_is ("modal"))
500  {
501  bool is_visible = win->isVisible ();
502 
503  // if window is already visible, need to hide and reshow it in order to
504  // make it use the modal settings
505  if (is_visible)
506  win->setVisible (false);
507 
508  win->setWindowModality (Qt::ApplicationModal);
509  win->setVisible (is_visible);
510  }
511  else
512  win->setWindowModality (Qt::NonModal);
513 
514  break;
515 
516  case figure::properties::ID_POINTERSHAPECDATA:
518  pointer_to_qimage (fp.get_pointershapecdata ().matrix_value ());
519  if (fp.get_pointer () != "custom")
520  break;
521  OCTAVE_FALLTHROUGH;
522 
523  case figure::properties::ID_POINTER:
524  case figure::properties::ID_POINTERSHAPEHOTSPOT:
525  case figure::properties::ID___MOUSE_MODE__:
526  case figure::properties::ID___ZOOM_MODE__:
528  fp.get_pointer (),
530  fp.get_pointershapehotspot ()
531  .matrix_value());
532  break;
533 
534  default:
535  break;
536  }
537 
538  m_blockUpdates = false;
539  }
540 
541  void
543  {
544  if (m_statusBar
545  && (! m_statusBar->isHidden ()) != visible)
546  {
547  int dy = m_statusBar->sizeHint ().height ();
548  QRect r = qWidget<QWidget> ()->geometry ();
549 
550  if (! visible)
551  r.adjust (0, 0, 0, -dy);
552  else
553  r.adjust (0, 0, 0, dy);
554 
555  m_blockUpdates = true;
556  set_geometry (r);
557  m_statusBar->setVisible (visible);
558  m_blockUpdates = false;
559 
560  updateBoundingBox (false);
561  }
562  }
563 
564  void
566  {
568 
569  octave::autolock guard (gh_mgr.graphics_lock ());
570  graphics_object go = object ();
571 
572  if (go.valid_object () && dh != 0)
573  {
574  QRect r = qWidget<QWidget> ()->geometry ();
575 
576  r.adjust (0, dh, 0, 0);
577 
578  m_blockUpdates = true;
579  set_geometry (r);
580  m_blockUpdates = false;
581 
582  updateBoundingBox (false);
583  }
584  }
585 
586  void
588  {
589  if (! m_statusBar->isHidden ())
590  m_statusBar->showMessage (QString ("(%1, %2)")
591  .arg (pt(0), 0, 'g', 5)
592  .arg (pt(1), 0, 'g', 5));
593  }
594 
595  void
596  Figure::do_connections (const QObject *receiver, const QObject* /* emitter */)
597  {
598  Object::do_connections (receiver);
600  }
601 
602  QWidget*
604  {
605  return qWidget<QMainWindow> ()->menuBar ();
606  }
607 
608  void
609  Figure::updateBoundingBox (bool internal, int flags)
610  {
611  QWidget *win = qWidget<QWidget> ();
612  Matrix bb (1, 4);
613  std::string prop;
614 
615  if (internal)
616  {
617  prop = "position";
618  QRect r = m_innerRect;
619 
620  if (flags & UpdateBoundingBoxPosition)
621  r.moveTopLeft (win->mapToGlobal (m_container->pos ()));
622  if (flags & UpdateBoundingBoxSize)
623  r.setSize (m_container->size ());
624 
625  if (r.isValid () && r != m_innerRect)
626  {
627  m_innerRect = r;
628 
629  bb(0) = r.x ();
630  bb(1) = r.y ();
631  bb(2) = r.width ();
632  bb(3) = r.height ();
633  }
634  else
635  return;
636  }
637  else
638  {
639  prop = "outerposition";
640  QRect r = m_outerRect;
641 
642  if (flags & UpdateBoundingBoxPosition)
643  r.moveTopLeft (win->pos ());
644  if (flags & UpdateBoundingBoxSize)
645  r.setSize (win->frameGeometry ().size ());
646 
647  if (r.isValid () && r != m_outerRect)
648  {
649  m_outerRect = r;
650 
651  bb(0) = r.x ();
652  bb(1) = r.y ();
653  bb(2) = r.width ();
654  bb(3) = r.height ();
655  }
656  else
657  return;
658  }
659 
660  figure::properties& fp = properties<figure> ();
661 
662  emit gh_set_event (m_handle, prop, fp.bbox2position (bb), false,
663  prop == "position");
664  }
665 
666  bool
667  Figure::eventNotifyBefore (QObject *obj, QEvent *xevent)
668  {
669  if (! m_blockUpdates)
670  {
671  // Clicking the toolbar or the menubar makes this figure current
672  if (xevent->type () == QEvent::MouseButtonPress)
673  {
674  figure::properties& fp = properties<figure> ();
675 
677 
678  graphics_object root = gh_mgr.get_object (0);
679 
680  if (fp.get_handlevisibility () == "on")
681  root.set ("currentfigure",
682  fp.get___myhandle__ ().as_octave_value ());
683  }
684 
685  if (obj == m_container)
686  {
687  // Do nothing...
688  }
689  else if (obj == m_menuBar)
690  {
691  switch (xevent->type ())
692  {
693  case QEvent::ActionAdded:
694  case QEvent::ActionChanged:
695  case QEvent::ActionRemoved:
696  m_previousHeight = m_menuBar->sizeHint ().height ();
697 
698  default:
699  break;
700  }
701  }
702  else
703  {
704  switch (xevent->type ())
705  {
706  case QEvent::Close:
707  xevent->ignore ();
708  emit gh_callback_event (m_handle, "closerequestfcn");
709  return true;
710 
711  default:
712  break;
713  }
714  }
715  }
716 
717  return false;
718  }
719 
720  void
721  Figure::eventNotifyAfter (QObject *watched, QEvent *xevent)
722  {
723  if (! m_blockUpdates)
724  {
725  if (watched == m_container)
726  {
728 
729  switch (xevent->type ())
730  {
731  case QEvent::Resize:
733  break;
734 
735  case QEvent::ChildAdded:
736  if (dynamic_cast<QChildEvent *> (xevent)->child
737  ()->isWidgetType())
738  {
739  octave::autolock guard (gh_mgr.graphics_lock ());
740  update (figure::properties::ID_TOOLBAR);
741 
743  }
744  break;
745 
746  case QEvent::ChildRemoved:
747  if (dynamic_cast<QChildEvent *> (xevent)->child
748  ()->isWidgetType())
749  {
750  octave::autolock guard (gh_mgr.graphics_lock ());
751  update (figure::properties::ID_TOOLBAR);
752  }
753  break;
754 
755  default:
756  break;
757  }
758  }
759  else if (watched == m_menuBar)
760  {
761  switch (xevent->type ())
762  {
763  case QEvent::ActionAdded:
764  case QEvent::ActionChanged:
765  case QEvent::ActionRemoved:
766  // The menubar may have been resized if no action is visible
767  {
768  QAction *a = dynamic_cast<QActionEvent *> (xevent)->action ();
769  int currentHeight = m_menuBar->sizeHint ().height ();
770  if (currentHeight != m_previousHeight
771  && ! a->isSeparator ())
772  updateFigureHeight (m_previousHeight - currentHeight);
773  }
774  break;
775 
776  default:
777  break;
778  }
779  }
780  else
781  {
782  switch (xevent->type ())
783  {
784  case QEvent::Move:
787  break;
788 
789  case QEvent::Resize:
791  break;
792 
793  default:
794  break;
795  }
796  }
797  }
798  }
799 
800  void
801  Figure::addCustomToolBar (QToolBar *bar, bool visible, bool isdefault)
802  {
803  QMainWindow *win = qWidget<QMainWindow> ();
804 
805  if (isdefault)
806  m_figureToolBar = bar;
807 
808  if (! visible)
809  win->addToolBar (bar);
810  else
811  {
812  QSize sz = bar->sizeHint ();
813  QRect r = win->geometry ();
814 
815  r.adjust (0, -sz.height (), 0, 0);
816 
817  m_blockUpdates = true;
818  set_geometry (r);
819  win->addToolBarBreak ();
820  win->addToolBar (bar);
821  m_blockUpdates = false;
822 
823  updateBoundingBox (false);
824  }
825  }
826 
827  void
828  Figure::showCustomToolBar (QToolBar *bar, bool visible)
829  {
830  QMainWindow *win = qWidget<QMainWindow> ();
831 
832  if ((! bar->isHidden ()) != visible)
833  {
834  QSize sz = bar->sizeHint ();
835  QRect r = win->geometry ();
836 
837  if (visible)
838  r.adjust (0, -sz.height (), 0, 0);
839  else
840  r.adjust (0, sz.height (), 0, 0);
841 
842  m_blockUpdates = true;
843  set_geometry (r);
844  bar->setVisible (visible);
845  m_blockUpdates = false;
846 
847  updateBoundingBox (false);
848  }
849  }
850 
851  void
853  {
854  redraw ();
855  }
856 
857  void
859  {
860 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
861  QWindow* window = qWidget<QMainWindow> ()->windowHandle ();
862  QScreen* screen = window->screen ();
863 
865 
866  octave::autolock guard (gh_mgr.graphics_lock ());
867 
868  figure::properties& fp = properties<figure> ();
869  fp.set___device_pixel_ratio__ (screen->devicePixelRatio ());
870 
871  connect (window, SIGNAL (screenChanged (QScreen*)),
872  this, SLOT (screenChanged (QScreen*)));
873 #endif
874  }
875 
876  void
877  Figure::screenChanged (QScreen* screen)
878  {
879 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
881 
882  octave::autolock guard (gh_mgr.graphics_lock ());
883 
884  figure::properties& fp = properties<figure> ();
885  double old_dpr = fp.get___device_pixel_ratio__ ();
886  double new_dpr = screen->devicePixelRatio ();
887  if (old_dpr != new_dpr)
888  {
889  fp.set___device_pixel_ratio__ (new_dpr);
890 
891  // For some obscure reason, changing the __device_pixel_ratio__ property
892  // from the GUI thread does not necessarily trigger a redraw. Force it.
893  redraw ();
894  }
895 #else
896  octave_unused_parameter (screen);
897 #endif
898  }
899 
900  void
902  {
903  // Enable mouse tracking on every widgets
904  m_container->setMouseTracking (true);
905  m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
906  for (auto *w : m_container->findChildren<QWidget*> ())
907  w->setMouseTracking (true);
908  }
909 
910 }
#define DECLARE_GENERICEVENTNOTIFY_SENDER(T, B)
octave_idx_type columns(void) const
Definition: Array.h:424
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:377
octave_idx_type rows(void) const
Definition: Array.h:415
Definition: dMatrix.h:42
void print(const QString &file_cmd, const QString &term)
Definition: Canvas.h:70
void addEventMask(int m)
Definition: Canvas.h:75
virtual QWidget * qWidget(void)=0
void setCursor(MouseMode mode, std::string fallback, QImage cdata, Matrix hotspot)
Definition: Canvas.cc:88
void clearEventMask(int m)
Definition: Canvas.h:76
virtual uint8NDArray getPixels(void)
Definition: Canvas.h:89
void redraw(bool sync=false)
Definition: Canvas.cc:58
void setEventMask(int m)
Definition: Canvas.h:77
void blockRedraw(bool block=true)
Definition: Canvas.cc:72
Canvas * canvas(const graphics_handle &handle, bool create=true)
Definition: Container.cc:56
QWidget * menu(void)
Definition: Figure.cc:603
void eventNotifyAfter(QObject *watched, QEvent *event)
Definition: Figure.cc:721
void screenChanged(QScreen *)
Definition: Figure.cc:877
void showFigureStatusBar(bool visible)
Definition: Figure.cc:542
void enableMouseTracking(void)
Definition: Figure.cc:901
void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
Definition: Figure.cc:596
void redraw(void)
Definition: Figure.cc:290
bool eventNotifyBefore(QObject *watched, QEvent *event)
Definition: Figure.cc:667
void updateBoundingBox(bool internal=false, int flags=0)
Definition: Figure.cc:609
void showCustomToolBar(QToolBar *bar, bool visible)
Definition: Figure.cc:828
Figure(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, FigureWindow *win)
Definition: Figure.cc:119
uint8NDArray slotGetPixels(void)
Definition: Figure.cc:331
@ UpdateBoundingBoxSize
Definition: Figure.h:102
@ UpdateBoundingBoxPosition
Definition: Figure.h:101
QToolBar * m_figureToolBar
Definition: Figure.h:137
void updateContainer(void)
Definition: Figure.cc:852
bool m_resizable
Definition: Figure.h:144
void beingDeleted(void)
Definition: Figure.cc:349
Container * m_container
Definition: Figure.h:135
void updateStatusBar(ColumnVector pt)
Definition: Figure.cc:587
void asyncUpdate(void)
void figureWindowShown()
Definition: Figure.cc:858
Container * innerContainer(void)
Definition: Figure.cc:284
QString fileName(void)
Definition: Figure.cc:199
void addCustomToolBar(QToolBar *bar, bool visible, bool isdefault)
Definition: Figure.cc:801
QRect m_innerRect
Definition: Figure.h:140
QImage m_pointer_cdata
Definition: Figure.h:142
QStatusBar * m_statusBar
Definition: Figure.h:139
MouseMode mouseMode(void)
Definition: Figure.cc:225
QRect m_outerRect
Definition: Figure.h:141
int m_previousHeight
Definition: Figure.h:143
void show(void)
Definition: Figure.cc:313
void set_geometry(QRect r)
Definition: Figure.cc:259
static Figure * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
Definition: Figure.cc:113
void print(const QString &file_cmd, const QString &term)
Definition: Figure.cc:322
void update(int pId)
Definition: Figure.cc:361
bool m_blockUpdates
Definition: Figure.h:136
void setFileName(const QString &name)
Definition: Figure.cc:213
void updateFigureHeight(int delta_h)
Definition: Figure.cc:565
MenuBar * m_menuBar
Definition: Figure.h:138
void removeReceiver(GenericEventNotifyReceiver *r)
void addReceiver(GenericEventNotifyReceiver *r)
graphics_object object(void) const
Definition: Object.cc:83
void slotRedraw(void)
Definition: Object.cc:131
virtual Container * innerContainer(void)=0
virtual void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
Definition: Object.cc:225
octave::interpreter & m_interpreter
Definition: Object.h:140
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * fromQObject(QObject *obj)
Definition: Object.cc:214
graphics_handle m_handle
Definition: Object.h:157
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
virtual void set(const caseless_str &, const octave_value &)
Matrix get_boundingbox(bool internal=false, const Matrix &parent_pix_size=Matrix()) const
Definition: graphics.cc:4254
Matrix bbox2position(const Matrix &bbox) const
Definition: graphics.cc:4271
std::string get_title(void) const
Definition: graphics.cc:5004
graphics_object get_object(double val) const
Definition: graphics.in.h:6260
int process_events(bool force=false)
Definition: graphics.cc:12268
octave::mutex graphics_lock(void)
Definition: graphics.in.h:6393
void set(const caseless_str &name, const octave_value &val)
Definition: graphics.in.h:2729
bool valid_object(void) const
Definition: graphics.in.h:2847
Base class for Octave interfaces that use Qt.
gh_manager & get_gh_manager(void)
Definition: interpreter.h:295
double value(void) const
Definition: oct-handle.h:78
octave_value getfield(const std::string &key) const
Definition: oct-map.cc:183
std::string string_value(bool force=false) const
Definition: ov.h:927
QString name
const QString global_menubar_style("QMenuBar {" "spacing-top: 0px;" "spacing-bottom: 0px;" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "}")
T * r
Definition: mx-inlines.cc:773
std::complex< double > w(std::complex< double > z, double relerr=0)
QString fromStdString(const std::string &s)
static QRect boundingBoxToRect(const Matrix &bb)
Definition: Figure.cc:74
MouseMode
Definition: Figure.h:50
@ ZoomOutMode
Definition: Figure.h:54
@ TextMode
Definition: Figure.h:57
@ NoMode
Definition: Figure.h:51
@ PanMode
Definition: Figure.h:55
@ ZoomInMode
Definition: Figure.h:53
@ RotateMode
Definition: Figure.h:52
static QImage pointer_to_qimage(const Matrix &cdata)
Definition: Figure.cc:90
double round(double x)
Definition: lo-mappers.h:136
static uint32_t state[624]
Definition: randmtzig.cc:190
std::function< void(octave::interpreter &)> meth_callback
Definition: event-manager.h:47
std::function< void(void)> fcn_callback
Definition: event-manager.h:46
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811