Update Wiki URL
[amule.git] / src / OScopeCtrl.h
blob62cd69b34f21d71bb4f6d6706cd9d6d1ebf64ea5
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef OSCOPECTRL_H
27 #define OSCOPECTRL_H
29 #ifndef NULL
30 #define NULL 0
31 #endif
33 #include <vector>
34 #include <wx/control.h> // Needed for wxControl
35 #include <wx/timer.h> // Needed for wxTimer
36 #include <wx/pen.h>
37 #include <wx/bitmap.h>
38 #include <wx/colour.h>
40 #include "Constants.h" // Needed for StatsGraphType
42 class wxMemoryDC;
44 /////////////////////////////////////////////////////////////////////////////
45 // COScopeCtrl window
47 class COScopeCtrl : public wxControl
49 friend class CStatisticsDlg;
51 public:
52 COScopeCtrl(int NTrends, int nDecimals, StatsGraphType type, wxWindow* parent = NULL);
53 ~COScopeCtrl();
55 void SetRange(float dLower, float dUpper, unsigned iTrend = 0);
56 void SetRanges(float dLower, float dUpper);
57 void SetYUnits(const wxString& string,
58 const wxString& YMin = wxEmptyString, const wxString& YMax = wxEmptyString);
59 void SetBackgroundColor(const wxColour& color);
60 void SetGridColor(const wxColour& color);
61 void SetPlotColor(const wxColour& color, unsigned iTrend = 0);
62 float GetUpperLimit() { return pdsTrends[0].fUpperLimit; }
63 void Reset(double sNewPeriod);
64 void Stop();
65 void RecreateGraph(bool bRefresh=true);
66 void RecreateGrid();
67 void AppendPoints(double sTimestamp, const std::vector<float *> &apf);
68 void DelayPoints() { nDelayedPoints++; }
70 StatsGraphType graph_type;
72 public:
73 unsigned nTrends;
74 unsigned nXGrids;
75 unsigned nYGrids;
76 unsigned nShiftPixels; // amount to shift with each new point
77 unsigned nYDecimals;
79 wxString strXUnits;
80 wxString strYUnits, strYMin, strYMax;
81 wxColour m_bgColour;
82 wxColour m_gridColour;
84 typedef struct PlotDataStruct {
85 wxColour crPlot; // data plot color
86 wxPen penPlot;
87 unsigned yPrev;
88 float fPrev;
89 float fLowerLimit; // lower bounds
90 float fUpperLimit; // upper bounds
91 float fVertScale;
92 } PlotData_t ;
95 protected:
96 DECLARE_EVENT_TABLE()
97 PlotData_t *pdsTrends;
99 wxRect m_rectClient;
100 wxRect m_rectPlot;
101 wxBrush brushBack;
102 wxBitmap m_bmapGrid;
103 wxBitmap m_bmapPlot;
105 void InvalidateGraph() { InvalidateCtrl(true, false); }
106 void InvalidateGrid() { InvalidateCtrl(false, true); }
108 private:
109 bool bRecreateGrid, bRecreateGraph, bRecreateAll, bStopped;
110 int nDelayedPoints;
111 double sLastTimestamp;
112 double sLastPeriod;
113 wxTimer timerRedraw;
114 bool m_onPaint;
116 void OnTimer(wxTimerEvent& evt);
117 void OnPaint(wxPaintEvent& evt);
118 void OnSize(wxSizeEvent& evt);
119 void ShiftGraph(unsigned cntPoints);
120 void PlotHistory(unsigned cntPoints, bool bShiftGraph, bool bRefresh);
121 void DrawPoints(const std::vector<float *> &apf, unsigned cntPoints);
122 unsigned GetPlotY(float fPlot, PlotData_t* ppds);
123 void InvalidateCtrl(bool bInvalidateGraph = true, bool bInvalidateGrid = true);
126 #endif // OSCOPECTRL_H
127 // File_checked_for_headers