Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1// This program is free software; you can redistribute it and/or
2// modify it under the terms of the GNU General Public License
3// as published by the Free Software Foundation; either version 2
4// of the License, or (at your option) any later version.
5
6// This program is distributed in the hope that it will be useful,
7// but WITHOUT ANY WARRANTY; without even the implied warranty of
8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9// GNU General Public License for more details.
10
11// You should have received a copy of the GNU General Public License
12// along with this program; if not, write to the Free Software
13// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14
20
21#ifndef _APP_H
22#define _APP_H
23
28enum {
29 ID_TOOL_FIRST = wxID_HIGHEST+1, // resulted in wrong events being fired
49#ifdef WITH_PSLOPE
50 ID_TOOL_PSLOPE,
51#endif
58
61#ifdef WITH_PYTHON
63#endif
80#ifdef WITH_PSLOPE
81 ID_VIEW_PSLOPE,
82#endif
117#if 0
118 ID_LATENCYSTART_MAXSLOPE,
119 ID_LATENCYSTART_HALFRISE,
120 ID_LATENCYSTART_PEAK,
121 ID_LATENCYSTART_MANUAL,
122 ID_LATENCYEND_FOOT,
123 ID_LATENCYEND_MAXSLOPE,
124 ID_LATENCYEND_HALFRISE,
125 ID_LATENCYEND_PEAK,
126 ID_LATENCYEND_MANUAL,
127 ID_LATENCYWINDOW,
128#endif
172#ifdef WITH_PYTHON
173 ID_USERDEF, // this should be the last ID event
174#endif
175};
176
177#include <list>
178
179#include <wx/mdi.h>
180#include <wx/docview.h>
181#include <wx/docmdi.h>
182#include <wx/fileconf.h>
183#include <wx/settings.h>
184
185#include "./../stf.h"
187
188#ifdef WITH_PYTHON
189
190#ifdef _POSIX_C_SOURCE
191#define _POSIX_C_SOURCE_WAS_DEF
192#undef _POSIX_C_SOURCE
193#endif
194#ifdef _XOPEN_SOURCE
195#define _XOPEN_SOURCE_WAS_DEF
196#undef _XOPEN_SOURCE
197#endif
198#include <Python.h>
199#ifdef _POSIX_C_SOURCE_WAS_DEF
200 #ifndef _POSIX_C_SOURCE
201 #define _POSIX_C_SOURCE
202 #endif
203#endif
204#ifdef _XOPEN_SOURCE_WAS_DEF
205 #ifndef _XOPEN_SOURCE
206 #define _XOPEN_SOURCE
207 #endif
208#endif
209
210#if defined(__WXMAC__) || defined(__WXGTK__)
211 #pragma GCC diagnostic ignored "-Wwrite-strings"
212#endif
213#ifdef WITH_PYTHON
214#if PY_MAJOR_VERSION >= 3
215 #include "../sip.h"
216 #include <wxPython/wxpy_api.h>
217#else
218 #include <wx/wxPython/wxPython.h>
219#endif
220#endif
221// revert to previous behaviour
222#if defined(__WXMAC__) || defined(__WXGTK__)
223 #pragma GCC diagnostic warning "-Wwrite-strings"
224#endif
225
226#endif // WITH_PYTHON
227
228#if (__cplusplus < 201103)
229 #include <boost/shared_ptr.hpp>
230#endif
231
232class wxDocManager;
233class wxStfDoc;
234class wxStfView;
235class wxStfCursorsDlg;
236class wxStfParentFrame;
237class wxStfChildFrame;
238class Section;
239
241
246class StfDll wxStfApp: public wxApp
247{
248public:
251
253
260 virtual bool OnInit();
261
263
266 virtual int OnExit();
267
269
277
279
282
284
287
289
293 void ErrorMsg(const wxString& msg) const {
294 wxMessageBox(msg,wxT("An error has occured"),wxOK | wxICON_EXCLAMATION,NULL);
295 }
296
298
302 void ExceptMsg(const wxString& msg) const {
303 wxMessageBox(msg,wxT("An exception was caught"),wxOK | wxICON_HAND,NULL);
304 }
305
307
311 void InfoMsg(const wxString& msg) const {
312 wxMessageBox(msg,wxT("Information"), wxOK | wxICON_INFORMATION, NULL);
313 }
314
316
318 bool get_directTxtImport() const { return directTxtImport; }
319
321
323 void set_directTxtImport(bool directTxtImport_) {
324 directTxtImport=directTxtImport_;
325 }
326
328
331 return txtImport;
332 }
333
335
338 txtImport=txtImport_;
339 }
340
342
344 const std::vector<stfnum::storedFunc>& GetFuncLib() const { return funcLib; }
345
346
348
350 stfnum::storedFunc* GetFuncLibPtr(std::size_t at) { return &funcLib.at(at); }
351
352
354
356 stfnum::storedFunc* GetLinFuncPtr( ) { return &storedLinFunc; }
357
358#ifdef WITH_PYTHON
360
362 const std::vector< stf::Extension >& GetExtensionLib() const { return extensionLib; }
363#endif
364
366
368 wxStfCursorsDlg* GetCursorsDialog() const { return CursorsDialog; }
369
371
373 std::vector<stf::SectionPointer> GetSectionsWithFits() const;
374
376
380 void wxWriteProfileInt(const wxString& main,const wxString& sub, int value) const;
381
383
389 int wxGetProfileInt(const wxString& main,const wxString& sub, int default_) const;
390
392
397 const wxString& main, const wxString& sub, const wxString& value ) const;
398
400
407 const wxString& main, const wxString& sub, const wxString& default_ ) const;
408
410
416 const Recording& NewData,
417 const wxStfDoc* Sender,
418 const wxString& title = wxT("\0")
419 );
420
422
426 void OnPeakcalcexecMsg(wxStfDoc* actDoc = 0);
427
429
431 void SetMRActiveDoc(wxStfDoc* pDoc) {mrActiveDoc = pDoc;}
432
434
438
440 bool CloseAll() { return GetDocManager()->CloseDocuments(); }
441
443
446 bool OpenFileSeries(const wxArrayString& fNameArray);
447
449
451 int GetDocCount() { return (int)GetDocManager()->GetDocuments().GetCount(); }
452
454
456 void set_isBars(bool value) { isBars=value; }
457
459
461 bool get_isBars() const { return isBars; }
462
464
467
469
472
474
476 wxDocManager* GetDocManager() const { return wxDocManager::GetDocumentManager(); }
477
478 wxStfParentFrame* GetMainFrame() {return (wxStfParentFrame*)GetTopWindow();}
479
480 virtual void OnInitCmdLine(wxCmdLineParser& parser);
481 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
482
483#ifdef WITH_PYTHON
485
488 bool OpenFilePy(const wxString& fNameArray);
489
491
494#endif
495
496protected:
497
498private:
499 void OnCursorSettings( wxCommandEvent& event );
500 void OnNewfromall( wxCommandEvent& event );
501 void OnApplytoall( wxCommandEvent& event );
502 void OnProcessCustom( wxCommandEvent& event );
503 void OnKeyDown( wxKeyEvent& event );
504
505#ifdef WITH_PYTHON
506 void ImportPython(const wxString& modulelocation);
507 void OnUserdef(wxCommandEvent& event);
508 bool Init_wxPython();
509 bool Exit_wxPython();
510 std::vector<stf::Extension> LoadExtensions();
511#endif // WITH_PYTHON
512
513 wxMenuBar* CreateUnifiedMenuBar(wxStfDoc* doc=NULL);
514
515#ifdef _WINDOWS
516#pragma optimize( "", off )
517#endif
518
519#ifdef _WINDOWS
520#pragma optimize( "", on )
521#endif
522
523 bool directTxtImport,isBars;
524 stfio::txtImportSettings txtImport;
525 // Registry:
526#if (__cplusplus < 201103)
527 boost::shared_ptr<wxFileConfig> config;
528#else
529 std::shared_ptr<wxFileConfig> config;
530#endif
531
532 std::vector<stfnum::storedFunc> funcLib;
533#ifdef WITH_PYTHON
534 std::vector< stf::Extension > extensionLib;
535#endif
536 // Pointer to the cursors settings dialog box
537 wxStfCursorsDlg* CursorsDialog;
538 wxDocTemplate* m_cfsTemplate, *m_hdf5Template, *m_txtTemplate,*m_abfTemplate,
539 *m_atfTemplate,*m_axgTemplate,*m_sonTemplate, *m_hekaTemplate, *m_intanTemplate, *m_tdmsTemplate, *m_biosigTemplate;
540 stfnum::storedFunc storedLinFunc;
541 // wxMenu* m_file_menu;
542 wxString m_fileToLoad;
543 /*std::list<wxStfDoc *> activeDoc;*/
544 wxStfDoc* mrActiveDoc;
545
546#ifdef WITH_PYTHON
547 PyThreadState* m_mainTState;
548#endif
549
550 DECLARE_EVENT_TABLE()
551};
552
553#ifdef _WINDOWS
556#else
557DECLARE_APP(wxStfApp)
558#endif
559
561extern bool singleWindowMode;
562
564
565#endif
566
Represents the data within a file.
Definition recording.h:44
Represents a continuously sampled sweep of data points.
Definition section.h:36
See http://www.wxwidgets.org/manuals/stable/wx_wxapp.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxcommandevent.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxdocument.html (wxWidgets documentation)
The application, derived from wxApp.
Definition app.h:247
Provides the child frame for displaying documents on separate windows.
Definition childframe.h:63
Cursor settings non-modal dialog.
Definition cursorsdlg.h:40
The document class, derived from both wxDocument and Recording.
Definition doc.h:35
Provides the top-level frame.
Definition parentframe.h:64
The view class, derived from wxView.
Definition view.h:39
See http://www.wxwidgets.org/manuals/stable/wx_wxstring.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxview.html (wxWidgets documentation)
int GetDocCount()
Returns the number of currently opened documents.
Definition app.h:451
int wxGetProfileInt(const wxString &main, const wxString &sub, int default_) const
Retrieves an integer value from the configuration.
wxStfParentFrame * GetMainFrame()
Definition app.h:478
virtual bool OnInit()
Initialise the application.
bool singleWindowMode
true if in single-window mode
void ErrorMsg(const wxString &msg) const
Displays a message box when an error has occured.
Definition app.h:293
void wxWriteProfileInt(const wxString &main, const wxString &sub, int value) const
Writes an integer value to the configuration.
const stfio::txtImportSettings & GetTxtImport() const
Retrieves the text import filter settings.
Definition app.h:330
wxString GetVersionString() const
Get a formatted version string.
void wxWriteProfileString(const wxString &main, const wxString &sub, const wxString &value) const
Writes a string to the configuration.
wxStfDoc * NewChild(const Recording &NewData, const wxStfDoc *Sender, const wxString &title=wxT("\0"))
Creates a new child window showing a new document.
void set_txtImportSettings(const stfio::txtImportSettings &txtImport_)
Sets the text import filter settings.
Definition app.h:337
wxStfCursorsDlg * GetCursorsDialog() const
Retrieves the cursor settings dialog.
Definition app.h:368
void OnPeakcalcexecMsg(wxStfDoc *actDoc=0)
Execute all pending calculations.
wxDocManager * GetDocManager() const
Access the document manager.
Definition app.h:476
wxStfApp()
Constructor.
stfnum::storedFunc * GetFuncLibPtr(std::size_t at)
Retrieves a pointer to a function for least-squares minimisation.
Definition app.h:350
bool get_isBars() const
Indicates whether scale bars or coordinates are shown.
Definition app.h:461
StfDll wxStfApp & wxGetApp()
Returns a reference to the application.
virtual void OnInitCmdLine(wxCmdLineParser &parser)
virtual bool OnCmdLineParsed(wxCmdLineParser &parser)
bool CloseAll()
Closes all documents.
Definition app.h:440
void set_isBars(bool value)
Determine whether scale bars or coordinates should be shown.
Definition app.h:456
void SetMRActiveDoc(wxStfDoc *pDoc)
Sets the currently active document.
Definition app.h:431
const std::vector< stf::Extension > & GetExtensionLib() const
Retrieves the user-defined extension functions.
Definition app.h:362
wxString wxGetProfileString(const wxString &main, const wxString &sub, const wxString &default_) const
Retrieves a string from the configuration.
stfnum::storedFunc * GetLinFuncPtr()
Retrieves a pointer to a function for least-squares minimisation.
Definition app.h:356
void set_directTxtImport(bool directTxtImport_)
Determines whether text files should be imported directly without showing an import filter settings d...
Definition app.h:323
const std::vector< stfnum::storedFunc > & GetFuncLib() const
Retrieves the functions that are available for least-squares minimisation.
Definition app.h:344
void OnPythonImport(wxCommandEvent &event)
Opens a dialog to import a Python module.
void CleanupDocument(wxStfDoc *pDoc)
Destroys the last cursor settings dialog when the last document is closed.
bool get_directTxtImport() const
Indicates whether text files should be imported directly without showing an import settings dialog.
Definition app.h:318
virtual int OnExit()
Exit the application.
void InfoMsg(const wxString &msg) const
Displays a message box with information.
Definition app.h:311
void OnNewfromselected(wxCommandEvent &event)
Open a new window showing all selected traces from all open files.
bool OpenFilePy(const wxString &fNameArray)
Opens a file in a new window, to be called from Python.
bool OpenFileSeries(const wxArrayString &fNameArray)
Opens a series of files. Optionally, files can be put into a single window.
wxStfDoc * GetActiveDoc() const
Retrieves the currently active document.
std::vector< stf::SectionPointer > GetSectionsWithFits() const
Retrieves all sections with fits.
wxStfView * GetActiveView() const
Retrieves the currently active view.
wxStfChildFrame * CreateChildFrame(wxDocument *doc, wxView *view)
Creates a new child frame.
void ExceptMsg(const wxString &msg) const
Displays a message box when an exception has occured.
Definition app.h:302
@ ID_SWAPCHANNELS
Definition app.h:107
@ ID_EVENTADD
Definition app.h:112
@ ID_ANNOTATION_IMPORTANNOTATIONS
Definition app.h:165
@ ID_CH2POS
Definition app.h:104
@ ID_NEWFROMALL
Definition app.h:144
@ ID_VIEW_RTLOHI
Definition app.h:72
@ ID_EVENT_EXTRACT
Definition app.h:159
@ ID_VIEWTABLE
Definition app.h:99
@ ID_ANNOTATION_DetectEvents
Definition app.h:166
@ ID_TOOL_PREVIOUS
Definition app.h:31
@ ID_ZERO_INDEX
Definition app.h:169
@ ID_PLOTSELECTED
Definition app.h:91
@ ID_EVENT_ADDEVENT
Definition app.h:158
@ ID_SCALE
Definition app.h:108
@ ID_BATCH
Definition app.h:100
@ ID_VIEW_MEASURE
Definition app.h:65
@ ID_UNSELECTSOME
Definition app.h:137
@ ID_EXPORTPS
Definition app.h:87
@ ID_EXPORTIMAGE
Definition app.h:86
@ ID_TOOL_SNAPSHOT_WMF
Definition app.h:59
@ ID_SPINCTRLTRACES
Definition app.h:168
@ ID_FILEINFO
Definition app.h:85
@ ID_APPLYTOALL
Definition app.h:114
@ ID_VIEW_SHELL
Definition app.h:84
@ ID_NEWFROMSELECTEDTHIS
Definition app.h:143
@ ID_TOOL_NEXT
Definition app.h:30
@ ID_VIEW_PEAKZERO
Definition app.h:69
@ ID_VIEW_PEAKTHRESHOLD
Definition app.h:71
@ ID_TOOL_CH1
Definition app.h:54
@ ID_MPL_SPECTRUM
Definition app.h:131
@ ID_MPL
Definition app.h:130
@ ID_COMBOINACTCHANNEL
Definition app.h:171
@ ID_VIEW_INNERRISETIME
Definition app.h:73
@ ID_TOOL_LEFT
Definition app.h:40
@ ID_EVENTEXTRACT
Definition app.h:113
@ ID_SAVEPERSPECTIVE
Definition app.h:155
@ ID_EVENT_ERASE
Definition app.h:160
@ ID_PLOTCORRELATION
Definition app.h:150
@ ID_SHOWSECOND
Definition app.h:92
@ ID_TOOL_LATENCY
Definition app.h:48
@ ID_VIEW_BASELINE
Definition app.h:66
@ ID_TOOL_DOWN
Definition app.h:38
@ ID_AVERAGE
Definition app.h:94
@ ID_UPDATE
Definition app.h:115
@ ID_MULTIPLY
Definition app.h:135
@ ID_VIEW_CURSORS
Definition app.h:83
@ ID_TOOL_YENL
Definition app.h:35
@ ID_SUBTRACTBASE
Definition app.h:146
@ ID_EXPORTLATEX
Definition app.h:88
@ ID_UNSELECTALL
Definition app.h:139
@ ID_CH2BASE
Definition app.h:103
@ ID_ALIGNEDAVERAGE
Definition app.h:95
@ ID_TOOL_EVENT
Definition app.h:53
@ ID_LFIT
Definition app.h:97
@ ID_CONCATENATE_MULTICHANNEL
Definition app.h:145
@ ID_TOOL_UP
Definition app.h:37
@ ID_SELECT_AND_REMOVE
Definition app.h:141
@ ID_INTEGRATE
Definition app.h:101
@ ID_DIFFERENTIATE
Definition app.h:102
@ ID_TOOL_XSHRINK
Definition app.h:34
@ ID_POVERN
Definition app.h:148
@ ID_ANNOTATION_ADDANNOTATION
Definition app.h:161
@ ID_SELECT_AND_ADD
Definition app.h:140
@ ID_EXTRACT
Definition app.h:152
@ ID_TOOL_CH2
Definition app.h:55
@ ID_IMPORTPYTHON
Definition app.h:62
@ ID_TOOL_XENL
Definition app.h:33
@ ID_LOG
Definition app.h:98
@ ID_VIEW_PEAKBASE
Definition app.h:70
@ ID_ZOOMHV
Definition app.h:109
@ ID_ANNOTATION_REMOVEANNOTATION
Definition app.h:162
@ ID_SELECTSOME
Definition app.h:136
@ ID_TOOL_ANNOTATION
Definition app.h:57
@ ID_ZOOMV
Definition app.h:111
@ ID_TRACES
Definition app.h:90
@ ID_COPYINTABLE
Definition app.h:134
@ ID_VIEW_LATENCY
Definition app.h:79
@ ID_MYSELECTALL
Definition app.h:138
@ ID_THRESHOLD
Definition app.h:153
@ ID_ANNOTATION_EXPORTANNOTATIONS
Definition app.h:164
@ ID_TOOL_SELECT
Definition app.h:42
@ ID_NEWFROMSELECTED
Definition app.h:142
@ ID_VIEW_RD
Definition app.h:76
@ ID_TOOL_YSHRINK
Definition app.h:36
@ ID_ANNOTATION_ERASEALLANNOTATIONS
Definition app.h:163
@ ID_TOOL_FIT
Definition app.h:39
@ ID_CURSORS
Definition app.h:93
@ ID_COMBOTRACES
Definition app.h:167
@ ID_TOOL_SNAPSHOT
Definition app.h:56
@ ID_TOOL_DECAY
Definition app.h:47
@ ID_VIEW_SLOPEDECAY
Definition app.h:78
@ ID_ZOOMH
Definition app.h:110
@ ID_CONVERT
Definition app.h:116
@ ID_USERDEF
Definition app.h:173
@ ID_PRINT_PAGE_SETUP
Definition app.h:132
@ ID_PRINT_PREVIEW
Definition app.h:133
@ ID_PRINT_PRINT
Definition app.h:129
@ ID_VIEW_THRESHOLD
Definition app.h:68
@ ID_FIT
Definition app.h:96
@ ID_PLOTCRITERION
Definition app.h:149
@ ID_VIEW_SLOPERISE
Definition app.h:77
@ ID_PLOTDECONVOLUTION
Definition app.h:151
@ ID_RESTOREPERSPECTIVE
Definition app.h:156
@ ID_COMBOACTCHANNEL
Definition app.h:170
@ ID_TOOL_RIGHT
Definition app.h:41
@ ID_TOOL_FIRST
Definition app.h:29
@ ID_TOOL_PEAK
Definition app.h:45
@ ID_VIEW_RESULTS
Definition app.h:64
@ ID_CH2ZOOM
Definition app.h:105
@ ID_VIEW_BASESD
Definition app.h:67
@ ID_TOOL_BASE
Definition app.h:46
@ ID_TOOL_REMOVE
Definition app.h:43
@ ID_FILTER
Definition app.h:147
@ ID_CH2BASEZOOM
Definition app.h:106
@ ID_LOADPERSPECTIVE
Definition app.h:154
@ ID_STFCHECKBOX
Definition app.h:157
@ ID_VIEW_OUTERRISETIME
Definition app.h:74
@ ID_VIEW_T50
Definition app.h:75
@ ID_TOOL_MEASURE
Definition app.h:44
@ ID_TOOL_LAST
Definition app.h:32
@ ID_EXPORTSVG
Definition app.h:89
@ ID_TOOL_FITDECAY
Definition app.h:60
@ ID_TOOL_ZOOM
Definition app.h:52
#define StfDll
Defines dll export or import functions for Windows.
Definition stf.h:55
Math functions.
Text file import filter settings.
Definition stfio.h:101
Function used for least-squares fitting.
Definition stfnum.h:270