Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
graph.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 _GRAPH_H
22#define _GRAPH_H
23
27
28// forward declarations:
29class wxStfView;
30class wxStfDoc;
32class wxStfCheckBox;
33class wxEnhMetaFile;
34
35#include "./zoom.h"
36
42
44
48class StfDll wxStfGraph : public wxScrolledWindow
49{
50public:
52
57 wxStfGraph(wxView *v, wxStfChildFrame *frame, const wxPoint& pos, const wxSize& size, long style);
58
60
62 virtual void OnDraw(wxDC& dc);
63
65
70
72
77 void OnMouseEvent(wxMouseEvent& event);
78
80
84 void OnKeyDown(wxKeyEvent& event);
85
87
90 void ChangeTrace(std::size_t trace);
91
93
96 void OnNext();
97
99
103
105
107 void OnLast();
108
110
112 void OnFirst();
113
115
118 void OnUp();
119
121
124 void OnDown();
125
127
130 void OnRight();
131
133
136 void OnLeft();
137
139
141 void OnXenlhi();
142
144
147 void OnXenllo();
148
150
154
156
159
161
163 void OnYenlhi();
164
166
169 void OnYenllo();
170
172
176
178
181
183 void Ch2base();
184
186 void Ch2pos();
187
189 void Ch2zoom();
190
192
196
198 void ChanScroll(int direction);
199
200
201 #if 0
203 void SwapChannels();
204#endif
205
207
211 void Fittowindow(bool refresh);
212
215
217
219 void set_isPrinted(bool value);
220
222
224 void set_printScale(double value) {printScale=value;}
225
227
229 void set_printRect(wxRect value) {printRect=value;}
230
232
234 void set_noGimmicks(bool value) {no_gimmicks=value;}
235
237
239 void set_downsampling(int value) { downsampling = (value < 1 ? 1 : value); }
240
242
244 bool get_noGimmicks() const {return no_gimmicks;}
245
247
249 int get_eventPos() const { return eventPos; }
250
252
254 // Zoom get_zoom() { return Doc()->at(Doc()->GetCurChIndex()).GetZoom(); }
255
257
259 // void set_zoom(const Zoom& zoom_) { Doc()->at(Doc()->GetCurChIndex()).GetZoomW()=zoom_; }
260
263
265
267 double get_plot_xmin() const;
268
270
272 double get_plot_xmax() const;
273
275
277 double get_plot_ymin() const;
278
280
282 double get_plot_ymax() const;
283
285
287 double get_plot_y2min() const;
288
290
292 double get_plot_y2max() const;
293
294private:
295 wxStfChildFrame* pFrame;
296 bool isZoomRect; //True if zoom window is set
297 bool no_gimmicks; //True if no extra rulers/lines and circles shall be displayed
298 bool isPrinted; //True when the View is drawn to a printer
299 bool isLatex;
300 bool firstPass;
301 bool isSyncx;
302
303 //Zoom struct
304 // Zoom zoom;
305
306 //Zoom struct to retain StdOut
307 // Zoom zoomOld;
308
309 //Zoom struct for PrintOut
310 // Zoom zoomPrint;
311
312 //Variables for the scaling of the print out
313 wxRect printRect;
314
315 //Printout graphic variables
316 static const int
317 boebbelStd=6;//Size of circles for display output
318 int
319 boebbel, //Size of circles (for peak, 2080rise time, etc.)
320 boebbelPrint; //Size of circles for scalable print out
321 double printScale;
322 int printSizePen1,//Size of pens for scalable print out
323 printSizePen2,
324 printSizePen4,
325 downsampling,
326 eventPos;
327
328 // ll... means lower limit, ul... means upper limit
329 double llz_x, ulz_x, llz_y, ulz_y, llz_y2,ulz_y2;
330
331 //Three lines of text containing the results
332 wxString results1, results2, results3,results4, results5, results6;
333
334 //Pens are declared here instead of locally to accelerate OnDraw()
335 //Drawing (pen) styles for the different graphical standard output
336 wxPen standardPen, standardPen2, standardPen3, scalePen, scalePen2, peakPen, peakLimitPen,
337 basePen, baseLimitPen, decayLimitPen, ZoomRectPen, fitPen, fitSelectedPen,
338 selectPen, averagePen, rtPen, hdPen, rdPen, slopePen, latencyPen,
339 alignPen, measPen, eventPen, PSlopePen; /*CSH*/
340
341 //Drawing (pen) styles for the different graphical standard output
342 wxPen standardPrintPen, standardPrintPen2, standardPrintPen3, scalePrintPen, scalePrintPen2,measPrintPen,
343 peakPrintPen, peakLimitPrintPen, basePrintPen, baseLimitPrintPen,
344 decayLimitPrintPen, fitPrintPen, fitSelectedPrintPen, selectPrintPen,
345 averagePrintPen, rtPrintPen, hdPrintPen, rdPrintPen,
346 slopePrintPen, resultsPrintPen, latencyPrintPen, PSlopePrintPen;
347
348 wxBrush baseBrush, zeroBrush;
349
350 wxPoint lastLDown;
351
352 YZoom yzoombg;
353
354#if (__cplusplus < 201103)
355 boost::shared_ptr<wxMenu> m_zoomContext;
356 boost::shared_ptr<wxMenu> m_eventContext;
357 boost::shared_ptr<wxMenu> m_annotationContext;
358#else
359 std::shared_ptr<wxMenu> m_zoomContext;
360 std::shared_ptr<wxMenu> m_eventContext;
361 std::shared_ptr<wxMenu> m_annotationContext;
362#endif
363
364 void InitPlot();
365 void PlotSelected(wxDC& DC);
366 void PlotAverage(wxDC& DC);
367 void DrawZoomRect(wxDC& DC);
368 void PlotGimmicks(wxDC& DC);
369 void PlotEvents(wxDC& DC);
370 void PlotAnnotations(wxDC& DC);
371 void DrawCrosshair( wxDC& DC, const wxPen& pen, const wxPen& printPen, int crosshairSize, double xch, double ych);
372 void PlotTrace( wxDC* pDC, const Vector_double& trace, plottype pt=active, int bgno=0 );
373 void DoPlot( wxDC* pDC, const Vector_double& trace, int start, int end, int, plottype pt=active, int bgno=0 );
374 void PrintScale(wxRect& WindowRect);
375 void PrintTrace( wxDC* pDC, const Vector_double& trace, plottype ptype=active);
376 void DoPrint( wxDC* pDC, const Vector_double& trace, int start, int end, plottype ptype=active);
377 void DrawCircle(wxDC* pDC, double x, double y, const wxPen& pen, const wxPen& printPen);
378 void DrawVLine(wxDC* pDC, double x, const wxPen& pen, const wxPen& printPen);
379 void DrawHLine(wxDC* pDC, double y, const wxPen& pen, const wxPen& printPen);
380 void eventArrow(wxDC* pDC, int eventIndex);
381 void DrawFit(wxDC* pDC);
382 void PlotFit( wxDC* pDC, const stf::SectionPointer& Sec );
383 void DrawIntegral(wxDC* pDC);
384 void CreateScale(wxDC* pDC);
385
386 // Function receives the x-coordinate of a point and returns
387 // its formatted value according to the current Zoom settings
388 long xFormat(double);
389 long xFormat(long);
390 long xFormat(int);
391 long xFormat(std::size_t);
392 // The same for the y coordinates
393 long yFormat(double);
394 long yFormat(long);
395 long yFormat(int);
396 long yFormatD(double f) { return yFormat(f); }
397 // The same for the y coordinates of the second channel
398 long yFormat2(double);
399 long yFormat2(long);
400 long yFormat2(int);
401 long yFormatD2(double f) { return yFormat2(f); }
402 // The same for the y coordinates of the background channel
403 long yFormatB(double);
404 long yFormatB(long);
405 long yFormatB(int);
406 long yFormatDB(double f) { return yFormatB(f); }
407
408 void FittorectY(YZoom& yzoom, const wxRect& rect, double min, double max, double screen_part);
409 void FitToWindowSecCh(bool refresh);
410
411 void LButtonDown(wxMouseEvent& event);
412 void RButtonDown(wxMouseEvent& event);
413 void LButtonUp(wxMouseEvent& event);
414
415 // shorthand:
416 wxStfDoc* Doc() {
417 if (view != NULL)
418 return view->Doc();
419 else
420 return NULL;
421 }
422 wxStfDoc* DocC() const {
423 if (view != NULL)
424 return view->DocC();
425 else
426 return NULL;
427 }
428 void ChangeXScale(double factor);
429 void ChangeYScale(double factor);
430 wxStfParentFrame* ParentFrame();
431 void OnZoomHV(wxCommandEvent& event);
432 void OnZoomH(wxCommandEvent& event);
433 void OnZoomV(wxCommandEvent& event);
434#if defined __WXMAC__ && !(wxCHECK_VERSION(2, 9, 0))
435 void OnPaint(wxPaintEvent &event);
436#endif
437 long SPX() const { return DocC()->GetXZoom().startPosX; }
438 long& SPXW() { return DocC()->GetXZoomW().startPosX; }
439 long SPY() const { return DocC()->GetYZoom(DocC()->GetCurChIndex()).startPosY; }
440 long& SPYW() { return DocC()->GetYZoomW(DocC()->GetCurChIndex()).startPosY; }
441 long SPY2() const { return DocC()->GetYZoom(DocC()->GetSecChIndex()).startPosY; }
442 long& SPY2W() { return DocC()->GetYZoomW(DocC()->GetSecChIndex()).startPosY; }
443
444 double XZ() const { return DocC()->GetXZoom().xZoom; }
445 double& XZW() { return DocC()->GetXZoomW().xZoom; }
446 double YZ() const { return DocC()->GetYZoom(DocC()->GetCurChIndex()).yZoom; }
447 double& YZW() { return DocC()->GetYZoomW(DocC()->GetCurChIndex()).yZoom; }
448 double YZ2() const { return DocC()->GetYZoom(DocC()->GetSecChIndex()).yZoom; }
449 double& YZ2W() { return DocC()->GetYZoomW(DocC()->GetSecChIndex()).yZoom; }
450
451 DECLARE_EVENT_TABLE()
452};
453
455
456#endif
#define min(a, b)
Definition ArrayPtr.hpp:25
#define max(a, b)
Definition ArrayPtr.hpp:24
WORD TSTime TpMarker WORD size
Definition Son.h:337
Handles y-scaling of traces.
Definition zoom.h:25
See http://www.wxwidgets.org/manuals/stable/wx_wxpoint.html (wxWidgets documentation)
See http://www.wxwidgets.org/manuals/stable/wx_wxsize.html (wxWidgets documentation)
Provides the child frame for displaying documents on separate windows.
Definition childframe.h:63
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)
std::vector< double > Vector_double
Definition core.h:55
void set_noGimmicks(bool value)
Set to true if the results table and the cursors should be printed.
Definition graph.h:234
void OnXshrinkhi()
Shrinks the x-scale by a factor of 2.
void OnYenlhi()
Enlarges the y-scale by a factor of 2.
wxStfDoc * DocC() const
Retrieve the attached document.
int get_eventPos() const
Returns the y-position of a right click when in event-detection mode.
Definition graph.h:249
void OnYenllo()
Enlarges the y-scale by a factor of 1.1.
void OnFirst()
Show and analyse first trace.
void OnRight()
Moves the traces right by 20 px.
wxStfDoc * Doc()
Retrieve the attached document.
double get_plot_xmax() const
Returns x value of the right screen border.
void Ch2pos()
Adjust y-positioning so that channel 1 and 2 are at the same absolute y-position.
double get_plot_ymin() const
Returns y value of the bottom screen border.
void OnMouseEvent(wxMouseEvent &event)
Handles mouse events.
void Ch2zoom()
Adjust y-scale so that channel 1 and 2 have the same y-scale.
void ChanScroll(int direction)
advance / decrement the active channel by one
void set_printScale(double value)
Sets the printing scale to the specified value.
Definition graph.h:224
void set_printRect(wxRect value)
Sets the size of the printout to the epcified rectangle.
Definition graph.h:229
void set_isPrinted(bool value)
Set to true if the graph is drawn on a printer.
void OnPrevious()
Show and analyse previous trace.
void Ch2base()
Adjust y-positioning so that the baselines of channel 1 and 2 are at the same y-position.
void OnXenllo()
Enlarges the x-scale by a factor of 1.1.
void OnYshrinkhi()
Shrinks the y-scale by a factor of 2.
void OnXenlhi()
Enlarges the x-scale by a factor of 2.
wxStfGraph(wxView *v, wxStfChildFrame *frame, const wxPoint &pos, const wxSize &size, long style)
Constructor.
void OnLast()
Show and analyse last trace.
void OnXshrinklo()
Shrinks the x-scale by a factor of 1.1.
void OnUp()
Moves the traces up by 20 px.
void ClearEvents()
Destroys all event check boxes.
void ChangeTrace(std::size_t trace)
Change trace.
virtual void OnDraw(wxDC &dc)
The central drawing function. Used for drawing to any output device, such as a printer or a screen.
void set_downsampling(int value)
Prints every n-th point.
Definition graph.h:239
double get_plot_y2max() const
Returns y value of the top screen border for the reference channel.
void OnDown()
Moves the traces down by 20 px.
double get_plot_ymax() const
Returns y value of the top screen border.
void Ch2basezoom()
Combines Ch2zoom() and Ch2base().
void Fittowindow(bool refresh)
Fits the graph to the window.
void OnKeyDown(wxKeyEvent &event)
Handles keyboard input.
double get_plot_xmin() const
Returns x value of the left screen border.
void OnYshrinklo()
Shrinks the y-scale by a factor of 1.1.
double get_plot_y2min() const
Returns y value of the bottom screen border for the reference channel.
wxStfView * view
Returns the current zoom struct.
Definition graph.h:262
void OnNext()
Show and analyse next trace.
void OnLeft()
Moves the traces left by 20 px.
plottype
Definition graph.h:37
void Snapshotwmf()
Copies the drawing to the clipboard as a windows metafile.
bool get_noGimmicks() const
Indicates whether everything (cursors, results table, etc.) is printed out.
Definition graph.h:244
@ background
Definition graph.h:40
@ active
Definition graph.h:38
@ reference
Definition graph.h:39
#define StfDll
Defines dll export or import functions for Windows.
Definition stf.h:55
Declares the Zoom struct.