|
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 _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()->GetCurCh()).GetZoom(); } 00242 00244 00246 // void set_zoom(const Zoom& zoom_) { Doc()->at(Doc()->GetCurCh()).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 int resLimit; 00290 00291 //Zoom struct 00292 // Zoom zoom; 00293 00294 //Zoom struct to retain StdOut 00295 // Zoom zoomOld; 00296 00297 //Zoom struct for PrintOut 00298 // Zoom zoomPrint; 00299 00300 //Variables for the scaling of the print out 00301 wxRect printRect; 00302 00303 //Printout graphic variables 00304 static const int 00305 boebbelStd=6;//Size of circles for display output 00306 int 00307 boebbel, //Size of circles (for peak, 2080rise time, etc.) 00308 boebbelPrint; //Size of circles for scalable print out 00309 double printScale; 00310 int printSizePen1,//Size of pens for scalable print out 00311 printSizePen2, 00312 printSizePen4, 00313 downsampling, 00314 eventPos; 00315 00316 // ll... means lower limit, ul... means upper limit 00317 double llz_x, ulz_x, llz_y, ulz_y, llz_y2,ulz_y2; 00318 00319 //Three lines of text containing the results 00320 wxString results1, results2, results3,results4, results5, results6; 00321 00322 //Pens are declared here instead of locally to accelerate OnDraw() 00323 //Drawing (pen) styles for the different graphical standard output 00324 wxPen standardPen, standardPen2, standardPen3, scalePen, scalePen2, peakPen, peakLimitPen, 00325 basePen, baseLimitPen, decayLimitPen, ZoomRectPen, fitPen, fitSelectedPen, 00326 selectPen, averagePen, rtPen, hdPen, rdPen, slopePen, latencyPen, 00327 alignPen, measPen, eventPen, PSlopePen; /*CSH*/ 00328 00329 //Drawing (pen) styles for the different graphical standard output 00330 wxPen standardPrintPen, standardPrintPen2, standardPrintPen3, scalePrintPen, scalePrintPen2,measPrintPen, 00331 peakPrintPen, peakLimitPrintPen, basePrintPen, baseLimitPrintPen, 00332 decayLimitPrintPen, fitPrintPen, fitSelectedPrintPen, selectPrintPen, 00333 averagePrintPen, rtPrintPen, hdPrintPen, rdPrintPen, 00334 slopePrintPen, resultsPrintPen, latencyPrintPen, PSlopePrintPen; 00335 00336 wxBrush baseBrush, zeroBrush; 00337 00338 wxPoint lastLDown; 00339 00340 YZoom yzoombg; 00341 00342 boost::shared_ptr<wxMenu> m_zoomContext; 00343 boost::shared_ptr<wxMenu> m_eventContext; 00344 std::vector<wxStfCheckBox*> cbList; 00345 void InitPlot(); 00346 void PlotSelected(wxDC& DC); 00347 void PlotAverage(wxDC& DC); 00348 void DrawZoomRect(wxDC& DC); 00349 void PlotGimmicks(wxDC& DC); 00350 void PlotEvents(wxDC& DC); 00351 void DrawCrosshair( wxDC& DC, const wxPen& pen, const wxPen& printPen, int crosshairSize, double xch, double ych); 00352 void PlotTrace( wxDC* pDC, const Vector_double& trace, plottype pt=active, int bgno=0 ); 00353 void DoPlot( wxDC* pDC, const Vector_double& trace, int start, int end, int step, plottype pt=active, int bgno=0 ); 00354 void PrintScale(wxRect& WindowRect); 00355 void PrintTrace( wxDC* pDC, const Vector_double& trace, plottype ptype=active); 00356 void DoPrint( wxDC* pDC, const Vector_double& trace, int start, int end, plottype ptype=active); 00357 void DrawCircle(wxDC* pDC, double x, double y, const wxPen& pen, const wxPen& printPen); 00358 void DrawVLine(wxDC* pDC, double x, const wxPen& pen, const wxPen& printPen); 00359 void DrawHLine(wxDC* pDC, double y, const wxPen& pen, const wxPen& printPen); 00360 void eventArrow(wxDC* pDC, int eventIndex); 00361 void DrawFit(wxDC* pDC); 00362 void PlotFit( wxDC* pDC, const stf::SectionPointer& Sec ); 00363 void DrawIntegral(wxDC* pDC); 00364 void CreateScale(wxDC* pDC); 00365 00366 // Function receives the x-coordinate of a point and returns 00367 // its formatted value according to the current Zoom settings 00368 int xFormat(double); 00369 int xFormat(int); 00370 int xFormat(std::size_t); 00371 // The same for the y coordinates 00372 int yFormat(double); 00373 int yFormat(int); 00374 int yFormatD(double f) { return yFormat(f); } 00375 // The same for the y coordinates of the second channel 00376 int yFormat2(double); 00377 int yFormat2(int); 00378 int yFormatD2(double f) { return yFormat2(f); } 00379 // The same for the y coordinates of the background channel 00380 int yFormatB(double); 00381 int yFormatB(int); 00382 int yFormatDB(double f) { return yFormatB(f); } 00383 00384 void FittorectY(YZoom& yzoom, const wxRect& rect, double min, double max, double screen_part); 00385 void FitToWindowSecCh(bool refresh); 00386 00387 void LButtonDown(wxMouseEvent& event); 00388 void RButtonDown(wxMouseEvent& event); 00389 void LButtonUp(wxMouseEvent& event); 00390 00391 // shorthand: 00392 wxStfDoc* Doc() { 00393 if (view != NULL) 00394 return view->Doc(); 00395 else 00396 return NULL; 00397 } 00398 wxStfDoc* DocC() const { 00399 if (view != NULL) 00400 return view->DocC(); 00401 else 00402 return NULL; 00403 } 00404 void ChangeXScale(double factor); 00405 void ChangeYScale(double factor); 00406 wxStfParentFrame* ParentFrame(); 00407 void OnZoomHV(wxCommandEvent& event); 00408 void OnZoomH(wxCommandEvent& event); 00409 void OnZoomV(wxCommandEvent& event); 00410 #if defined __WXMAC__ && !(wxCHECK_VERSION(2, 9, 0)) 00411 void OnPaint(wxPaintEvent &event); 00412 #endif 00413 int SPX() const { return DocC()->GetXZoom().startPosX; } 00414 int& SPXW() { return DocC()->GetXZoomW().startPosX; } 00415 int SPY() const { return DocC()->GetYZoom(DocC()->GetCurCh()).startPosY; } 00416 int& SPYW() { return DocC()->GetYZoomW(DocC()->GetCurCh()).startPosY; } 00417 int SPY2() const { return DocC()->GetYZoom(DocC()->GetSecCh()).startPosY; } 00418 int& SPY2W() { return DocC()->GetYZoomW(DocC()->GetSecCh()).startPosY; } 00419 00420 double XZ() const { return DocC()->GetXZoom().xZoom; } 00421 double& XZW() { return DocC()->GetXZoomW().xZoom; } 00422 double YZ() const { return DocC()->GetYZoom(DocC()->GetCurCh()).yZoom; } 00423 double& YZW() { return DocC()->GetYZoomW(DocC()->GetCurCh()).yZoom; } 00424 double YZ2() const { return DocC()->GetYZoom(DocC()->GetSecCh()).yZoom; } 00425 double& YZ2W() { return DocC()->GetYZoomW(DocC()->GetSecCh()).yZoom; } 00426 00427 DECLARE_EVENT_TABLE() 00428 }; 00429 00432 #endif
1.7.4