GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Canvas.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <QApplication>
28 #include <QBitmap>
29 #include <QCursor>
30 #include <QInputDialog>
31 #include <QList>
32 #include <QMouseEvent>
33 #include <QWheelEvent>
34 #include <QRectF>
35 
36 #include "Backend.h"
37 #include "Canvas.h"
38 #include "ContextMenu.h"
39 #include "GLCanvas.h"
40 #include "QtHandlesUtils.h"
41 
42 #include "annotation-dialog.h"
43 
44 #include "gl2ps-renderer.h"
45 #include "octave-qt-link.h"
46 
47 #include "builtin-defun-decls.h"
48 
49 namespace QtHandles
50 {
51 
52 void
53 Canvas::redraw (bool sync)
54 {
55  QWidget *w = qWidget ();
56 
57  if (w)
58  {
59  if (sync)
60  w->repaint ();
61  else
62  w->update ();
63  }
64 }
65 
66 void
67 Canvas::blockRedraw (bool block)
68 {
69  m_redrawBlocked = block;
70 }
71 
72 void
74 {
75  QWidget *w = qWidget ();
76 
77  if (w)
78  {
79  static QCursor origCursor = w->cursor ();
80 
81  switch (mode)
82  {
83  case PanMode:
84  case RotateMode:
85  w->setCursor (Qt::OpenHandCursor);
86  break;
87 
88  case ZoomInMode:
89  w->setCursor (QPixmap (":/images/zoom-in.png"));
90  break;
91 
92  case ZoomOutMode:
93  w->setCursor (QPixmap (":/images/zoom-out.png"));
94  break;
95 
96  default:
97  w->setCursor (origCursor);
98  break;
99  }
100  }
101 }
102 
103 void
104 Canvas::print (const QString& file_cmd, const QString& term)
105 {
108 
109  if (obj.valid_object ())
110  {
111  graphics_object figObj (obj.get_ancestor ("figure"));
112 
113  gl2ps_print (figObj, file_cmd.toStdString (), term.toStdString ());
114  }
115 }
116 
117 /*
118  Two updateCurrentPoint() routines are required:
119  1) Used for QMouseEvents where cursor position data is in callback from Qt.
120  2) Used for QKeyEvents where cursor position must be determined.
121 */
122 void
124  const graphics_object& obj, QMouseEvent* event)
125 {
127 
128  gh_manager::post_set (fig.get_handle (), "currentpoint",
129  Utils::figureCurrentPoint (fig, event), false);
130 
131  Matrix children = obj.get_properties ().get_children ();
132  octave_idx_type num_children = children.numel ();
133 
134  for (int i = 0; i < num_children; i++)
135  {
136  graphics_object childObj (gh_manager::get_object (children(i)));
137 
138  if (childObj.isa ("axes"))
139  {
140  axes::properties& ap = Utils::properties<axes> (childObj);
141  Matrix x_zlim = ap.get_transform_zlim ();
142  graphics_xform x_form = ap.get_transform ();
143 
144  ColumnVector p1 = x_form.untransform (event->x (), event->y (),
145  x_zlim(0));
146  ColumnVector p2 = x_form.untransform (event->x (), event->y (),
147  x_zlim(1));
148 
149  Matrix cp (2, 3, 0.0);
150 
151  cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
152  cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
153 
154  gh_manager::post_set (childObj.get_handle (), "currentpoint", cp,
155  false);
156  }
157  }
158 }
159 
160 void
162  const graphics_object& obj)
163 {
165 
166  gh_manager::post_set (fig.get_handle (), "currentpoint",
167  Utils::figureCurrentPoint (fig), false);
168 
169  Matrix children = obj.get_properties ().get_children ();
170  octave_idx_type num_children = children.numel ();
171 
172  for (int i = 0; i < num_children; i++)
173  {
174  graphics_object childObj (gh_manager::get_object (children(i)));
175 
176  if (childObj.isa ("axes"))
177  {
178  // FIXME: QCursor::pos() may give inaccurate results with asynchronous
179  // window systems like X11 over ssh.
180  QWidget *w = qWidget ();
181  QPoint p = w->mapFromGlobal (QCursor::pos ());
182  axes::properties& ap = Utils::properties<axes> (childObj);
183  Matrix x_zlim = ap.get_transform_zlim ();
184  graphics_xform x_form = ap.get_transform ();
185 
186  ColumnVector p1 = x_form.untransform (p.x (), p.y (), x_zlim(0));
187  ColumnVector p2 = x_form.untransform (p.x (), p.y (), x_zlim(1));
188 
189  Matrix cp (2, 3, 0.0);
190 
191  cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
192  cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
193 
194  gh_manager::post_set (childObj.get_handle (), "currentpoint", cp,
195  false);
196  }
197  }
198 }
199 
200 void
202 {
203  Ffeval (ovl ("annotation").append (args));
204 
205  redraw ();
206 }
207 
208 void
210 {
212 
214 
215  if (go.valid_object ())
216  {
217  figure::properties& fp = Utils::properties<figure> (go);
218 
219  graphics_handle ah = fp.get_currentaxes ();
220 
222 
223  if (ax.valid_object ())
224  {
225  axes::properties& ap = Utils::properties<axes> (ax);
226 
227  if (ap.handlevisibility_is ("on"))
228  {
229  ap.set_visible (! ap.is_visible ());
230 
231  redraw (true);
232  }
233  }
234  }
235 }
236 
237 void
239 {
241 
243 
244  if (go.valid_object ())
245  {
246  figure::properties& fp = Utils::properties<figure> (go);
247 
248  graphics_handle ah = fp.get_currentaxes ();
249 
251 
252  if (ax.valid_object ())
253  {
254  axes::properties& ap = Utils::properties<axes> (ax);
255 
256  std::string tmp;
257 
258  // If any grid is off, then turn them all on. If they are all
259  // on, then turn them off.
260 
261  std::string state = ((ap.get_xgrid () == "off"
262  || ap.get_ygrid () == "off"
263  || ap.get_zgrid () == "off")
264  ? "on" : "off");
265 
266  ap.set_xgrid (state);
267  ap.set_ygrid (state);
268  ap.set_zgrid (state);
269 
270  redraw (true);
271 
272  }
273  }
274 }
275 
276 static void
278 {
279  ap.clear_zoom_stack ();
280 
281  ap.set_xlimmode ("auto");
282  ap.set_ylimmode ("auto");
283  ap.set_zlimmode ("auto");
284 }
285 
286 void
288 {
290 
292 
293  if (go.valid_object ())
294  {
295  figure::properties& fp = Utils::properties<figure> (go);
296 
297  graphics_handle ah = fp.get_currentaxes ();
298 
300 
301  if (ax.valid_object ())
302  {
303  axes::properties& ap = Utils::properties<axes> (ax);
304 
305  autoscale_axes (ap);
306 
307  redraw (true);
308  }
309  }
310 }
311 
312 void
314 {
315  if (! m_redrawBlocked)
316  {
318 
319  draw (m_handle);
320 
321  if ((m_mouseMode == ZoomInMode && m_mouseAxes.ok ()) || m_rectMode)
323  }
324 }
325 
326 static bool
328 {
329  // Getting pan mode property:
330  octave_value ov_pm
331  = Utils::properties<figure> (figObj).get___pan_mode__ ();
332 
333  octave_scalar_map pm = ov_pm.scalar_map_value ();
334 
335  return pm.contents ("Enable").string_value () == "on";
336 }
337 
338 static std::string
339 pan_mode (const graphics_object figObj)
340 {
341  // Getting pan mode property:
342  octave_value ov_pm
343  = Utils::properties<figure> (figObj).get___pan_mode__ ();
344 
345  octave_scalar_map pm = ov_pm.scalar_map_value ();
346 
347  return pm.contents ("Motion").string_value ();
348 }
349 
350 static bool
352 {
353  // Getting rotate mode property:
354  octave_value ov_rm
355  = Utils::properties<figure> (figObj).get___rotate_mode__ ();
356 
357  octave_scalar_map rm = ov_rm.scalar_map_value ();
358 
359  return rm.contents ("Enable").string_value () == "on";
360 }
361 
362 static bool
364 {
365  // Getting zoom mode property:
366  octave_value ov_zm
367  = Utils::properties<figure> (figObj).get___zoom_mode__ ();
368 
369  octave_scalar_map zm = ov_zm.scalar_map_value ();
370 
371  return zm.contents ("Enable").string_value () == "on";
372 }
373 
374 static std::string
376 {
377  // Getting zoom mode property:
378  octave_value ov_zm
379  = Utils::properties<figure> (figObj).get___zoom_mode__ ();
380 
381  octave_scalar_map zm = ov_zm.scalar_map_value ();
382 
383  return zm.contents ("Motion").string_value ();
384 }
385 
386 static std::string
388 {
389  // Getting zoom mode property:
390  octave_value ov_zm
391  = Utils::properties<figure> (figObj).get___zoom_mode__ ();
392 
393  octave_scalar_map zm = ov_zm.scalar_map_value ();
394 
395  return zm.contents ("Direction").string_value ();
396 }
397 
398 void
399 Canvas::canvasMouseMoveEvent (QMouseEvent* event)
400 {
403 
404  if (m_mouseMode != NoMode && ax.valid_object ())
405  {
406  axes::properties& ap = Utils::properties<axes> (ax);
407 
408  switch (m_mouseMode)
409  {
410  case RotateMode:
411  {
412  ap.rotate3d (m_mouseCurrent.x (), event->x (),
413  m_mouseCurrent.y (), event->y ());
414 
415  // Update current mouse position
416  m_mouseCurrent = event->pos ();
417 
418  // Force immediate redraw
419  redraw (true);
420  }
421  break;
422  case TextMode:
423  case ZoomInMode:
424  case ZoomOutMode:
425  m_mouseCurrent = event->pos ();
426  redraw (true);
427  break;
428 
429  case PanMode:
430  {
431  graphics_object figObj (ax.get_ancestor ("figure"));
432 
433  std::string mode = pan_mode (figObj);
434 
436  m_mouseCurrent.y ());
437  ColumnVector p1 = ap.pixel2coord (event->x (),
438  event->y ());
439 
440  ap.translate_view (mode, p0(0), p1(0), p0(1), p1(1));
441 
442  // Update current mouse position
443  m_mouseCurrent = event->pos ();
444 
445  // Force immediate redraw
446  redraw (true);
447  }
448 
449  default:
450  break;
451  }
452  }
453  else if (m_mouseMode == NoMode)
454  {
456 
457  if (obj.valid_object ())
458  {
459  graphics_object figObj (obj.get_ancestor ("figure"));
460 
461  updateCurrentPoint (figObj, obj, event);
462  gh_manager::post_callback (figObj.get_handle (),
463  "windowbuttonmotionfcn");
464  }
465  }
466 }
467 
468 void
470 {
471  // same processing as normal click, but event type is MouseButtonDblClick
472  canvasMousePressEvent (event);
473 }
474 
475 static double
476 button_number (QMouseEvent *event)
477 {
478  double retval = 0;
479 
480  switch (event->button ())
481  {
482  case Qt::LeftButton:
483  retval = 1;
484  break;
485 
486  case Qt::MidButton:
487  retval = 2;
488  break;
489 
490  case Qt::RightButton:
491  retval = 3;
492  break;
493 
494  default:
495  break;
496  }
497 
498  return retval;
499 }
500 
501 void
502 Canvas::canvasMousePressEvent (QMouseEvent* event)
503 {
506 
507  bool isdblclick = (event->type () == QEvent::MouseButtonDblClick);
508 
509  if (obj.valid_object ())
510  {
511  graphics_object figObj (obj.get_ancestor ("figure"));
512  graphics_object currentObj, axesObj;
513  QList<graphics_object> axesList;
514 
515  Matrix children = obj.get_properties ().get_all_children ();
516  octave_idx_type num_children = children.numel ();
517 
518  for (int i = 0; i < num_children; i++)
519  {
520  graphics_object childObj (gh_manager::get_object (children(i)));
521 
522  if (childObj.isa ("axes"))
523  axesList.append (childObj);
524  else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel"))
525  {
526  Matrix bb = childObj.get_properties ().get_boundingbox (false);
527  QRectF r (bb(0), bb(1), bb(2), bb(3));
528 
529  r.adjust (-5, -5, 5, 5);
530  if (r.contains (event->posF ()))
531  {
532  currentObj = childObj;
533  break;
534  }
535  }
536  }
537 
538  if (! currentObj)
539  {
540  for (QList<graphics_object>::ConstIterator it = axesList.begin ();
541  it != axesList.end (); ++it)
542  {
543  graphics_object go = selectFromAxes (*it, event->pos ());
544 
545  if (go)
546  {
547  currentObj = go;
548  axesObj = *it;
549  }
550  // FIXME: is this really necessary? the axes object should
551  // have been selected through selectFromAxes anyway
552  else if (it->get_properties ().is_hittest ())
553  {
554  Matrix bb = it->get_properties ().get_boundingbox (true);
555  QRectF r (bb(0), bb(1), bb(2), bb(3));
556 
557  if (r.contains (event->posF ()))
558  axesObj = *it;
559  }
560 
561  if (axesObj && currentObj)
562  break;
563  }
564 
565  if (axesObj)
566  {
567  if (axesObj.get_properties ().handlevisibility_is ("on"))
568  Utils::properties<figure> (figObj)
569  .set_currentaxes (axesObj.get_handle ().as_octave_value ());
570  if (! currentObj)
571  currentObj = axesObj;
572  }
573  }
574 
575  if (! currentObj)
576  currentObj = obj;
577 
578  if (currentObj.get_properties ().handlevisibility_is ("on"))
579  Utils::properties<figure> (figObj)
580  .set_currentobject (currentObj.get_handle ().as_octave_value ());
581  else
582  Utils::properties<figure> (figObj).set_currentobject (octave_NaN);
583 
584  Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj));
585 
586  MouseMode newMouseMode = NoMode;
587 
588  if (fig)
589  newMouseMode = fig->mouseMode ();
590 
591  switch (newMouseMode)
592  {
593  case NoMode:
594  gh_manager::post_set (figObj.get_handle (), "selectiontype",
595  Utils::figureSelectionType (event, isdblclick), false);
596 
597  updateCurrentPoint (figObj, obj, event);
598 
599  gh_manager::post_callback (figObj.get_handle (),
600  "windowbuttondownfcn",
601  button_number (event));
602 
603  gh_manager::post_callback (currentObj.get_handle (),
604  "buttondownfcn",
605  button_number (event));
606 
607  if (event->button () == Qt::RightButton)
608  ContextMenu::executeAt (currentObj.get_properties (),
609  event->globalPos ());
610  break;
611 
612  case TextMode:
613  {
614  if (event->modifiers () == Qt::NoModifier)
615  {
616  switch (event->buttons ())
617  {
618  case Qt::LeftButton:
619  m_mouseAnchor = m_mouseCurrent = event->pos ();
620  m_mouseAxes = axesObj.get_handle ();
621  m_mouseMode = newMouseMode;
622  m_rectMode = true;
623  }
624  }
625  redraw (false);
626  }
627  break;
628 
629  case PanMode:
630  case RotateMode:
631  case ZoomInMode:
632  case ZoomOutMode:
633  if (axesObj && axesObj.get_properties ().handlevisibility_is ("on"))
634  {
635  bool redraw_figure = true;
636 
637  if (isdblclick)
638  {
639  if (event->button () == Qt::LeftButton)
640  {
641  axes::properties& ap = Utils::properties<axes> (axesObj);
642 
643  autoscale_axes (ap);
644  }
645  else
646  {
647  redraw_figure = false;
648  }
649  }
650  else if (event->modifiers () == Qt::NoModifier)
651  {
652  switch (event->buttons ())
653  {
654  case Qt::LeftButton:
655  m_mouseAnchor = m_mouseCurrent = event->pos ();
656  m_mouseAxes = axesObj.get_handle ();
657  m_mouseMode = newMouseMode;
658  m_clickMode = newMouseMode == ZoomInMode;
659  break;
660 
661  case Qt::RightButton:
662  if (newMouseMode == ZoomInMode)
663  {
664  m_mouseAnchor = m_mouseCurrent = event->pos ();
665  m_mouseAxes = axesObj.get_handle ();
666  m_mouseMode = newMouseMode;
667  m_clickMode = false;
668  }
669 
670  break;
671 
672  case Qt::MidButton:
673  {
674  axes::properties& ap =
675  Utils::properties<axes> (axesObj);
676 
677  autoscale_axes (ap);
678  }
679  break;
680 
681  default:
682  redraw_figure = false;
683  break;
684  }
685  }
686  else if (event->modifiers () == Qt::ShiftModifier)
687  {
688  switch (event->buttons ())
689  {
690  case Qt::LeftButton:
691  if (newMouseMode == ZoomInMode)
692  {
693  m_mouseAnchor = m_mouseCurrent = event->pos ();
694  m_mouseAxes = axesObj.get_handle ();
695  m_mouseMode = newMouseMode;
696  m_clickMode = false;
697  }
698  break;
699 
700  default:
701  redraw_figure = false;
702  break;
703  }
704  }
705 
706  if (redraw_figure)
707  redraw (false);
708  }
709  break;
710 
711  default:
712  break;
713  }
714  }
715 
716 }
717 
718 void
720 {
722  && m_mouseAxes.ok ())
723  {
726 
727  if (ax.valid_object ())
728  {
729  axes::properties& ap = Utils::properties<axes> (ax);
730 
732 
733  graphics_object figObj (obj.get_ancestor ("figure"));
734 
735  std::string zm = zoom_mode (figObj);
736 
737  if (m_mouseAnchor == event->pos ())
738  {
739  double factor = m_clickMode ? 2.0 : 0.5;
740 
741  ColumnVector p1 = ap.pixel2coord (event->x (), event->y ());
742 
743  ap.zoom_about_point (zm, p1(0), p1(1), factor);
744  }
745  else if (m_mouseMode == ZoomInMode)
746  {
747  ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (),
748  m_mouseAnchor.y ());
749  ColumnVector p1 = ap.pixel2coord (event->x (),
750  event->y ());
751 
752  Matrix xl (1, 2, 0.0);
753  Matrix yl (1, 2, 0.0);
754 
755  xl(0) = std::min (p0(0), p1(0));
756  xl(1) = std::max (p0(0), p1(0));
757  yl(0) = std::min (p0(1), p1(1));
758  yl(1) = std::max (p0(1), p1(1));
759 
760  ap.zoom (zm, xl, yl);
761  }
762 
763  redraw (false);
764  }
765  }
766  else if (m_mouseMode == NoMode)
767  {
770 
771  if (obj.valid_object ())
772  {
773  graphics_object figObj (obj.get_ancestor ("figure"));
774 
775  updateCurrentPoint (figObj, obj, event);
776  gh_manager::post_callback (figObj.get_handle (),
777  "windowbuttonupfcn");
778  }
779  }
780  else if (m_mouseMode == TextMode)
781  {
783 
784  graphics_object figObj =
786  if (figObj.valid_object ())
787  {
788  QWidget *w = qWidget ();
789  if (w)
790  {
791  Matrix bb = figObj.get ("position").matrix_value ();
792  bb(0) = m_mouseAnchor.x () / bb(2);
793  bb(1) = 1.0 - (m_mouseAnchor.y () / bb(3));
794  bb(2) = (event->x () - m_mouseAnchor.x ()) / bb(2);
795  bb(3) = (m_mouseAnchor.y () - event->y ()) / bb(3);
796 
797  octave_value_list props = ovl("textbox", bb);
798 
799  annotation_dialog anno_dlg (w, props);
800 
801  if (anno_dlg.exec () == QDialog::Accepted)
802  {
803  props = anno_dlg.get_properties ();
804 
806  props);
807  }
808  }
809  }
810  }
811  m_rectMode = false;
814 }
815 
816 void
817 Canvas::canvasWheelEvent (QWheelEvent* event)
818 {
821 
822  if (obj.valid_object ())
823  {
824  std::string mode;
825 
826  graphics_object axesObj;
827 
828  Matrix children = obj.get_properties ().get_children ();
829  octave_idx_type num_children = children.numel ();
830 
831  for (int i = 0; i < num_children; i++)
832  {
833  graphics_object childObj (gh_manager::get_object (children(i)));
834 
835  if (childObj.isa ("axes"))
836  {
837  graphics_object go = selectFromAxes (childObj, event->pos ());
838 
839  if (go)
840  {
841  axesObj = childObj;
842  break;
843  }
844  }
845  }
846 
847  if (axesObj)
848  {
849  MouseMode newMouseMode = NoMode;
850 
851  graphics_object figObj (obj.get_ancestor ("figure"));
852 
853  Figure* fig = dynamic_cast<Figure*> (Backend::toolkitObject (figObj));
854 
855  if (fig)
856  newMouseMode = fig->mouseMode ();
857 
858  if (axesObj.get_properties ().handlevisibility_is ("on"))
859  {
860  Utils::properties<figure> (figObj)
861  .set_currentaxes (axesObj.get_handle ().as_octave_value ());
862 
863  if (zoom_enabled (figObj))
864  {
865  if (event->delta () > 0)
866  newMouseMode = ZoomInMode;
867  else
868  newMouseMode = ZoomOutMode;
869 
870  mode = zoom_mode (figObj);
871  }
872  else if (pan_enabled (figObj))
873  {
874  newMouseMode = PanMode;
875 
876  mode = pan_mode (figObj);
877  }
878  }
879 
880  bool redrawFigure = true;
881 
882  switch (newMouseMode)
883  {
884  case ZoomInMode:
885  case ZoomOutMode:
886  {
887  axes::properties& ap = Utils::properties<axes> (axesObj);
888 
889  // Control how fast to zoom when using scroll wheel.
890  double wheel_zoom_speed = ap.get_mousewheelzoom ();
891 
892  // Determine if we're zooming in or out.
893  double factor = (newMouseMode == ZoomInMode
894  ? 1 / (1.0 - wheel_zoom_speed)
895  : 1.0 - wheel_zoom_speed);
896 
897  // FIXME: should we zoom about point for 2D plots?
898 
899  ap.zoom (mode, factor);
900  }
901  break;
902 
903  case PanMode:
904  {
905  axes::properties& ap = Utils::properties<axes> (axesObj);
906 
907  double factor = event->delta () > 0 ? 0.1 : -0.1;
908 
909  ap.pan (mode, factor);
910  }
911  break;
912 
913  default:
914  redrawFigure = false;
915  break;
916  }
917 
918  if (redrawFigure)
919  redraw (false);
920  }
921  }
922 }
923 
924 bool
925 Canvas::canvasKeyPressEvent (QKeyEvent* event)
926 {
927  if (m_eventMask & KeyPress)
928  {
931 
932  if (obj.valid_object ())
933  {
934  graphics_object figObj (obj.get_ancestor ("figure"));
935 
936  updateCurrentPoint (figObj, obj);
937  }
938 
939  octave_scalar_map eventData = Utils::makeKeyEventStruct (event);
940 
941  gh_manager::post_set (m_handle, "currentcharacter",
942  eventData.getfield ("Character"), false);
943  gh_manager::post_callback (m_handle, "keypressfcn", eventData);
944 
945  return true;
946  }
947 
948  return false;
949 }
950 
951 bool
953 {
954  if (! event->isAutoRepeat () && (m_eventMask & KeyRelease))
955  {
956  gh_manager::post_callback (m_handle, "keyreleasefcn",
957  Utils::makeKeyEventStruct (event));
958 
959  return true;
960  }
961 
962  return false;
963 }
964 
965 Canvas*
966 Canvas::create (const std::string& /* name */, QWidget* parent,
967  const graphics_handle& handle)
968 {
969  // Only OpenGL
970  return new GLCanvas (parent, handle);
971 }
972 
973 }; // namespace QtHandles
graphics_handle m_mouseAxes
Definition: Canvas.h:117
virtual QWidget * qWidget(void)=0
graphics_handle get_currentaxes(void) const
Definition: graphics.h:4168
static std::string zoom_direction(const graphics_object figObj)
Definition: Canvas.cc:387
void rotate3d(double x0, double x1, double y0, double y1, bool push_to_zoom_stack=true)
Definition: graphics.cc:7925
void set_ylimmode(const octave_value &val)
Definition: graphics.h:6501
bool handlevisibility_is(const std::string &v) const
Definition: graphics.h:2733
static void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
Definition: graphics.h:13329
bool is_visible(void) const
Definition: graphics.h:2758
static uint32_t state[624]
Definition: randmtzig.c:188
bool isa(const std::string &go_name) const
Definition: graphics.h:3375
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
MouseMode
Definition: Figure.h:38
const octave_value & contents(const_iterator p) const
Definition: oct-map.h:192
bool ok(void) const
Definition: oct-handle.h:105
graphics_handle m_handle
Definition: Canvas.h:111
void updateCurrentPoint(const graphics_object &fig, const graphics_object &obj, QMouseEvent *event)
Definition: Canvas.cc:123
void zoom(const std::string &mode, double factor, bool push_to_zoom_stack=true)
Definition: graphics.cc:7761
void set_visible(const octave_value &val)
Definition: graphics.h:2922
virtual Matrix get_boundingbox(bool=false, const Matrix &=Matrix()) const
Definition: graphics.h:2553
void translate_view(const std::string &mode, double x0, double x1, double y0, double y1, bool push_to_zoom_stack=true)
Definition: graphics.cc:7879
static bool rotate_enabled(const graphics_object figObj)
Definition: Canvas.cc:351
void print(const QString &file_cmd, const QString &term)
Definition: Canvas.cc:104
void set_zgrid(const octave_value &val)
Definition: graphics.h:6615
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
void redraw(bool sync=false)
Definition: Canvas.cc:53
void canvasToggleGrid(const graphics_handle &handle)
Definition: Canvas.cc:238
octave_value get(bool all=false) const
Definition: graphics.h:3300
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
static void autoscale_axes(axes::properties &ap)
Definition: Canvas.cc:277
void canvasMouseDoubleClickEvent(QMouseEvent *event)
Definition: Canvas.cc:469
graphics_xform get_transform(void) const
Definition: graphics.h:5127
void gl2ps_print(const graphics_object &fig, const std::string &cmd, const std::string &term)
std::string get_zgrid(void) const
Definition: graphics.h:5702
void canvasToggleAxes(const graphics_handle &handle)
Definition: Canvas.cc:209
static void executeAt(const base_properties &props, const QPoint &pt)
Definition: ContextMenu.cc:114
void pan(const std::string &mode, double factor, bool push_to_zoom_stack=true)
Definition: graphics.cc:7908
void canvasMousePressEvent(QMouseEvent *event)
Definition: Canvas.cc:502
QPoint m_mouseAnchor
Definition: Canvas.h:115
void canvasWheelEvent(QWheelEvent *event)
Definition: Canvas.cc:817
bool canvasKeyPressEvent(QKeyEvent *event)
Definition: Canvas.cc:925
Matrix get_children(void) const
Definition: graphics.h:2571
void canvasMouseMoveEvent(QMouseEvent *event)
Definition: Canvas.cc:399
std::string string_value(bool force=false) const
Definition: ov.h:897
bool m_clickMode
Definition: Canvas.h:114
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
static bool zoom_enabled(const graphics_object figObj)
Definition: Canvas.cc:363
double get_mousewheelzoom(void) const
Definition: graphics.h:5579
void canvasAutoAxes(const graphics_handle &handle)
Definition: Canvas.cc:287
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string get_ygrid(void) const
Definition: graphics.h:5665
QPoint m_mouseCurrent
Definition: Canvas.h:116
base_properties & get_properties(void)
Definition: graphics.h:3377
Definition: dMatrix.h:35
void zoom_about_point(const std::string &mode, double x, double y, double factor, bool push_to_zoom_stack=true)
Definition: graphics.cc:7732
MouseMode m_mouseMode
Definition: Canvas.h:113
graphics_object get_ancestor(const std::string &type) const
Definition: graphics.cc:3394
Matrix matrix_value(bool frc_str_conv=false) const
Definition: ov.h:773
std::string get_xgrid(void) const
Definition: graphics.h:5625
void canvasPaintEvent(void)
Definition: Canvas.cc:313
void set_xgrid(const octave_value &val)
Definition: graphics.h:6317
void canvasMouseReleaseEvent(QMouseEvent *event)
Definition: Canvas.cc:719
ColumnVector untransform(double x, double y, double z, bool use_scale=true) const
Definition: graphics.cc:6780
bool valid_object(void) const
Definition: graphics.h:3395
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:233
static Object * toolkitObject(const graphics_object &go)
Definition: Backend.cc:197
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
bool canvasKeyReleaseEvent(QKeyEvent *event)
Definition: Canvas.cc:952
octave_value_list ovl(const octave_value &a0)
Definition: oct-obj.h:178
ColumnVector pixel2coord(double px, double py) const
Definition: graphics.h:5175
virtual void draw(const graphics_handle &handle)=0
octave_scalar_map scalar_map_value(void) const
Definition: ov.cc:1591
#define octave_NaN
Definition: lo-ieee.h:37
void setCursor(MouseMode mode)
Definition: Canvas.cc:73
void set_xlimmode(const octave_value &val)
Definition: graphics.h:6346
void set_zlimmode(const octave_value &val)
Definition: graphics.h:6644
octave_handle graphics_handle
Definition: graphics.h:58
static bool pan_enabled(const graphics_object figObj)
Definition: Canvas.cc:327
Matrix get_all_children(void) const
Definition: graphics.h:2576
virtual graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)=0
void clear_zoom_stack(bool do_unzoom=true)
Definition: graphics.cc:8033
static Canvas * create(const std::string &name, QWidget *parent, const graphics_handle &handle)
Definition: Canvas.cc:966
static graphics_object get_object(double val)
Definition: graphics.h:13212
octave_value_list get_properties() const
MouseMode mouseMode(void)
Definition: Figure.cc:263
void annotation_callback(const octave_value_list &args)
Definition: Canvas.cc:201
static std::string pan_mode(const graphics_object figObj)
Definition: Canvas.cc:339
octave_value getfield(const std::string &key) const
Definition: oct-map.cc:164
OCTINTERP_API octave_value_list Ffeval(const octave_value_list &=octave_value_list(), int=0)
Definition: oct-parse.cc:8742
graphics_handle get_handle(void) const
Definition: graphics.h:3363
void set_ygrid(const octave_value &val)
Definition: graphics.h:6472
bool m_redrawBlocked
Definition: Canvas.h:112
static double button_number(QMouseEvent *event)
Definition: Canvas.cc:476
Matrix get_transform_zlim(void) const
Definition: graphics.h:5134
octave_value as_octave_value(void) const
Definition: oct-handle.h:72
static std::string zoom_mode(const graphics_object figObj)
Definition: Canvas.cc:375
void blockRedraw(bool block=true)
Definition: Canvas.cc:67
static void post_set(const graphics_handle &h, const std::string &name, const octave_value &value, bool notify_toolkit=true)
Definition: graphics.h:13343
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:210