-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFitsbenchMain.h
More file actions
187 lines (159 loc) · 7.77 KB
/
FitsbenchMain.h
File metadata and controls
187 lines (159 loc) · 7.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef __FitsbenchMain_H
#define __FitsbenchMain_H
/*
* Copyright (c) 2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include <qapplication.h>
# include "ui_fitsbench.h"
# include "FitsbenchItem.h"
# include <tcl.h>
class FitsbenchMain : public QMainWindow {
Q_OBJECT
public:
FitsbenchMain(QWidget*parent =0);
~FitsbenchMain();
private:
// The user interface...
Ui::FitsbenchMainWidget ui;
void closeEvent(QCloseEvent*);
// For the TCL engine, keep a map of script names to
// scriptables. The user manipulates this map by setting or
// changing the "script name" for the bench item.
std::map<std::string, FitsbenchItem*> script_names_;
void set_bench_script_name_(FitsbenchItem*item, const QString&name);
// Clear the script names for this item and all its children.
void clear_bench_script_names_(FitsbenchItem*item);
// Convenience function for getting an item from the script
// name. If there is no item with the name, return 0.
FitsbenchItem* item_from_name_(const std::string&nam) const;
FitsbenchItem* item_from_name_(Tcl_Obj*obj) const;
// Locate or create a DataArray with the given script name. If
// the name is a work/path string, then create the image in
// the WorkFolder. Otherwise, create a ScratchImage with the
// same name.
DataArray* image_from_name_(const std::string&nam);
DataArray* image_from_name_(Tcl_Obj*obj);
// Similar to above, but in this case the image *must* be of
// the form work/file.
WorkFolder::Image* workitem_from_name_(Tcl_Obj*obj) const;
// Convenience function for getting the existing folder for
// the name. The name part is returned to the nam argument.
WorkFolder* workfolder_from_name_(const QString&path, QString&nam) const;
WorkFolder* workfolder_from_name_(Tcl_Obj*obj, QString&nam) const;
void bench_tree_delete_item_(FitsbenchItem*item);
private:
// The TCL engine...
Tcl_Interp*tcl_engine_;
Tcl_Channel tcl_stdout_;
void run_command_string_(const QString&script);
std::vector<long> vector_from_listobj_(Tcl_Obj*obj);
Tcl_Obj* listobj_from_vector_(const std::vector<long>&axes);
Tcl_Obj* listobj_from_vector_(const std::vector<double>&axes);
static Tcl_ChannelType tcl_stdout_type_;
char tcl_stdout_linebuf_[2048];
size_t tcl_stdout_linebuf_fill_;
// Imlementations of TCL I/O functions...
int tcl_stdout_closeProc_(Tcl_Interp*);
int tcl_stdout_inputProc_(char*, int, int*);
int tcl_stdout_outputProc_(const char*buf, int toWrite, int*err);
void tcl_stdout_watchProc_(int);
int tcl_stdout_getHandleProc_(int, ClientData*);
static int tcl_stdout_close_thunk_(ClientData, Tcl_Interp*);
static int tcl_stdout_input_thunk_(ClientData, char*, int, int*);
static int tcl_stdout_output_thunk_(ClientData, CONST char*, int, int*);
static void tcl_stdout_watch_thunk_(ClientData, int);
static int tcl_stdout_getHandle_thunk_(ClientData, int, ClientData*);
// Implementations of TCL commands...
int ftcl_bench_(int objc, Tcl_Obj*const objv[]);
int ftcl_axes_(int objc, Tcl_Obj*const objv[]);
int ftcl_bayer_decompose_(int objc, Tcl_Obj*const objv[]);
int ftcl_choose_file_(int objc, Tcl_Obj*const objv[]);
int ftcl_choose_one_(int objc, Tcl_Obj*const objv[]);
int ftcl_copy_(int objc, Tcl_Obj*const objv[]);
int ftcl_crop_(int objc, Tcl_Obj*const objv[]);
int ftcl_define_action_(int objc, Tcl_Obj*const objv[]);
int ftcl_fill_(int objc, Tcl_Obj*const objv[]);
int ftcl_folder_(int objc, Tcl_Obj*const objv[]);
int ftcl_image_(int objc, Tcl_Obj*const objv[]);
int ftcl_import_(int objc, Tcl_Obj*const objv[]);
int ftcl_scratch_(int objc, Tcl_Obj*const objv[]);
int ftcl_minmax_(int objc, Tcl_Obj*const objv[]);
int ftcl_normalize_(int objc, Tcl_Obj*const objv[]);
int ftcl_phase_corr_(int objc, Tcl_Obj*const objv[]);
int ftcl_pixbin_(int objc, Tcl_Obj*const objv[]);
int ftcl_stack_(int objc, Tcl_Obj*const objv[]);
int ftcl_table_(int objc, Tcl_Obj*const objv[]);
// Stubs to convert the Tcl interpreter's call to the command
// back to a method of this object.
static int ftcl_bench_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_axes_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_bayer_decomp_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_choose_file_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_choose_one_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_copy_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_crop_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_define_action_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_fill_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_folder_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_image_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_import_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_scratch_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_minmax_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_normalize_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_phase_corr_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_pixbin_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_stack_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static int ftcl_table_thunk_(ClientData obj, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[]);
static const struct ftcl_command_table {
const char*name;
int (*thunk) (ClientData, Tcl_Interp*, int objc, Tcl_Obj*CONST objv[]);
} ftcl_commands[];
private slots:
// Menu actions
void action_OpenImage_slot_(void);
void action_OpenFITSBench_Work_Folder_slot_(void);
void action_FITS_File_slot_(void);
void action_FITSBench_Work_Folder_slot_(void);
void action_Open_TCL_Script_slot_(void);
void defined_action_slot_(QAction*);
// Slots to handle widget signals
void bench_tree_clicked_slot_(QTreeWidgetItem*, int);
void bench_tree_activated_slot_(QTreeWidgetItem*, int);
void bench_tree_custom_menu_slot_(const QPoint&);
void commands_line_slot_(void);
};
#endif