Stimfit
0.13.15
|
00001 // This program is free software; you can redistribute it and/or 00002 // modify it under the terms of the GNU General Public License 00003 // as published by the Free Software Foundation; either version 2 00004 // of the License, or (at your option) any later version. 00005 00006 // This program is distributed in the hope that it will be useful, 00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00009 // GNU General Public License for more details. 00010 00011 // You should have received a copy of the GNU General Public License 00012 // along with this program; if not, write to the Free Software 00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00014 00021 #ifndef _APP_H 00022 #define _APP_H 00023 00027 00028 enum { 00029 ID_TOOL_FIRST, // = wxID_HIGHEST+1, resulted in wrong events being fired 00030 ID_TOOL_NEXT, 00031 ID_TOOL_PREVIOUS, 00032 ID_TOOL_LAST, 00033 ID_TOOL_XENL, 00034 ID_TOOL_XSHRINK, 00035 ID_TOOL_YENL, 00036 ID_TOOL_YSHRINK, 00037 ID_TOOL_UP, 00038 ID_TOOL_DOWN, 00039 ID_TOOL_FIT, 00040 ID_TOOL_LEFT, 00041 ID_TOOL_RIGHT, 00042 ID_TOOL_SELECT, 00043 ID_TOOL_REMOVE, 00044 ID_TOOL_MEASURE, 00045 ID_TOOL_PEAK, 00046 ID_TOOL_BASE, 00047 ID_TOOL_DECAY, 00048 ID_TOOL_LATENCY, 00049 #ifdef WITH_PSLOPE 00050 ID_TOOL_PSLOPE, 00051 #endif 00052 ID_TOOL_ZOOM, 00053 ID_TOOL_EVENT, 00054 ID_TOOL_CH1, 00055 ID_TOOL_CH2, 00056 ID_TOOL_SNAPSHOT, 00057 00058 ID_TOOL_SNAPSHOT_WMF, 00059 00060 #ifdef WITH_PYTHON 00061 ID_IMPORTPYTHON, 00062 #endif 00063 ID_VIEW_RESULTS, 00064 ID_VIEW_MEASURE, 00065 ID_VIEW_BASELINE, 00066 ID_VIEW_BASESD, 00067 ID_VIEW_THRESHOLD, 00068 ID_VIEW_PEAKZERO, 00069 ID_VIEW_PEAKBASE, 00070 ID_VIEW_PEAKTHRESHOLD, 00071 ID_VIEW_RTLOHI, 00072 ID_VIEW_INNERRISETIME, 00073 ID_VIEW_OUTERRISETIME, 00074 ID_VIEW_T50, 00075 ID_VIEW_RD, 00076 ID_VIEW_SLOPERISE, 00077 ID_VIEW_SLOPEDECAY, 00078 ID_VIEW_LATENCY, 00079 #ifdef WITH_PSLOPE 00080 ID_VIEW_PSLOPE, 00081 #endif 00082 ID_VIEW_CURSORS, 00083 ID_VIEW_SHELL, 00084 ID_FILEINFO, 00085 ID_EXPORTIMAGE, 00086 ID_EXPORTPS, 00087 ID_EXPORTLATEX, 00088 ID_EXPORTSVG, 00089 ID_TRACES, 00090 ID_PLOTSELECTED, 00091 ID_SHOWSECOND, 00092 ID_CURSORS, 00093 ID_AVERAGE, 00094 ID_ALIGNEDAVERAGE, 00095 ID_FIT, 00096 ID_LFIT, 00097 ID_LOG, 00098 ID_VIEWTABLE, 00099 ID_BATCH, 00100 ID_INTEGRATE, 00101 ID_DIFFERENTIATE, 00102 ID_CH2BASE, 00103 ID_CH2POS, 00104 ID_CH2ZOOM, 00105 ID_CH2BASEZOOM, 00106 ID_SWAPCHANNELS, 00107 ID_SCALE, 00108 ID_ZOOMHV, 00109 ID_ZOOMH, 00110 ID_ZOOMV, 00111 ID_EVENTADD, 00112 ID_EVENTEXTRACT, 00113 ID_APPLYTOALL, 00114 ID_UPDATE, 00115 ID_CONVERT, 00116 #if 0 00117 ID_LATENCYSTART_MAXSLOPE, 00118 ID_LATENCYSTART_HALFRISE, 00119 ID_LATENCYSTART_PEAK, 00120 ID_LATENCYSTART_MANUAL, 00121 ID_LATENCYEND_FOOT, 00122 ID_LATENCYEND_MAXSLOPE, 00123 ID_LATENCYEND_HALFRISE, 00124 ID_LATENCYEND_PEAK, 00125 ID_LATENCYEND_MANUAL, 00126 ID_LATENCYWINDOW, 00127 #endif 00128 ID_PRINT_PRINT, 00129 ID_MPL, 00130 ID_MPL_SPECTRUM, 00131 ID_PRINT_PAGE_SETUP, 00132 ID_PRINT_PREVIEW, 00133 ID_COPYINTABLE, 00134 ID_MULTIPLY, 00135 ID_SELECTSOME, 00136 ID_UNSELECTSOME, 00137 ID_MYSELECTALL, 00138 ID_UNSELECTALL, 00139 ID_NEWFROMSELECTED, 00140 ID_NEWFROMSELECTEDTHIS, 00141 ID_NEWFROMALL, 00142 ID_CONCATENATE_MULTICHANNEL, 00143 ID_SUBTRACTBASE, 00144 ID_FILTER, 00145 ID_POVERN, 00146 ID_PLOTCRITERION, 00147 ID_PLOTCORRELATION, 00148 ID_PLOTDECONVOLUTION, 00149 ID_EXTRACT, 00150 ID_THRESHOLD, 00151 ID_LOADPERSPECTIVE, 00152 ID_SAVEPERSPECTIVE, 00153 ID_RESTOREPERSPECTIVE, 00154 ID_STFCHECKBOX, 00155 ID_EVENT_ADDEVENT, 00156 ID_EVENT_EXTRACT, 00157 ID_EVENT_ERASE, 00158 ID_COMBOTRACES, 00159 ID_SPINCTRLTRACES, 00160 ID_ZERO_INDEX, 00161 ID_COMBOACTCHANNEL, 00162 ID_COMBOINACTCHANNEL, 00163 #ifdef WITH_PYTHON 00164 ID_USERDEF, // this should be the last ID event 00165 #endif 00166 }; 00167 00168 #include <list> 00169 00170 #include <wx/mdi.h> 00171 #include <wx/docview.h> 00172 #include <wx/docmdi.h> 00173 #include <wx/fileconf.h> 00174 #include <wx/settings.h> 00175 00176 #include "./../math/stfmath.h" 00177 00178 #ifdef WITH_PYTHON 00179 00180 #ifdef _POSIX_C_SOURCE 00181 #define _POSIX_C_SOURCE_WAS_DEF 00182 #undef _POSIX_C_SOURCE 00183 #endif 00184 #ifdef _XOPEN_SOURCE 00185 #define _XOPEN_SOURCE_WAS_DEF 00186 #undef _XOPEN_SOURCE 00187 #endif 00188 #include <Python.h> 00189 #ifdef _POSIX_C_SOURCE_WAS_DEF 00190 #ifndef _POSIX_C_SOURCE 00191 #define _POSIX_C_SOURCE 00192 #endif 00193 #endif 00194 #ifdef _XOPEN_SOURCE_WAS_DEF 00195 #ifndef _XOPEN_SOURCE 00196 #define _XOPEN_SOURCE 00197 #endif 00198 #endif 00199 00200 #if defined(__WXMAC__) || defined(__WXGTK__) 00201 #pragma GCC diagnostic ignored "-Wwrite-strings" 00202 #endif 00203 #if PY_MAJOR_VERSION >= 3 00204 #include <wx/wxPython/wxpy_api.h> 00205 #else 00206 #include <wx/wxPython/wxPython.h> 00207 #endif 00208 // revert to previous behaviour 00209 #if defined(__WXMAC__) || defined(__WXGTK__) 00210 #pragma GCC diagnostic warning "-Wwrite-strings" 00211 #endif 00212 00213 #endif // WITH_PYTHON 00214 00215 #include <boost/shared_ptr.hpp> 00216 00217 class wxDocManager; 00218 class wxStfDoc; 00219 class wxStfView; 00220 class wxStfCursorsDlg; 00221 class wxStfParentFrame; 00222 class wxStfChildFrame; 00223 class Section; 00224 00226 00231 class StfDll wxStfApp: public wxApp 00232 { 00233 public: 00235 wxStfApp(); 00236 00238 00245 virtual bool OnInit(); 00246 00248 00251 virtual int OnExit(); 00252 00254 00261 wxStfChildFrame *CreateChildFrame(wxDocument *doc, wxView *view); 00262 00264 00266 wxStfDoc* GetActiveDoc() const; 00267 00269 00271 /*void SetActiveDoc(wxStfDoc* pDoc);*/ 00272 00274 00276 wxStfView* GetActiveView() const; 00277 00279 00283 void ErrorMsg(const wxString& msg) const { 00284 wxMessageBox(msg,wxT("An error has occured"),wxOK | wxICON_EXCLAMATION,NULL); 00285 } 00286 00288 00292 void ExceptMsg(const wxString& msg) const { 00293 wxMessageBox(msg,wxT("An exception was caught"),wxOK | wxICON_HAND,NULL); 00294 } 00295 00297 00301 void InfoMsg(const wxString& msg) const { 00302 wxMessageBox(msg,wxT("Information"), wxOK | wxICON_INFORMATION, NULL); 00303 } 00304 00306 00308 bool get_directTxtImport() const { return directTxtImport; } 00309 00311 00313 void set_directTxtImport(bool directTxtImport_) { 00314 directTxtImport=directTxtImport_; 00315 } 00316 00318 00320 const stfio::txtImportSettings& GetTxtImport() const { 00321 return txtImport; 00322 } 00323 00325 00327 void set_txtImportSettings(const stfio::txtImportSettings& txtImport_) { 00328 txtImport=txtImport_; 00329 } 00330 00332 00334 const std::vector<stf::storedFunc>& GetFuncLib() const { return funcLib; } 00335 00336 00338 00340 stf::storedFunc* GetFuncLibPtr(std::size_t at) { return &funcLib.at(at); } 00341 00342 00344 00346 stf::storedFunc* GetLinFuncPtr( ) { return &storedLinFunc; } 00347 00348 #ifdef WITH_PYTHON 00349 00350 00352 const std::vector< stf::Extension >& GetExtensionLib() const { return extensionLib; } 00353 #endif 00354 00356 00358 wxStfCursorsDlg* GetCursorsDialog() const { return CursorsDialog; } 00359 00361 00363 std::vector<stf::SectionPointer> GetSectionsWithFits() const; 00364 00366 00370 void wxWriteProfileInt(const wxString& main,const wxString& sub, int value) const; 00371 00373 00379 int wxGetProfileInt(const wxString& main,const wxString& sub, int default_) const; 00380 00382 00386 void wxWriteProfileString( 00387 const wxString& main, const wxString& sub, const wxString& value ) const; 00388 00390 00396 wxString wxGetProfileString( 00397 const wxString& main, const wxString& sub, const wxString& default_ ) const; 00398 00400 00405 wxStfDoc* NewChild( 00406 const Recording& NewData, 00407 const wxStfDoc* Sender, 00408 const wxString& title = wxT("\0") 00409 ); 00410 00412 00416 void OnPeakcalcexecMsg(wxStfDoc* actDoc = 0); 00417 00419 00422 void CleanupDocument(wxStfDoc* pDoc); 00423 00425 bool CloseAll() { return GetDocManager()->CloseDocuments(); } 00426 00428 00431 bool OpenFileSeries(const wxArrayString& fNameArray); 00432 00434 00436 int GetDocCount() { return (int)GetDocManager()->GetDocuments().GetCount(); } 00437 00439 00441 void set_isBars(bool value) { isBars=value; } 00442 00444 00446 bool get_isBars() const { return isBars; } 00447 00449 00451 wxString GetVersionString() const; 00452 00454 00456 void OnNewfromselected( wxCommandEvent& event ); 00457 00459 00461 wxDocManager* GetDocManager() const { return wxDocManager::GetDocumentManager(); } 00462 00463 virtual void OnInitCmdLine(wxCmdLineParser& parser); 00464 virtual bool OnCmdLineParsed(wxCmdLineParser& parser); 00465 00466 #ifdef WITH_PYTHON 00467 00468 00471 bool OpenFilePy(const wxString& fNameArray); 00472 00474 00476 void OnPythonImport( wxCommandEvent& event ); 00477 #endif 00478 00479 protected: 00480 00481 private: 00482 void OnCursorSettings( wxCommandEvent& event ); 00483 void OnNewfromall( wxCommandEvent& event ); 00484 void OnApplytoall( wxCommandEvent& event ); 00485 void OnProcessCustom( wxCommandEvent& event ); 00486 void OnKeyDown( wxKeyEvent& event ); 00487 00488 #ifdef WITH_PYTHON 00489 void ImportPython(const wxString& modulelocation); 00490 void OnUserdef(wxCommandEvent& event); 00491 bool Init_wxPython(); 00492 bool Exit_wxPython(); 00493 std::vector<stf::Extension> LoadExtensions(); 00494 #endif // WITH_PYTHON 00495 00496 wxMenuBar* CreateUnifiedMenuBar(wxStfDoc* doc=NULL); 00497 00498 #ifdef _WINDOWS 00499 #pragma optimize( "", off ) 00500 #endif 00501 00502 #ifdef _WINDOWS 00503 #pragma optimize( "", on ) 00504 #endif 00505 00506 bool directTxtImport,isBars; 00507 stfio::txtImportSettings txtImport; 00508 // Registry: 00509 boost::shared_ptr<wxFileConfig> config; 00510 std::vector<stf::storedFunc> funcLib; 00511 #ifdef WITH_PYTHON 00512 std::vector< stf::Extension > extensionLib; 00513 #endif 00514 // Pointer to the cursors settings dialog box 00515 wxStfCursorsDlg* CursorsDialog; 00516 wxDocTemplate* m_cfsTemplate, *m_hdf5Template, *m_txtTemplate,*m_abfTemplate, 00517 *m_atfTemplate,*m_axgTemplate,*m_sonTemplate, *m_hekaTemplate, *m_biosigTemplate; 00518 stf::storedFunc storedLinFunc; 00519 // wxMenu* m_file_menu; 00520 wxString m_fileToLoad; 00521 /*std::list<wxStfDoc *> activeDoc;*/ 00522 00523 #ifdef WITH_PYTHON 00524 PyThreadState* m_mainTState; 00525 #endif 00526 00527 DECLARE_EVENT_TABLE() 00528 }; 00529 00530 #ifdef _WINDOWS 00531 00532 extern StfDll wxStfApp& wxGetApp(); 00533 #else 00534 DECLARE_APP(wxStfApp) 00535 #endif 00536 00538 00539 extern StfDll wxStfParentFrame *GetMainFrame(); 00540 00542 extern bool singleWindowMode; 00543 00546 #endif 00547