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.h
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 #ifndef __QtHandles_Canvas__
24 #define __QtHandles_Canvas__ 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) { }
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  void addEventMask (int m) { m_eventMask |= m; }
60  void clearEventMask (int m) { m_eventMask &= (~m); }
61  void setEventMask (int m) { m_eventMask = m; }
62 
63  void setCursor (MouseMode mode);
64 
65  virtual QWidget* qWidget (void) = 0;
66 
67  static Canvas* create (const std::string& name, QWidget* parent,
68  const graphics_handle& handle);
69 
70  virtual void toggleAxes (const graphics_handle& handle) = 0;
71  virtual void toggleGrid (const graphics_handle& handle) = 0;
72  virtual void autoAxes (const graphics_handle& handle) = 0;
73 
74 protected:
75  virtual void draw (const graphics_handle& handle) = 0;
76  virtual void drawZoomBox (const QPoint& p1, const QPoint& p2) = 0;
77  virtual void resize (int x, int y, int width, int height) = 0;
79  const QPoint& pt) = 0;
80 
81 protected:
82  Canvas (const graphics_handle& handle)
83  : m_handle (handle),
84  m_redrawBlocked (false),
86  m_clickMode (false),
87  m_eventMask (0),
88  m_rectMode (false)
89  { }
90 
91  void canvasToggleAxes (const graphics_handle& handle);
92  void canvasToggleGrid (const graphics_handle& handle);
93  void canvasAutoAxes (const graphics_handle& handle);
94  void canvasPaintEvent (void);
95  void canvasMouseDoubleClickEvent (QMouseEvent* event);
96  void canvasMouseMoveEvent (QMouseEvent* event);
97  void canvasMousePressEvent (QMouseEvent* event);
98  void canvasMouseReleaseEvent (QMouseEvent* event);
99  void canvasWheelEvent (QWheelEvent* event);
100  bool canvasKeyPressEvent (QKeyEvent* event);
101  bool canvasKeyReleaseEvent (QKeyEvent* event);
102 
103  void updateCurrentPoint (const graphics_object& fig,
104  const graphics_object& obj, QMouseEvent *event);
105  void updateCurrentPoint (const graphics_object& fig,
106  const graphics_object& obj);
107 
108  void annotation_callback (const octave_value_list& args);
109 
110 private:
114  bool m_clickMode; // True: ZoomIn, False: ZoomOut
120 };
121 
122 }; // namespace QtHandles
123 
124 #endif
graphics_handle m_mouseAxes
Definition: Canvas.h:117
virtual QWidget * qWidget(void)=0
MouseMode
Definition: Figure.h:38
virtual void autoAxes(const graphics_handle &handle)=0
void setEventMask(int m)
Definition: Canvas.h:61
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 addEventMask(int m)
Definition: Canvas.h:59
void print(const QString &file_cmd, const QString &term)
Definition: Canvas.cc:104
void redraw(bool sync=false)
Definition: Canvas.cc:53
void canvasToggleGrid(const graphics_handle &handle)
Definition: Canvas.cc:238
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
void canvasMouseDoubleClickEvent(QMouseEvent *event)
Definition: Canvas.cc:469
void canvasToggleAxes(const graphics_handle &handle)
Definition: Canvas.cc:209
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
void canvasMouseMoveEvent(QMouseEvent *event)
Definition: Canvas.cc:399
bool m_clickMode
Definition: Canvas.h:114
void canvasAutoAxes(const graphics_handle &handle)
Definition: Canvas.cc:287
QPoint m_mouseCurrent
Definition: Canvas.h:116
virtual ~Canvas(void)
Definition: Canvas.h:52
MouseMode m_mouseMode
Definition: Canvas.h:113
void canvasPaintEvent(void)
Definition: Canvas.cc:313
Canvas(const graphics_handle &handle)
Definition: Canvas.h:82
virtual void toggleAxes(const graphics_handle &handle)=0
virtual void toggleGrid(const graphics_handle &handle)=0
void canvasMouseReleaseEvent(QMouseEvent *event)
Definition: Canvas.cc:719
bool canvasKeyReleaseEvent(QKeyEvent *event)
Definition: Canvas.cc:952
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
static Canvas * create(const std::string &name, QWidget *parent, const graphics_handle &handle)
Definition: Canvas.cc:966
void annotation_callback(const octave_value_list &args)
Definition: Canvas.cc:201
virtual void resize(int x, int y, int width, int height)=0
bool m_redrawBlocked
Definition: Canvas.h:112
void blockRedraw(bool block=true)
Definition: Canvas.cc:67
void clearEventMask(int m)
Definition: Canvas.h:60
F77_RET_T const double * x