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
octave-qt-link.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2015 John W. Eaton
4 Copyright (C) 2011-2015 Jacob Dawid
5 Copyright (C) 2011-2015 John P. Swensen
6 
7 This file is part of Octave.
8 
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifndef OCTAVE_QT_LINK_H
26 #define OCTAVE_QT_LINK_H
27 
28 #include <list>
29 #include <string>
30 
31 #include <QList>
32 #include <QObject>
33 #include <QString>
34 #include <QThread>
35 #include <QMutex>
36 #include <QWaitCondition>
37 
38 #include "octave-link.h"
39 #include "octave-interpreter.h"
40 
41 // Defined for purposes of sending QList<int> as part of signal.
43 
44 // @class OctaveLink
45 // @brief Provides threadsafe access to octave.
46 // @author Jacob Dawid
47 //
48 // This class is a wrapper around octave and provides thread safety by
49 // buffering access operations to octave and executing them in the
50 // readline event hook, which lives in the octave thread.
51 
52 class octave_qt_link : public QObject, public octave_link
53 {
54  Q_OBJECT
55 
56 public:
57 
59 
60  ~octave_qt_link (void);
61 
62  void execute_interpreter (void);
63 
64  bool do_confirm_shutdown (void);
65  bool do_exit (int status);
66 
67  bool do_copy_image_to_clipboard (const std::string& file);
68 
69  bool do_edit_file (const std::string& file);
70  bool do_prompt_new_edit_file (const std::string& file);
71 
72  int do_message_dialog (const std::string& dlg, const std::string& msg,
73  const std::string& title);
74 
75  std::string
76  do_question_dialog (const std::string& msg, const std::string& title,
77  const std::string& btn1, const std::string& btn2,
78  const std::string& btn3, const std::string& btndef);
79 
80  std::pair<std::list<int>, int>
81  do_list_dialog (const std::list<std::string>& list,
82  const std::string& mode,
83  int width, int height,
84  const std::list<int>& initial_value,
85  const std::string& name,
86  const std::list<std::string>& prompt,
87  const std::string& ok_string,
88  const std::string& cancel_string);
89 
90  std::list<std::string>
91  do_input_dialog (const std::list<std::string>& prompt,
92  const std::string& title,
93  const std::list<float>& nr,
94  const std::list<float>& nc,
95  const std::list<std::string>& defaults);
96 
97  std::list<std::string>
98  do_file_dialog (const filter_list& filter, const std::string& title,
99  const std::string &filename, const std::string &pathname,
100  const std::string& multimode);
101 
102  int
103  do_debug_cd_or_addpath_error (const std::string& file,
104  const std::string& dir,
105  bool addpath_option);
106 
107  void do_change_directory (const std::string& dir);
108 
109  void do_execute_command_in_terminal (const std::string& command);
110 
111  void do_set_workspace (bool top_level, bool debug,
112  const std::list<workspace_element>& ws);
113 
114  void do_clear_workspace (void);
115 
116  void do_set_history (const string_vector& hist);
117  void do_append_history (const std::string& hist_entry);
118  void do_clear_history (void);
119 
120  void do_pre_input_event (void);
121  void do_post_input_event (void);
122 
123  void do_enter_debugger_event (const std::string& file, int line);
124  void do_execute_in_debugger_event (const std::string& file, int line);
125  void do_exit_debugger_event (void);
126 
127  void do_update_breakpoint (bool insert, const std::string& file, int line);
128 
129  void do_set_default_prompts (std::string& ps1, std::string& ps2,
130  std::string& ps4);
131 
132  static bool file_in_path (const std::string& file, const std::string& dir);
133 
134  void do_show_preferences (void);
135 
136  void do_show_doc (const std::string& file);
137 
138  QMutex mutex;
139  QWaitCondition waitcondition;
141 
142  void update_directory (void);
143 
144 private:
145 
147 
149 
151 
152  void do_insert_debugger_pointer (const std::string& file, int line);
153  void do_delete_debugger_pointer (const std::string& file, int line);
154 
155  // Thread running octave_main.
157 
159 
161  bool _new_dir;
162 
163 signals:
164 
165  void execute_interpreter_signal (void);
166 
167  void copy_image_to_clipboard_signal (const QString& file, bool remove_file);
168 
169  void edit_file_signal (const QString& file);
170 
171  void change_directory_signal (const QString& dir);
172 
173  void execute_command_in_terminal_signal (const QString& command);
174 
175  void set_workspace_signal (bool top_level,
176  bool debug,
177  const QString& scopes,
178  const QStringList& symbols,
179  const QStringList& class_names,
180  const QStringList& dimensions,
181  const QStringList& values,
182  const QIntList& complex_flags);
183 
184  void clear_workspace_signal (void);
185 
186  void set_history_signal (const QStringList& hist);
187  void append_history_signal (const QString& hist_entry);
188  void clear_history_signal (void);
189 
190  void enter_debugger_signal (void);
191  void exit_debugger_signal (void);
192 
193  void update_breakpoint_marker_signal (bool insert, const QString& file,
194  int line);
195 
196  void insert_debugger_pointer_signal (const QString&, int);
197  void delete_debugger_pointer_signal (const QString&, int);
198 
199  void show_preferences_signal (void);
200 
201  void show_doc_signal (const QString &file);
202 
203  void confirm_shutdown_signal (void);
204  void exit_app_signal (int status);
205 
206 public slots:
207 
208  void terminal_interrupt (void);
209 };
210 
211 #endif
MArray< double > filter(MArray< double > &, MArray< double > &, MArray< double > &, int dim)
static bool debug
Definition: mkoctfile.cc:227
QList< int > QIntList
Definition: dialog.h:38