GNU Octave  3.8.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 John W. Eaton
4 Copyright (C) 2011-2013 Jacob Dawid
5 Copyright (C) 2011-2013 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 
36 #include "octave-link.h"
37 #include "octave-interpreter.h"
38 
39 // Defined for purposes of sending QList<int> as part of signal.
41 
42 // \class OctaveLink
43 // \brief Provides threadsafe access to octave.
44 // \author Jacob Dawid
45 //
46 // This class is a wrapper around octave and provides thread safety by
47 // buffering access operations to octave and executing them in the
48 // readline event hook, which lives in the octave thread.
49 
50 class octave_qt_link : public QObject, public octave_link
51 {
52  Q_OBJECT
53 
54 public:
55 
56  octave_qt_link (void);
57 
58  ~octave_qt_link (void);
59 
60  void execute_interpreter (void);
61 
62  bool do_exit (int status);
63 
64  bool do_edit_file (const std::string& file);
65  bool do_prompt_new_edit_file (const std::string& file);
66 
67  int do_message_dialog (const std::string& dlg, const std::string& msg,
68  const std::string& title);
69 
70  std::string
71  do_question_dialog (const std::string& msg, const std::string& title,
72  const std::string& btn1, const std::string& btn2,
73  const std::string& btn3, const std::string& btndef);
74 
75  std::pair<std::list<int>, int>
76  do_list_dialog (const std::list<std::string>& list,
77  const std::string& mode,
78  int width, int height,
79  const std::list<int>& initial_value,
80  const std::string& name,
81  const std::list<std::string>& prompt,
82  const std::string& ok_string,
83  const std::string& cancel_string);
84 
85  std::list<std::string>
86  do_input_dialog (const std::list<std::string>& prompt,
87  const std::string& title,
88  const std::list<float>& nr,
89  const std::list<float>& nc,
90  const std::list<std::string>& defaults);
91 
92  std::list<std::string>
93  do_file_dialog (const filter_list& filter, const std::string& title,
94  const std::string &filename, const std::string &pathname,
95  const std::string& multimode);
96 
97  int
98  do_debug_cd_or_addpath_error (const std::string& file,
99  const std::string& dir,
100  bool addpath_option);
101 
102  void do_change_directory (const std::string& dir);
103 
104  void do_execute_command_in_terminal (const std::string& command);
105 
106  void do_set_workspace (bool top_level,
107  const std::list<workspace_element>& ws);
108 
109  void do_clear_workspace (void);
110 
111  void do_set_history (const string_vector& hist);
112  void do_append_history (const std::string& hist_entry);
113  void do_clear_history (void);
114 
115  void do_pre_input_event (void);
116  void do_post_input_event (void);
117 
118  void do_enter_debugger_event (const std::string& file, int line);
119  void do_execute_in_debugger_event (const std::string& file, int line);
120  void do_exit_debugger_event (void);
121 
122  void do_update_breakpoint (bool insert, const std::string& file, int line);
123 
124  void do_set_default_prompts (std::string& ps1, std::string& ps2,
125  std::string& ps4);
126 
127  static bool file_in_path (const std::string& file, const std::string& dir);
128 
129  void do_show_preferences (void);
130 
131  void do_show_doc (const std::string& file);
132 
133 private:
134 
135  // No copying!
136 
138 
140 
141  void do_insert_debugger_pointer (const std::string& file, int line);
142  void do_delete_debugger_pointer (const std::string& file, int line);
143 
144  // Thread running octave_main.
146 
148 
149 signals:
150 
151  void execute_interpreter_signal (void);
152 
153  void exit_signal (int status);
154 
155  void edit_file_signal (const QString& file);
156 
157  void change_directory_signal (const QString& dir);
158 
159  void execute_command_in_terminal_signal (const QString& command);
160 
161  void set_workspace_signal (bool top_level,
162  const QString& scopes,
163  const QStringList& symbols,
164  const QStringList& class_names,
165  const QStringList& dimensions,
166  const QStringList& values,
167  const QIntList& complex_flags);
168 
169  void clear_workspace_signal (void);
170 
171  void set_history_signal (const QStringList& hist);
172  void append_history_signal (const QString& hist_entry);
173  void clear_history_signal (void);
174 
175  void enter_debugger_signal (void);
176  void exit_debugger_signal (void);
177 
178  void update_breakpoint_marker_signal (bool insert, const QString& file,
179  int line);
180 
181  void insert_debugger_pointer_signal (const QString&, int);
182  void delete_debugger_pointer_signal (const QString&, int);
183 
184  void show_preferences_signal (void);
185 
186  void show_doc_signal (const QString &file);
187 
188 public slots:
189 
190  void terminal_interrupt (void);
191 };
192 
193 #endif