GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave-qt-link.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2018 John W. Eaton
4 Copyright (C) 2011-2018 Jacob Dawid
5 Copyright (C) 2011-2018 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
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License 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 <https://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if ! defined (octave_qt_link_h)
26 #define octave_qt_link_h 1
27 
28 #include <list>
29 #include <string>
30 
31 #include <QList>
32 #include <QObject>
33 #include <QString>
34 #include <QMutex>
35 #include <QWaitCondition>
36 
37 #include "octave-gui.h"
38 #include "octave-link.h"
39 
40 // Defined for purposes of sending QList<int> as part of signal.
42 
43 class octave_value;
44 
45 namespace octave
46 {
47 
48  //! Provides threadsafe access to octave.
49  //! @author Jacob Dawid
50  //!
51  //! This class is a wrapper around octave and provides thread safety by
52  //! buffering access operations to octave and executing them in the
53  //! readline event hook, which lives in the octave thread.
54 
55  class octave_qt_link : public QObject, public octave_link
56  {
57  Q_OBJECT
58 
59  public:
60 
61  octave_qt_link (QWidget *p, gui_application *app_context);
62 
63  // No copying!
64 
65  octave_qt_link (const octave_qt_link&) = delete;
66 
67  octave_qt_link& operator = (const octave_qt_link&) = delete;
68 
69  ~octave_qt_link (void) = default;
70 
71  bool do_confirm_shutdown (void);
72 
74 
75  bool do_edit_file (const std::string& file);
77 
78  int do_message_dialog (const std::string& dlg, const std::string& msg,
79  const std::string& title);
80 
82  do_question_dialog (const std::string& msg, const std::string& title,
83  const std::string& btn1, const std::string& btn2,
84  const std::string& btn3, const std::string& btndef);
85 
86  std::pair<std::list<int>, int>
87  do_list_dialog (const std::list<std::string>& list,
88  const std::string& mode,
89  int width, int height,
90  const std::list<int>& initial_value,
91  const std::string& name,
92  const std::list<std::string>& prompt,
93  const std::string& ok_string,
94  const std::string& cancel_string);
95 
96  std::list<std::string>
97  do_input_dialog (const std::list<std::string>& prompt,
98  const std::string& title,
99  const std::list<float>& nr,
100  const std::list<float>& nc,
101  const std::list<std::string>& defaults);
102 
103  std::list<std::string>
104  do_file_dialog (const filter_list& filter, const std::string& title,
105  const std::string& filename, const std::string& pathname,
106  const std::string& multimode);
107 
108  int
110  const std::string& dir,
111  bool addpath_option);
112 
113  void do_change_directory (const std::string& dir);
114 
116 
117  void do_set_workspace (bool top_level, bool debug,
118  const symbol_scope& scope,
119  bool update_variable_editor);
120 
121  void do_clear_workspace (void);
122 
123  void do_set_history (const string_vector& hist);
124  void do_append_history (const std::string& hist_entry);
125  void do_clear_history (void);
126 
127  void do_pre_input_event (void);
128  void do_post_input_event (void);
129 
130  void do_enter_debugger_event (const std::string& file, int line);
132  void do_exit_debugger_event (void);
133 
134  void do_update_breakpoint (bool insert, const std::string& file, int line,
135  const std::string& cond);
136 
138  std::string& ps4);
139 
140  static bool file_in_path (const std::string& file, const std::string& dir);
141 
142  void do_show_preferences (void);
143 
144  void do_show_doc (const std::string& file);
145  void do_register_doc (const std::string& file);
146  void do_unregister_doc (const std::string& file);
147 
148  void do_edit_variable (const std::string& name, const octave_value& val);
149 
151 
152  void lock (void) { m_mutex.lock (); }
153  void wait (void) { m_waitcondition.wait (&m_mutex); }
154  void unlock (void) { m_mutex.unlock (); }
155  void wake_all (void) { m_waitcondition.wakeAll (); }
156 
157  private:
158 
159  void do_insert_debugger_pointer (const std::string& file, int line);
160  void do_delete_debugger_pointer (const std::string& file, int line);
161 
163 
165 
166  QMutex m_mutex;
167  QWaitCondition m_waitcondition;
168 
169  signals:
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, bool debug,
180  const symbol_scope& scope);
181 
182  void clear_workspace_signal (void);
183 
184  void set_history_signal (const QStringList& hist);
185  void append_history_signal (const QString& hist_entry);
186  void clear_history_signal (void);
187 
188  void enter_debugger_signal (void);
189  void exit_debugger_signal (void);
190 
191  void update_breakpoint_marker_signal (bool insert, const QString& file,
192  int line, const QString& cond);
193 
194  void insert_debugger_pointer_signal (const QString&, int);
195  void delete_debugger_pointer_signal (const QString&, int);
196 
197  void show_preferences_signal (void);
198 
199  void show_doc_signal (const QString& file);
200 
201  void register_doc_signal (const QString& file);
202 
203  void unregister_doc_signal (const QString& file);
204 
205  void edit_variable_signal (const QString& name, const octave_value& val);
206 
207  void refresh_variable_editor_signal (void);
208 
209  void confirm_shutdown_signal (void);
210  };
211 }
212 
213 #endif
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
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:734
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
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
std::string filename
Definition: urlwrite.cc:121
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
static bool debug
nd deftypefn *std::string name
Definition: sysdep.cc:647
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
Definition: filter.cc:43
p
Definition: lu.cc:138
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