GNU Octave  4.2.1
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-2017 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 #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) { }
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),
87  m_eventMask (0),
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 
109  void select_object (graphics_object obj, QMouseEvent* event,
110  graphics_object &currentObj, graphics_object &axesObj,
111  bool axes_only = false,
112  std::vector<std::string> omit = std::vector<std::string> ());
113 
114  private:
118  bool m_clickMode; // True: ZoomIn, False: ZoomOut
124  };
125 
126 }
127 
128 #endif
graphics_handle m_mouseAxes
Definition: Canvas.h:121
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:375
MouseMode
Definition: Figure.h:39
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:6386
virtual void autoAxes(const graphics_handle &handle)=0
void setEventMask(int m)
Definition: Canvas.h:61
graphics_handle m_handle
Definition: Canvas.h:115
void updateCurrentPoint(const graphics_object &fig, const graphics_object &obj, QMouseEvent *event)
Definition: Canvas.cc:124
void addEventMask(int m)
Definition: Canvas.h:59
void print(const QString &file_cmd, const QString &term)
Definition: Canvas.cc:105
void redraw(bool sync=false)
Definition: Canvas.cc:54
void canvasToggleGrid(const graphics_handle &handle)
Definition: Canvas.cc:239
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
void canvasMouseDoubleClickEvent(QMouseEvent *event)
Definition: Canvas.cc:576
void canvasToggleAxes(const graphics_handle &handle)
Definition: Canvas.cc:210
JNIEnv void * args
Definition: ov-java.cc:67
void canvasMousePressEvent(QMouseEvent *event)
Definition: Canvas.cc:609
QPoint m_mouseAnchor
Definition: Canvas.h:119
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
void canvasWheelEvent(QWheelEvent *event)
Definition: Canvas.cc:888
bool canvasKeyPressEvent(QKeyEvent *event)
Definition: Canvas.cc:996
void canvasMouseMoveEvent(QMouseEvent *event)
Definition: Canvas.cc:477
bool m_clickMode
Definition: Canvas.h:118
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
void canvasAutoAxes(const graphics_handle &handle)
Definition: Canvas.cc:287
QPoint m_mouseCurrent
Definition: Canvas.h:120
is false
Definition: cellfun.cc:398
virtual ~Canvas(void)
Definition: Canvas.h:52
MouseMode m_mouseMode
Definition: Canvas.h:117
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:789
bool canvasKeyReleaseEvent(QKeyEvent *event)
Definition: Canvas.cc:1023
virtual void draw(const graphics_handle &handle)=0
void setCursor(MouseMode mode)
Definition: Canvas.cc:74
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:5342
static Canvas * create(const std::string &name, QWidget *parent, const graphics_handle &handle)
Definition: Canvas.cc:1037
void annotation_callback(const octave_value_list &args)
Definition: Canvas.cc:202
virtual void resize(int x, int y, int width, int height)=0
bool m_redrawBlocked
Definition: Canvas.h:116
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:854
void blockRedraw(bool block=true)
Definition: Canvas.cc:68
void clearEventMask(int m)
Definition: Canvas.h:60
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x