GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Canvas.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_Canvas_h)
24 #define octave_Canvas_h 1
25 
26 #include <QPoint>
27 
28 #include "graphics.h"
29 
30 #include "Figure.h"
31 
32 class QKeyEvent;
33 class QMouseEvent;
34 class QWheelEvent;
35 class QWidget;
36 
37 class octave_value_list;
38 
39 namespace QtHandles
40 {
41 
42  class Canvas
43  {
44  public:
45  enum EventMask
46  {
47  KeyPress = 0x01,
48  KeyRelease = 0x02
49  };
50 
51  public:
52  virtual ~Canvas (void) = default;
53 
54  void redraw (bool sync = false);
55  void blockRedraw (bool block = true);
56 
57  void print (const QString& file_cmd, const QString& term)
58  {
59  do_print (file_cmd, term, m_handle);
60  }
61 
62  void addEventMask (int m) { m_eventMask |= m; }
63  void clearEventMask (int m) { m_eventMask &= (~m); }
64  void setEventMask (int m) { m_eventMask = m; }
65 
66  void setCursor (MouseMode mode);
67 
68  virtual QWidget * qWidget (void) = 0;
69 
70  static Canvas * create (const std::string& name, QWidget *parent,
71  const graphics_handle& handle);
72 
73  virtual void toggleAxes (const graphics_handle& handle) = 0;
74  virtual void toggleGrid (const graphics_handle& handle) = 0;
75  virtual void autoAxes (const graphics_handle& handle) = 0;
76 
77  virtual uint8NDArray getPixels (void) { return do_getPixels (m_handle); };
78 
79  protected:
80  virtual void draw (const graphics_handle& handle) = 0;
81  virtual void drawZoomBox (const QPoint& p1, const QPoint& p2) = 0;
82  virtual void resize (int x, int y, int width, int height) = 0;
84  const QPoint& pt) = 0;
85  virtual uint8NDArray do_getPixels (const graphics_handle& handle) = 0;
86  virtual void do_print (const QString& file_cmd, const QString& term,
87  const graphics_handle& handle) = 0;
88 
89  protected:
91  : m_handle (handle),
95  m_eventMask (0),
97  { }
98 
101  void canvasAutoAxes (const graphics_handle& handle);
102  void canvasPaintEvent (void);
103  void canvasMouseDoubleClickEvent (QMouseEvent *event);
104  void canvasMouseMoveEvent (QMouseEvent *event);
105  void canvasMousePressEvent (QMouseEvent *event);
106  void canvasMouseReleaseEvent (QMouseEvent *event);
107  void canvasWheelEvent (QWheelEvent *event);
108  bool canvasKeyPressEvent (QKeyEvent *event);
109  bool canvasKeyReleaseEvent (QKeyEvent *event);
110 
111  void updateCurrentPoint (const graphics_object& fig,
112  const graphics_object& obj, QMouseEvent *event);
113  void updateCurrentPoint (const graphics_object& fig,
114  const graphics_object& obj);
115 
116  void annotation_callback (const octave_value_list& args);
117  void select_object (graphics_object obj, QMouseEvent *event,
118  graphics_object& currentObj, graphics_object& axesObj,
119  bool axes_only = false,
120  std::vector<std::string> omit = std::vector<std::string> ());
121 
122  private:
126  bool m_clickMode; // True: ZoomIn, False: ZoomOut
132  };
133 
134 }
135 
136 #endif
graphics_handle m_mouseAxes
Definition: Canvas.h:129
virtual QWidget * qWidget(void)=0
void select_object(graphics_object obj, QMouseEvent *event, graphics_object &currentObj, graphics_object &axesObj, bool axes_only=false, std::vector< std::string > omit=std::vector< std::string >())
Definition: Canvas.cc:360
MouseMode
Definition: Figure.h:39
virtual void do_print(const QString &file_cmd, const QString &term, const graphics_handle &handle)=0
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6348
virtual void autoAxes(const graphics_handle &handle)=0
void setEventMask(int m)
Definition: Canvas.h:64
graphics_handle m_handle
Definition: Canvas.h:123
void updateCurrentPoint(const graphics_object &fig, const graphics_object &obj, QMouseEvent *event)
Definition: Canvas.cc:109
void addEventMask(int m)
Definition: Canvas.h:62
void print(const QString &file_cmd, const QString &term)
Definition: Canvas.h:57
void redraw(bool sync=false)
Definition: Canvas.cc:53
void canvasToggleGrid(const graphics_handle &handle)
Definition: Canvas.cc:224
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
void canvasMouseDoubleClickEvent(QMouseEvent *event)
Definition: Canvas.cc:561
void canvasToggleAxes(const graphics_handle &handle)
Definition: Canvas.cc:195
void canvasMousePressEvent(QMouseEvent *event)
Definition: Canvas.cc:594
QPoint m_mouseAnchor
Definition: Canvas.h:127
nd deftypefn *std::string name
Definition: sysdep.cc:647
void canvasWheelEvent(QWheelEvent *event)
Definition: Canvas.cc:903
bool canvasKeyPressEvent(QKeyEvent *event)
Definition: Canvas.cc:1016
void canvasMouseMoveEvent(QMouseEvent *event)
Definition: Canvas.cc:462
virtual uint8NDArray getPixels(void)
Definition: Canvas.h:77
bool m_clickMode
Definition: Canvas.h:126
void canvasAutoAxes(const graphics_handle &handle)
Definition: Canvas.cc:272
QPoint m_mouseCurrent
Definition: Canvas.h:128
is false
Definition: cellfun.cc:400
MouseMode m_mouseMode
Definition: Canvas.h:125
void canvasPaintEvent(void)
Definition: Canvas.cc:298
Canvas(const graphics_handle &handle)
Definition: Canvas.h:90
virtual void toggleAxes(const graphics_handle &handle)=0
virtual void toggleGrid(const graphics_handle &handle)=0
void canvasMouseReleaseEvent(QMouseEvent *event)
Definition: Canvas.cc:804
bool canvasKeyReleaseEvent(QKeyEvent *event)
Definition: Canvas.cc:1043
virtual void draw(const graphics_handle &handle)=0
void setCursor(MouseMode mode)
Definition: Canvas.cc:73
virtual graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)=0
the element is set to zero In other the statement xample y
Definition: data.cc:5264
virtual uint8NDArray do_getPixels(const graphics_handle &handle)=0
static Canvas * create(const std::string &name, QWidget *parent, const graphics_handle &handle)
Definition: Canvas.cc:1057
void annotation_callback(const octave_value_list &args)
Definition: Canvas.cc:187
virtual void resize(int x, int y, int width, int height)=0
bool m_redrawBlocked
Definition: Canvas.h:124
is a function handle
Definition: bsxfun.cc:337
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
void blockRedraw(bool block=true)
Definition: Canvas.cc:67
void clearEventMask(int m)
Definition: Canvas.h:63
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
virtual ~Canvas(void)=default