Stimfit  0.13.15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
graph.h
Go to the documentation of this file.
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 _GRAPH_H
00022 #define _GRAPH_H
00023 
00028 // forward declarations:
00029 class wxStfView;
00030 class wxStfDoc;
00031 class wxStfParentFrame;
00032 class wxStfCheckBox;
00033 class wxEnhMetaFile;
00034 
00035 #include "./zoom.h"
00036 
00037 enum plottype {
00038     active,
00039     reference,
00040     background
00041 };
00042     
00044 
00048 class StfDll wxStfGraph : public wxScrolledWindow
00049 {
00050 public:
00052 
00057     wxStfGraph(wxView *v, wxStfChildFrame *frame, const wxPoint& pos, const wxSize& size, long style);
00058 
00060 
00062     virtual void OnDraw(wxDC& dc);
00063     
00065 
00069     void Snapshotwmf();
00070 
00072 
00077     void OnMouseEvent(wxMouseEvent& event);
00078 
00080 
00084     void OnKeyDown(wxKeyEvent& event);
00085     
00087 
00090     void OnNext();
00091 
00093 
00096     void OnPrevious();
00097 
00099 
00101     void OnLast();
00102 
00104 
00106     void OnFirst();
00107     
00109 
00112     void OnUp();
00113 
00115 
00118     void OnDown();
00119 
00121 
00124     void OnRight();
00125 
00127 
00130     void OnLeft();
00131 
00133 
00135     void OnXenlhi();
00136 
00138 
00141     void OnXenllo();
00142 
00144 
00147     void OnXshrinklo();
00148 
00150 
00152     void OnXshrinkhi();
00153 
00155 
00157     void OnYenlhi();
00158 
00160 
00163     void OnYenllo();
00164 
00166 
00169     void OnYshrinklo();
00170 
00172 
00174     void OnYshrinkhi();
00175 
00177     void Ch2base();
00178 
00180     void Ch2pos();
00181 
00183     void Ch2zoom();
00184 
00186 
00189     void Ch2basezoom();
00190 
00191 #if 0
00192 
00193     void SwapChannels();
00194 #endif
00195     
00197 
00201     void Fittowindow(bool refresh);
00202 
00204 
00206     void set_isPrinted(bool value);
00207 
00209 
00211     void set_printScale(double value) {printScale=value;}
00212 
00214 
00216     void set_printRect(wxRect value) {printRect=value;}
00217 
00219 
00221     void set_noGimmicks(bool value) {no_gimmicks=value;}
00222 
00224 
00226     void set_downsampling(int value) { downsampling = (value < 1 ? 1 : value); }
00227 
00229 
00231     bool get_noGimmicks() const {return no_gimmicks;}
00232 
00234 
00236     int get_eventPos() const { return eventPos; }
00237 
00239 
00241 //    Zoom get_zoom() { return Doc()->at(Doc()->GetCurChIndex()).GetZoom(); }
00242 
00244 
00246 //    void set_zoom(const Zoom& zoom_) { Doc()->at(Doc()->GetCurChIndex()).GetZoomW()=zoom_; }
00247 
00249     wxStfView *view;
00250 
00252 
00254     double get_plot_xmin() const;
00255 
00257 
00259     double get_plot_xmax() const;
00260 
00262 
00264     double get_plot_ymin() const;
00265 
00267 
00269     double get_plot_ymax() const;
00270     
00272 
00274     double get_plot_y2min() const;
00275 
00277 
00279     double get_plot_y2max() const;
00280 
00281  private:
00282     wxStfChildFrame* pFrame;
00283     bool isZoomRect; //True if zoom window is set
00284     bool no_gimmicks; //True if no extra rulers/lines and circles shall be displayed
00285     bool isPrinted; //True when the View is drawn to a printer 
00286     bool isLatex;
00287     bool firstPass;
00288     bool isSyncx;
00289 
00290     //Zoom struct
00291 //    Zoom zoom;
00292 
00293     //Zoom struct to retain StdOut
00294 //    Zoom zoomOld;
00295 
00296     //Zoom struct for PrintOut
00297 //    Zoom zoomPrint;
00298 
00299     //Variables for the scaling of the print out
00300     wxRect printRect;
00301 
00302     //Printout graphic variables
00303     static const int
00304         boebbelStd=6;//Size of circles for display output
00305     int
00306         boebbel, //Size of circles (for peak, 2080rise time, etc.)
00307         boebbelPrint; //Size of circles for scalable print out
00308     double printScale;
00309     int  printSizePen1,//Size of pens for scalable print out 
00310         printSizePen2,
00311         printSizePen4,
00312         downsampling,
00313         eventPos;
00314 
00315     // ll... means lower limit, ul... means upper limit
00316     double llz_x, ulz_x, llz_y, ulz_y, llz_y2,ulz_y2;
00317 
00318     //Three lines of text containing the results
00319     wxString results1, results2, results3,results4, results5, results6; 
00320 
00321     //Pens are declared here instead of locally to accelerate OnDraw()
00322     //Drawing (pen) styles for the different graphical standard output
00323     wxPen standardPen, standardPen2, standardPen3, scalePen, scalePen2, peakPen, peakLimitPen,
00324         basePen, baseLimitPen, decayLimitPen, ZoomRectPen, fitPen, fitSelectedPen,
00325         selectPen, averagePen, rtPen, hdPen, rdPen, slopePen, latencyPen,
00326         alignPen, measPen, eventPen, PSlopePen;                                         /*CSH*/
00327 
00328     //Drawing (pen) styles for the different graphical standard output
00329     wxPen standardPrintPen, standardPrintPen2, standardPrintPen3, scalePrintPen, scalePrintPen2,measPrintPen,
00330         peakPrintPen, peakLimitPrintPen, basePrintPen, baseLimitPrintPen,
00331         decayLimitPrintPen, fitPrintPen, fitSelectedPrintPen, selectPrintPen,
00332         averagePrintPen, rtPrintPen, hdPrintPen, rdPrintPen,
00333         slopePrintPen, resultsPrintPen, latencyPrintPen, PSlopePrintPen;
00334 
00335     wxBrush baseBrush, zeroBrush;
00336     
00337     wxPoint lastLDown;
00338 
00339     YZoom yzoombg;
00340     
00341     boost::shared_ptr<wxMenu> m_zoomContext;
00342     boost::shared_ptr<wxMenu> m_eventContext;
00343     std::vector<wxStfCheckBox*> cbList;
00344     void InitPlot();
00345     void PlotSelected(wxDC& DC);
00346     void PlotAverage(wxDC& DC);
00347     void DrawZoomRect(wxDC& DC);
00348     void PlotGimmicks(wxDC& DC);
00349     void PlotEvents(wxDC& DC);
00350     void DrawCrosshair( wxDC& DC, const wxPen& pen, const wxPen& printPen, int crosshairSize, double xch, double ych);
00351     void PlotTrace( wxDC* pDC, const Vector_double& trace, plottype pt=active, int bgno=0 );
00352     void DoPlot( wxDC* pDC, const Vector_double& trace, int start, int end, int step, plottype pt=active, int bgno=0 );
00353     void PrintScale(wxRect& WindowRect);
00354     void PrintTrace( wxDC* pDC, const Vector_double& trace, plottype ptype=active);
00355     void DoPrint( wxDC* pDC, const Vector_double& trace, int start, int end, plottype ptype=active);
00356     void DrawCircle(wxDC* pDC, double x, double y, const wxPen& pen, const wxPen& printPen);
00357     void DrawVLine(wxDC* pDC, double x, const wxPen& pen, const wxPen& printPen);
00358     void DrawHLine(wxDC* pDC, double y, const wxPen& pen, const wxPen& printPen);
00359     void eventArrow(wxDC* pDC, int eventIndex);
00360     void DrawFit(wxDC* pDC);
00361     void PlotFit( wxDC* pDC, const stf::SectionPointer& Sec );
00362     void DrawIntegral(wxDC* pDC);
00363     void CreateScale(wxDC* pDC);
00364 
00365     // Function receives the x-coordinate of a point and returns 
00366     // its formatted value according to the current Zoom settings
00367     int xFormat(double);
00368     int xFormat(int); 
00369     int xFormat(std::size_t); 
00370     // The same for the y coordinates
00371     int yFormat(double);
00372     int yFormat(int);
00373     int yFormatD(double f) { return yFormat(f); }
00374     // The same for the y coordinates of the second channel
00375     int yFormat2(double);
00376     int yFormat2(int);
00377     int yFormatD2(double f) { return yFormat2(f); }
00378     // The same for the y coordinates of the background channel
00379     int yFormatB(double);
00380     int yFormatB(int);
00381     int yFormatDB(double f) { return yFormatB(f); }
00382 
00383     void FittorectY(YZoom& yzoom, const wxRect& rect, double min, double max, double screen_part);
00384     void FitToWindowSecCh(bool refresh);
00385 
00386     void LButtonDown(wxMouseEvent& event);
00387     void RButtonDown(wxMouseEvent& event);
00388     void LButtonUp(wxMouseEvent& event);
00389 
00390     // shorthand:
00391     wxStfDoc* Doc() {
00392         if (view != NULL) 
00393             return view->Doc();
00394         else
00395             return NULL;
00396     }
00397     wxStfDoc* DocC() const {
00398         if (view != NULL) 
00399             return view->DocC();
00400         else
00401             return NULL;
00402     }
00403     void ChangeXScale(double factor);
00404     void ChangeYScale(double factor);
00405     wxStfParentFrame* ParentFrame();
00406     void OnZoomHV(wxCommandEvent& event);
00407     void OnZoomH(wxCommandEvent& event);
00408     void OnZoomV(wxCommandEvent& event);
00409 #if defined __WXMAC__ && !(wxCHECK_VERSION(2, 9, 0))
00410     void OnPaint(wxPaintEvent &event);
00411 #endif
00412     int SPX() const { return DocC()->GetXZoom().startPosX; }
00413     int& SPXW() { return DocC()->GetXZoomW().startPosX; } 
00414     int SPY() const { return DocC()->GetYZoom(DocC()->GetCurChIndex()).startPosY; }
00415     int& SPYW() { return DocC()->GetYZoomW(DocC()->GetCurChIndex()).startPosY; } 
00416     int SPY2() const { return DocC()->GetYZoom(DocC()->GetSecChIndex()).startPosY; }
00417     int& SPY2W() { return DocC()->GetYZoomW(DocC()->GetSecChIndex()).startPosY; }
00418     
00419     double XZ() const { return DocC()->GetXZoom().xZoom; }
00420     double& XZW() { return DocC()->GetXZoomW().xZoom; }
00421     double YZ() const { return DocC()->GetYZoom(DocC()->GetCurChIndex()).yZoom; }
00422     double& YZW() { return DocC()->GetYZoomW(DocC()->GetCurChIndex()).yZoom; }
00423     double YZ2() const { return DocC()->GetYZoom(DocC()->GetSecChIndex()).yZoom; }
00424     double& YZ2W() { return DocC()->GetYZoomW(DocC()->GetSecChIndex()).yZoom; }
00425     
00426     DECLARE_EVENT_TABLE()
00427 };
00428 
00431 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines