Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
stf.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
23
24#ifndef _STF_H_
25#define _STF_H_
26
27#ifndef _WINDOWS
28#if (__cplusplus < 201103)
29 #include <boost/function.hpp>
30#else
31 #include <algorithm>
32 #include <memory>
33#endif
34#endif
35
36#if (__GNUC__ > 5)
37 #include <functional>
38#endif
39#include <vector>
40#include <map>
41#include <string>
42
43#include "./gui/zoom.h"
44
45#ifdef _MSC_VER
46#pragma warning( disable : 4251 ) // Disable warning messages
47#pragma warning( disable : 4996 ) // Disable warning messages
48#endif
49
51#if defined(_WINDOWS) && !defined(__MINGW32__)
52 #ifdef STFDLL
53 #define StfDll __declspec( dllexport )
54 #else
55 #define StfDll __declspec( dllimport )
56 #endif
57#else
58 #define StfDll
59#endif
60
61#ifndef MODULE_ONLY
62 #include <wx/wxprec.h>
63 #ifdef __BORLANDC__
64 #pragma hdrstop
65 #endif
66
67 #ifndef WX_PRECOMP
68 #include <wx/wx.h>
69 #include <wx/aui/aui.h>
70 #include <wx/docview.h>
71 #include <wx/docmdi.h>
72 #endif
73
74 #include <wx/wfstream.h>
75 #include <wx/progdlg.h>
77 // typedef wxDocChildFrameAny<wxAuiMDIChildFrame, wxAuiMDIParentFrame> wxStfChildType;
78 #ifdef STF_TEST
79 typedef int wxStfChildType;
81 typedef int wxStfParentType;
82 #else
84
87 #endif
88#else
89 typedef std::string wxString;
90 typedef int wxWindow;
91 #define wxT(x) x
92 #define wxCHECK_VERSION(major,minor,release) 0
93#endif
94
95#include "../libstfio/stfio.h"
96#include "../libstfnum/stfnum.h"
97
99
102namespace stf {
103
107
110public:
111 wxProgressInfo(const std::string& title, const std::string& message, int maximum, bool verbose=true);
112 bool Update(int value, const std::string& newmsg="", bool* skip=NULL);
113private:
114 wxProgressDialog pd;
115};
116
117std::string wx2std(const wxString& wxs);
118wxString std2wx(const std::string& sst);
119
121
125
127
131
133
137
139#if (__cplusplus < 201103)
140typedef boost::function<Recording(const Recording&,const Vector_double&,std::map<std::string, double>&)> PluginFunc;
141#else
142typedef std::function<Recording(const Recording&,const Vector_double&,std::map<std::string, double>&)> PluginFunc;
143#endif
144
146struct UserInput {
147 std::vector<std::string> labels;
149 std::string title;
150
152
157 const std::vector<std::string>& labels_=std::vector<std::string>(0),
158 const Vector_double& defaults_=Vector_double(0),
159 std::string title_="\0"
160 ) : labels(labels_),defaults(defaults_),title(title_)
161 {
162 if (defaults.size()!=labels.size()) {
163 defaults.resize(labels.size());
164 std::fill(defaults.begin(), defaults.end(), 0.0);
165 }
166 }
167};
168
170
174struct Plugin {
176
181 const wxString& menuEntry_,
182 const PluginFunc& pluginFunc_,
183 const UserInput& input_=UserInput()
184 ) : menuEntry(menuEntry_),pluginFunc(pluginFunc_),input(input_)
185 {
186 id = n_plugins;
187 n_plugins++;
188 }
189
192
193 int id;
194 static int n_plugins;
198};
199
201
205struct Extension {
207
212 Extension(const std::string& menuEntry_, void* pyFunc_,
213 const std::string& description_, bool requiresFile_) :
214 menuEntry(menuEntry_), pyFunc(pyFunc_),
215 description(description_), requiresFile(requiresFile_)
216 {
217 id = n_extensions;
218 n_extensions++;
219 }
220
223
224 int id;
225 static int n_extensions;
226 std::string menuEntry;
227 void* pyFunc;
228 std::string description;
230};
231
234
236
237 ifstreamMan( const wxString& filename )
238 : myStream( filename, wxT("r") )
239 {}
240
242 ~ifstreamMan() { myStream.Close(); }
243
245 wxFFile myStream;
246};
247
250
252
253 ofstreamMan( const wxString& filename )
254 : myStream( filename, wxT("w") )
255 {}
256
258 ~ofstreamMan() { myStream.Close(); }
259
261 wxFFile myStream;
262};
263
265class Event {
266public:
268 explicit Event(std::size_t start, std::size_t peak, std::size_t size, wxCheckBox* cb);
269
272
274
275 std::size_t GetEventStartIndex() const { return eventStartIndex; }
276
278
279 std::size_t GetEventPeakIndex() const { return eventPeakIndex; }
280
282
283 std::size_t GetEventSize() const { return eventSize; }
284
286
287 bool GetDiscard() const { return !checkBox->GetValue(); }
288
290
291 wxCheckBox* GetCheckBox() {return checkBox;}
292
294
295 void SetEventStartIndex( std::size_t value ) { eventStartIndex = value; }
296
298
299 void SetEventPeakIndex( std::size_t value ) { eventPeakIndex = value; }
300
302
303 void SetEventSize( std::size_t value ) { eventSize = value; }
304
306
307 /*void SetDiscard( bool value ) { discard = value; }*/
308
310 /*void ToggleStatus() { discard = !discard; }*/
311
312private:
313 std::size_t eventStartIndex;
314 std::size_t eventPeakIndex;
315 std::size_t eventSize;
316 wxCheckBox* checkBox;
317
318};
319
321
323struct PyMarker {
325
328 PyMarker( double xv, double yv ) : x(xv), y(yv) {}
329 double x;
330 double y;
331};
332
347
353
355const double PI=3.14159265358979323846;
356
358
361int round(double toRound);
362
378
385
395
401
402#ifdef WITH_PSLOPE
404enum pslope_mode_beg {
405 psBeg_manualMode =0, /*< Set the start Slope cursor manually. */
406 psBeg_footMode =1, /*< Set the start Slope cursor to the beginning of an event. */
407 psBeg_thrMode =2, /*< Set the start Slope cursor to a threshold. */
408 psBeg_t50Mode =3, /*< Set the start Slope cursor to the half-width of an event*/
409 psBeg_undefined
410};
411
413enum pslope_mode_end {
414 psEnd_manualMode =0, /*< Set the end Slope cursor manually. */
415 psEnd_t50Mode =1, /*< Set the Slope cursor to the half-width of an event. */
416 psEnd_DeltaTMode =2, /*< Set the Slope cursor to a given distance from the first cursor. */
417 psEnd_peakMode =3, /*< Set the Slope cursor to the peak. */
418 psEnd_undefined
419};
420
421#endif // WITH_PSLOPE
422
429
431
432} // end of namespace
433
434inline int stf::round(double toRound) {
435 return toRound <= 0.0 ? int(toRound-0.5) : int(toRound+0.5);
436}
437
438typedef std::vector< wxString >::iterator wxs_it;
439typedef std::vector< wxString >::const_iterator c_wxs_it;
440typedef std::vector< stf::Event >::iterator event_it;
441typedef std::vector< stf::Event >::const_iterator c_event_it;
442typedef std::vector< stf::PyMarker >::iterator marker_it;
443typedef std::vector< stf::PyMarker >::const_iterator c_marker_it;
444
445// Doxygen-links to documentation of frequently used wxWidgets-classes
446
450
454
458
462
466
470
474
478
482
486
490
494
498
502
506
510
514
518
520
521
525
529
533
537
541
543
544#endif
545
WORD TSTime TpMarker WORD size
Definition Son.h:337
Represents the data within a file.
Definition recording.h:44
Represents a continuously sampled sweep of data points.
Definition section.h:36
ProgressInfo class.
Definition stfio.h:69
A table used for printing information.
Definition stfnum.h:152
See http://www.wxwidgets.org/manuals/stable/wx_wxcheckbox.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxdocmdichildframe.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxdocmdiparentframe.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxstring.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxwindow.html (wxWidgets documentation)
std::vector< double > Vector_double
Definition core.h:55
Plugin(const wxString &menuEntry_, const PluginFunc &pluginFunc_, const UserInput &input_=UserInput())
Constructor.
Definition stf.h:180
std::size_t storeFitEnd
Definition stf.h:342
double y
Definition stf.h:330
boost::function< Recording(const Recording &, const Vector_double &, std::map< std::string, double > &)> PluginFunc
Get a Recording, do something with it, return the new Recording.
Definition stf.h:140
bool GetDiscard() const
Indicates whether an event should be discarded.
Definition stf.h:287
static int n_extensions
Definition stf.h:225
std::size_t storeFitBeg
Definition stf.h:341
std::vector< stf::Event > eventList
Definition stf.h:335
~Plugin()
Destructor.
Definition stf.h:191
SectionAttributes sec_attr
Definition stf.h:351
ifstreamMan(const wxString &filename)
Constructor.
Definition stf.h:237
Extension(const std::string &menuEntry_, void *pyFunc_, const std::string &description_, bool requiresFile_)
Constructor.
Definition stf.h:212
Vector_double defaults
Definition stf.h:148
void * pyFunc
Definition stf.h:227
wxString CreatePreview(const wxString &fName)
Creates a preview of a text file.
Section * pSection
Definition stf.h:350
std::size_t GetEventSize() const
Retrieves the size of an event.
Definition stf.h:283
wxFFile myStream
The managed stream.
Definition stf.h:245
int id
Definition stf.h:193
static int n_plugins
Definition stf.h:194
wxString std2wx(const std::string &sst)
std::string description
Definition stf.h:228
~Event()
Destructor.
UserInput input
Definition stf.h:197
std::size_t storeIntBeg
Definition stf.h:343
std::string wx2std(const wxString &wxs)
int round(double toRound)
Does what it says.
Definition stf.h:434
const double PI
Add decimals if you are not satisfied.
Definition stf.h:355
Event(std::size_t start, std::size_t peak, std::size_t size, wxCheckBox *cb)
Constructor.
double x
Definition stf.h:329
std::string menuEntry
Definition stf.h:226
latency_mode
Latency cursor settings.
Definition stf.h:387
void SetEventStartIndex(std::size_t value)
Sets the start index of an event.
Definition stf.h:295
UserInput(const std::vector< std::string > &labels_=std::vector< std::string >(0), const Vector_double &defaults_=Vector_double(0), std::string title_="\0")
Constructor.
Definition stf.h:156
bool Update(int value, const std::string &newmsg="", bool *skip=NULL)
Updates the progress info.
~ifstreamMan()
Destructor.
Definition stf.h:242
wxProgressInfo(const std::string &title, const std::string &message, int maximum, bool verbose=true)
wxString sectionToString(const Section &section)
Converts a Section to a wxString.
~ofstreamMan()
Destructor.
Definition stf.h:258
zoom_channels
Determines which channels to scale.
Definition stf.h:380
std::vector< stf::PyMarker > pyMarkers
Definition stf.h:336
stfnum::Table bestFit
Definition stf.h:345
wxFFile myStream
The managed stream.
Definition stf.h:261
void SetEventSize(std::size_t value)
Sets the size of an event.
Definition stf.h:303
wxString menuEntry
Definition stf.h:195
~Extension()
Destructor.
Definition stf.h:222
PyMarker(double xv, double yv)
Constructor.
Definition stf.h:328
stfnum::storedFunc * fitFunc
Definition stf.h:338
Vector_double bestFitP
Definition stf.h:339
std::vector< std::string > labels
Definition stf.h:147
std::size_t storeIntEnd
Definition stf.h:344
Vector_double quad_p
Definition stf.h:340
std::string title
Definition stf.h:149
bool requiresFile
Definition stf.h:229
extraction_mode
Deconvolution.
Definition stf.h:424
std::size_t GetEventPeakIndex() const
Retrieves the index of an event's peak.
Definition stf.h:279
wxString noPath(const wxString &fName)
Strips the directory off a full path name, returns only the filename.
cursor_type
Mouse cursor types.
Definition stf.h:364
wxCheckBox * GetCheckBox()
Get the check box associated with this event.
Definition stf.h:291
latency_window_mode
Latency window settings.
Definition stf.h:397
PluginFunc pluginFunc
Definition stf.h:196
SectionPointer(Section *pSec=NULL, const SectionAttributes &sa=SectionAttributes())
ofstreamMan(const wxString &filename)
Constructor.
Definition stf.h:253
std::size_t GetEventStartIndex() const
Retrieves the start index of an event.
Definition stf.h:275
void SetEventPeakIndex(std::size_t value)
Sets the index of an event's peak.
Definition stf.h:299
@ footMode
Definition stf.h:392
@ manualMode
Definition stf.h:388
@ peakMode
Definition stf.h:389
@ undefinedMode
Definition stf.h:393
@ riseMode
Definition stf.h:390
@ halfMode
Definition stf.h:391
@ zoomboth
Definition stf.h:383
@ zoomch2
Definition stf.h:382
@ zoomch1
Definition stf.h:381
@ correlation
Definition stf.h:426
@ deconvolution
Definition stf.h:427
@ criterion
Definition stf.h:425
@ annotation_cursor
Definition stf.h:372
@ measure_cursor
Definition stf.h:365
@ undefined_cursor
Definition stf.h:376
@ event_cursor
Definition stf.h:371
@ base_cursor
Definition stf.h:367
@ decay_cursor
Definition stf.h:368
@ latency_cursor
Definition stf.h:369
@ peak_cursor
Definition stf.h:366
@ zoom_cursor
Definition stf.h:370
@ defaultMode
Definition stf.h:398
@ windowMode
Definition stf.h:399
The stimfit namespace.
Definition stf.h:102
std::vector< stf::PyMarker >::const_iterator c_marker_it
Definition stf.h:443
std::vector< stf::Event >::const_iterator c_event_it
Definition stf.h:441
std::vector< wxString >::const_iterator c_wxs_it
Definition stf.h:439
wxDocMDIParentFrame wxStfParentType
parent frame type; depends on whether aui is used for the doc/view interface
Definition stf.h:86
wxDocMDIChildFrame wxStfChildType
child frame type; depends on whether aui is used for the doc/view interface
Definition stf.h:83
std::vector< stf::PyMarker >::iterator marker_it
Definition stf.h:442
std::vector< wxString >::iterator wxs_it
Definition stf.h:438
#define StfDll
Defines dll export or import functions for Windows.
Definition stf.h:55
std::vector< stf::Event >::iterator event_it
Definition stf.h:440
header file for libstfio
Math functions.
Represents user input from dialogs that can be used in plugins.
Definition stf.h:146
Function used for least-squares fitting.
Definition stfnum.h:270
Declares the Zoom struct.