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
octave-qt-link.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2017 John W. Eaton
4 Copyright (C) 2011-2016 Jacob Dawid
5 Copyright (C) 2011-2016 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 #if ! defined (octave_octave_qt_link_h)
26 #define octave_octave_qt_link_h 1
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-gui.h"
39 #include "octave-link.h"
40 #include "octave-interpreter.h"
41 
42 // Defined for purposes of sending QList<int> as part of signal.
44 
45 // @class OctaveLink
46 // @brief Provides threadsafe access to octave.
47 // @author Jacob Dawid
48 //
49 // This class is a wrapper around octave and provides thread safety by
50 // buffering access operations to octave and executing them in the
51 // readline event hook, which lives in the octave thread.
52 
53 class octave_qt_link : public QObject, public octave_link
54 {
55  Q_OBJECT
56 
57 public:
58 
60 
61  ~octave_qt_link (void);
62 
63  void execute_interpreter (void);
64 
65  bool do_confirm_shutdown (void);
66  bool do_exit (int status);
67 
69 
70  bool do_edit_file (const std::string& file);
71  bool do_prompt_new_edit_file (const std::string& file);
72 
73  int do_message_dialog (const std::string& dlg, const std::string& msg,
74  const std::string& title);
75 
77  do_question_dialog (const std::string& msg, const std::string& title,
78  const std::string& btn1, const std::string& btn2,
79  const std::string& btn3, const std::string& btndef);
80 
81  std::pair<std::list<int>, int>
82  do_list_dialog (const std::list<std::string>& list,
83  const std::string& mode,
84  int width, int height,
85  const std::list<int>& initial_value,
86  const std::string& name,
87  const std::list<std::string>& prompt,
88  const std::string& ok_string,
89  const std::string& cancel_string);
90 
91  std::list<std::string>
92  do_input_dialog (const std::list<std::string>& prompt,
93  const std::string& title,
94  const std::list<float>& nr,
95  const std::list<float>& nc,
96  const std::list<std::string>& defaults);
97 
98  std::list<std::string>
99  do_file_dialog (const filter_list& filter, const std::string& title,
100  const std::string &filename, const std::string &pathname,
101  const std::string& multimode);
102 
103  int
105  const std::string& dir,
106  bool addpath_option);
107 
108  void do_change_directory (const std::string& dir);
109 
111 
112  void do_set_workspace (bool top_level, bool debug,
113  const std::list<workspace_element>& ws);
114 
115  void do_clear_workspace (void);
116 
117  void do_set_history (const string_vector& hist);
118  void do_append_history (const std::string& hist_entry);
119  void do_clear_history (void);
120 
121  void do_pre_input_event (void);
122  void do_post_input_event (void);
123 
124  void do_enter_debugger_event (const std::string& file, int line);
125  void do_execute_in_debugger_event (const std::string& file, int line);
126  void do_exit_debugger_event (void);
127 
128  void do_update_breakpoint (bool insert, const std::string& file, int line,
129  const std::string& cond);
130 
132  std::string& ps4);
133 
134  static bool file_in_path (const std::string& file, const std::string& dir);
135 
136  void do_show_preferences (void);
137 
138  void do_show_doc (const std::string& file);
139 
140  QMutex mutex;
141  QWaitCondition waitcondition;
143 
144  void update_directory (void);
145 
146 private:
147 
149 
151 
153 
154  void do_insert_debugger_pointer (const std::string& file, int line);
155  void do_delete_debugger_pointer (const std::string& file, int line);
156 
157  // Thread running octave_main.
159 
161 
163 
165  bool _new_dir;
166 
167 signals:
168 
169  void execute_interpreter_signal (void);
170 
171  void copy_image_to_clipboard_signal (const QString& file, bool remove_file);
172 
173  void edit_file_signal (const QString& file);
174 
175  void change_directory_signal (const QString& dir);
176 
177  void execute_command_in_terminal_signal (const QString& command);
178 
179  void set_workspace_signal (bool top_level,
180  bool debug,
181  const QString& scopes,
182  const QStringList& symbols,
183  const QStringList& class_names,
184  const QStringList& dimensions,
185  const QStringList& values,
186  const QIntList& complex_flags);
187 
188  void clear_workspace_signal (void);
189 
190  void set_history_signal (const QStringList& hist);
191  void append_history_signal (const QString& hist_entry);
192  void clear_history_signal (void);
193 
194  void enter_debugger_signal (void);
195  void exit_debugger_signal (void);
196 
197  void update_breakpoint_marker_signal (bool insert, const QString& file,
198  int line, const QString& cond);
199 
200  void insert_debugger_pointer_signal (const QString&, int);
201  void delete_debugger_pointer_signal (const QString&, int);
202 
203  void show_preferences_signal (void);
204 
205  void show_doc_signal (const QString &file);
206 
207  void confirm_shutdown_signal (void);
208  void exit_app_signal (int status);
209 
210 public slots:
211 
212  void terminal_interrupt (void);
213 };
214 
215 #endif
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition: oct-hist.cc:728
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
std::string filename
Definition: urlwrite.cc:340
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any simply delete all the lines from the buffer before leaving the editor When invoked with no edit the previously executed command
Definition: oct-hist.cc:587
cell array If invoked with two or more scalar integer or a vector of integer values
Definition: ov-cell.cc:1205
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
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
Definition: filter.cc:43
static bool debug
Definition: mkoctfile.cc:239
p
Definition: lu.cc:138
QList< int > QIntList
Definition: dialog.h:38
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