|
Stimfit 0.12.7
|
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_T50, 00073 ID_VIEW_RD, 00074 ID_VIEW_SLOPERISE, 00075 ID_VIEW_SLOPEDECAY, 00076 ID_VIEW_LATENCY, 00077 #ifdef WITH_PSLOPE 00078 ID_VIEW_PSLOPE, 00079 #endif 00080 ID_VIEW_CURSORS, 00081 ID_VIEW_SHELL, 00082 ID_FILEINFO, 00083 ID_EXPORTIMAGE, 00084 ID_EXPORTPS, 00085 ID_EXPORTLATEX, 00086 ID_EXPORTSVG, 00087 ID_TRACES, 00088 ID_PLOTSELECTED, 00089 ID_SHOWSECOND, 00090 ID_CURSORS, 00091 ID_AVERAGE, 00092 ID_ALIGNEDAVERAGE, 00093 ID_FIT, 00094 ID_LFIT, 00095 ID_LOG, 00096 ID_VIEWTABLE, 00097 ID_BATCH, 00098 ID_INTEGRATE, 00099 ID_DIFFERENTIATE, 00100 ID_CH2BASE, 00101 ID_CH2POS, 00102 ID_CH2ZOOM, 00103 ID_CH2BASEZOOM, 00104 ID_SWAPCHANNELS, 00105 ID_SCALE, 00106 ID_HIRES, 00107 ID_ZOOMHV, 00108 ID_ZOOMH, 00109 ID_ZOOMV, 00110 ID_EVENTADD, 00111 ID_EVENTEXTRACT, 00112 ID_APPLYTOALL, 00113 ID_UPDATE, 00114 ID_CONVERT, 00115 #if 0 00116 ID_LATENCYSTART_MAXSLOPE, 00117 ID_LATENCYSTART_HALFRISE, 00118 ID_LATENCYSTART_PEAK, 00119 ID_LATENCYSTART_MANUAL, 00120 ID_LATENCYEND_FOOT, 00121 ID_LATENCYEND_MAXSLOPE, 00122 ID_LATENCYEND_HALFRISE, 00123 ID_LATENCYEND_PEAK, 00124 ID_LATENCYEND_MANUAL, 00125 ID_LATENCYWINDOW, 00126 #endif 00127 ID_PRINT_PRINT, 00128 ID_MPL, 00129 ID_MPL_SPECTRUM, 00130 ID_PRINT_PAGE_SETUP, 00131 ID_PRINT_PREVIEW, 00132 ID_COPYINTABLE, 00133 ID_MULTIPLY, 00134 ID_SELECTSOME, 00135 ID_UNSELECTSOME, 00136 ID_MYSELECTALL, 00137 ID_UNSELECTALL, 00138 ID_NEWFROMSELECTED, 00139 ID_NEWFROMSELECTEDTHIS, 00140 ID_NEWFROMALL, 00141 ID_CONCATENATE, 00142 ID_SUBTRACTBASE, 00143 ID_FILTER, 00144 ID_POVERN, 00145 ID_PLOTCRITERION, 00146 ID_PLOTCORRELATION, 00147 ID_PLOTDECONVOLUTION, 00148 ID_EXTRACT, 00149 ID_THRESHOLD, 00150 ID_LOADPERSPECTIVE, 00151 ID_SAVEPERSPECTIVE, 00152 ID_RESTOREPERSPECTIVE, 00153 ID_STFCHECKBOX, 00154 ID_EVENT_ADDEVENT, 00155 ID_EVENT_EXTRACT, 00156 ID_EVENT_ERASE, 00157 ID_COMBOTRACES, 00158 ID_SPINCTRLTRACES, 00159 ID_ZERO_INDEX, 00160 ID_COMBOACTCHANNEL, 00161 ID_COMBOINACTCHANNEL, 00162 #ifdef WITH_PYTHON 00163 ID_USERDEF, // this should be the last ID event 00164 #endif 00165 }; 00166 00167 #include <list> 00168 00169 #include <wx/mdi.h> 00170 #include <wx/docview.h> 00171 #include <wx/docmdi.h> 00172 #include <wx/fileconf.h> 00173 #include <wx/settings.h> 00174 00175 #include "./../math/stfmath.h" 00176 00177 #ifdef WITH_PYTHON 00178 00179 #ifdef _POSIX_C_SOURCE 00180 #define _POSIX_C_SOURCE_WAS_DEF 00181 #undef _POSIX_C_SOURCE 00182 #endif 00183 #ifdef _XOPEN_SOURCE 00184 #define _XOPEN_SOURCE_WAS_DEF 00185 #undef _XOPEN_SOURCE 00186 #endif 00187 #include <Python.h> 00188 #ifdef _POSIX_C_SOURCE_WAS_DEF 00189 #ifndef _POSIX_C_SOURCE 00190 #define _POSIX_C_SOURCE 00191 #endif 00192 #endif 00193 #ifdef _XOPEN_SOURCE_WAS_DEF 00194 #ifndef _XOPEN_SOURCE 00195 #define _XOPEN_SOURCE 00196 #endif 00197 #endif 00198 00199 #if defined(__WXMAC__) || defined(__WXGTK__) 00200 #pragma GCC diagnostic ignored "-Wwrite-strings" 00201 #endif 00202 #include <wx/wxPython/wxPython.h> 00203 // revert to previous behaviour 00204 #if defined(__WXMAC__) || defined(__WXGTK__) 00205 #pragma GCC diagnostic warning "-Wwrite-strings" 00206 #endif 00207 00208 #endif // WITH_PYTHON 00209 00210 #include <boost/shared_ptr.hpp> 00211 00212 class wxDocManager; 00213 class wxStfDoc; 00214 class wxStfView; 00215 class wxStfCursorsDlg; 00216 class wxStfParentFrame; 00217 class wxStfChildFrame; 00218 class Section; 00219 00221 00226 class StfDll wxStfApp: public wxApp 00227 { 00228 public: 00230 wxStfApp(); 00231 00233 00240 virtual bool OnInit(); 00241 00243 00246 virtual int OnExit(); 00247 00249 00256 wxStfChildFrame *CreateChildFrame(wxDocument *doc, wxView *view); 00257 00259 00261 wxStfDoc* GetActiveDoc() const; 00262 00264 00266 /*void SetActiveDoc(wxStfDoc* pDoc);*/ 00267 00269 00271 wxStfView* GetActiveView() const; 00272 00274 00278 void ErrorMsg(const wxString& msg) const { 00279 wxMessageBox(msg,wxT("An error has occured"),wxOK | wxICON_EXCLAMATION,NULL); 00280 } 00281 00283 00287 void ExceptMsg(const wxString& msg) const { 00288 wxMessageBox(msg,wxT("An exception was caught"),wxOK | wxICON_HAND,NULL); 00289 } 00290 00292 00296 void InfoMsg(const wxString& msg) const { 00297 wxMessageBox(msg,wxT("Information"), wxOK | wxICON_INFORMATION, NULL); 00298 } 00299 00301 00303 bool get_directTxtImport() const { return directTxtImport; } 00304 00306 00308 void set_directTxtImport(bool directTxtImport_) { 00309 directTxtImport=directTxtImport_; 00310 } 00311 00313 00315 const stfio::txtImportSettings& GetTxtImport() const { 00316 return txtImport; 00317 } 00318 00320 00322 void set_txtImportSettings(const stfio::txtImportSettings& txtImport_) { 00323 txtImport=txtImport_; 00324 } 00325 00327 00329 const std::vector<stf::storedFunc>& GetFuncLib() const { return funcLib; } 00330 00331 00333 00335 stf::storedFunc* GetFuncLibPtr(std::size_t at) { return &funcLib.at(at); } 00336 00337 00339 00341 stf::storedFunc* GetLinFuncPtr( ) { return &storedLinFunc; } 00342 00343 #ifdef WITH_PYTHON 00344 00345 00347 const std::vector< stf::Extension >& GetExtensionLib() const { return extensionLib; } 00348 #endif 00349 00351 00353 wxStfCursorsDlg* GetCursorsDialog() const { return CursorsDialog; } 00354 00356 00358 std::vector<stf::SectionPointer> GetSectionsWithFits() const; 00359 00361 00365 void wxWriteProfileInt(const wxString& main,const wxString& sub, int value) const; 00366 00368 00374 int wxGetProfileInt(const wxString& main,const wxString& sub, int default_) const; 00375 00377 00381 void wxWriteProfileString( 00382 const wxString& main, const wxString& sub, const wxString& value ) const; 00383 00385 00391 wxString wxGetProfileString( 00392 const wxString& main, const wxString& sub, const wxString& default_ ) const; 00393 00395 00400 wxStfDoc* NewChild( 00401 const Recording& NewData, 00402 const wxStfDoc* Sender, 00403 const wxString& title = wxT("\0") 00404 ); 00405 00407 00411 void OnPeakcalcexecMsg(wxStfDoc* actDoc = 0); 00412 00414 00417 void CleanupDocument(wxStfDoc* pDoc); 00418 00420 bool CloseAll() { return GetDocManager()->CloseDocuments(); } 00421 00423 00426 bool OpenFileSeries(const wxArrayString& fNameArray); 00427 00429 00431 int GetDocCount() { return (int)GetDocManager()->GetDocuments().GetCount(); } 00432 00434 00436 void set_isBars(bool value) { isBars=value; } 00437 00439 00441 bool get_isBars() const { return isBars; } 00442 00444 00447 void set_isHires(bool value) { isHires=value; } 00448 00450 00452 bool get_isHires() const { return isHires; } 00453 00455 00457 wxString GetVersionString() const; 00458 00460 00462 void OnNewfromselected( wxCommandEvent& event ); 00463 00465 00467 wxDocManager* GetDocManager() const { return wxDocManager::GetDocumentManager(); } 00468 00469 virtual void OnInitCmdLine(wxCmdLineParser& parser); 00470 virtual bool OnCmdLineParsed(wxCmdLineParser& parser); 00471 00472 #ifdef WITH_PYTHON 00473 00474 00477 bool OpenFilePy(const wxString& fNameArray); 00478 00480 00482 void OnPythonImport( wxCommandEvent& event ); 00483 #endif 00484 00485 protected: 00486 00487 private: 00488 void OnCursorSettings( wxCommandEvent& event ); 00489 void OnNewfromall( wxCommandEvent& event ); 00490 void OnApplytoall( wxCommandEvent& event ); 00491 void OnProcessCustom( wxCommandEvent& event ); 00492 void OnKeyDown( wxKeyEvent& event ); 00493 00494 #ifdef WITH_PYTHON 00495 void ImportPython(const wxString& modulelocation); 00496 void OnUserdef(wxCommandEvent& event); 00497 bool Init_wxPython(); 00498 bool Exit_wxPython(); 00499 std::vector<stf::Extension> LoadExtensions(); 00500 #endif // WITH_PYTHON 00501 00502 wxMenuBar* CreateUnifiedMenuBar(wxStfDoc* doc=NULL); 00503 00504 #ifdef _WINDOWS 00505 #pragma optimize( "", off ) 00506 #endif 00507 00508 #ifdef _WINDOWS 00509 #pragma optimize( "", on ) 00510 #endif 00511 00512 bool directTxtImport,isBars,isHires; 00513 stfio::txtImportSettings txtImport; 00514 // Registry: 00515 boost::shared_ptr<wxFileConfig> config; 00516 std::vector<stf::storedFunc> funcLib; 00517 #ifdef WITH_PYTHON 00518 std::vector< stf::Extension > extensionLib; 00519 #endif 00520 // Pointer to the cursors settings dialog box 00521 wxStfCursorsDlg* CursorsDialog; 00522 wxDocTemplate* m_cfsTemplate, *m_hdf5Template, *m_txtTemplate,*m_abfTemplate, 00523 *m_atfTemplate,*m_axgTemplate,*m_sonTemplate, *m_hekaTemplate, *m_biosigTemplate; 00524 stf::storedFunc storedLinFunc; 00525 // wxMenu* m_file_menu; 00526 wxString m_fileToLoad; 00527 /*std::list<wxStfDoc *> activeDoc;*/ 00528 00529 #ifdef WITH_PYTHON 00530 PyThreadState* m_mainTState; 00531 #endif 00532 00533 DECLARE_EVENT_TABLE() 00534 }; 00535 00536 #ifdef _WINDOWS 00537 00538 extern StfDll wxStfApp& wxGetApp(); 00539 #else 00540 DECLARE_APP(wxStfApp) 00541 #endif 00542 00544 00545 extern StfDll wxStfParentFrame *GetMainFrame(); 00546 00548 extern bool singleWindowMode; 00549 00552 #endif 00553
1.7.4