2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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
33 #include <wx/control.h> // Needed for wxControl
34 #include <wx/timer.h> // Needed for wxTimer
37 #include "Color.h" // Needed for COLORREF and RGB
38 #include "Statistics.h" // Needed for StatsGraphType
42 /////////////////////////////////////////////////////////////////////////////
45 #define TIMER_OSCOPE 7641
47 class COScopeCtrl
: public wxControl
49 friend class CStatisticsDlg
;
52 COScopeCtrl(int NTrends
, int nDecimals
, StatsGraphType type
, wxWindow
* parent
=NULL
);
55 void SetRange(float dLower
, float dUpper
, unsigned iTrend
= 0);
56 void SetRanges(float dLower
, float dUpper
);
57 void SetXUnits(const wxString
& string
,
58 const wxString
& XMin
= wxEmptyString
, const wxString
& XMax
= wxEmptyString
);
59 void SetYUnits(const wxString
& string
,
60 const wxString
& YMin
= wxEmptyString
, const wxString
& YMax
= wxEmptyString
);
61 void SetBackgroundColor(COLORREF color
);
62 void SetGridColor(COLORREF color
);
63 void SetPlotColor(COLORREF color
, unsigned iTrend
= 0);
64 COLORREF
GetPlotColor(unsigned iTrend
= 0) {return pdsTrends
[iTrend
].crPlot
;}
65 float GetUpperLimit() { return pdsTrends
[0].fUpperLimit
; }
66 void Reset(double sNewPeriod
);
68 void RecreateGraph(bool bRefresh
=true);
70 void AppendPoints(double sTimestamp
, const std::vector
<float *> &apf
);
71 void DelayPoints() { nDelayedPoints
++; }
72 unsigned GetPlotHeightPixels() { return nPlotHeight
; }
73 unsigned GetPlotWidthPoints() { return nPlotWidth
/nShiftPixels
; }
74 wxBitmap
* GetBitmapPlot() { return bmapPlot
; }
75 wxBitmap
* GetBitmapGrid() { return bmapGrid
; }
77 StatsGraphType graph_type
;
83 unsigned nShiftPixels
; // amount to shift with each new point
86 wxString strXUnits
, strXMin
, strXMax
;
87 wxString strYUnits
, strYMin
, strYMax
;
88 COLORREF crBackground
;
91 typedef struct PlotDataStruct
{
92 COLORREF crPlot
; // data plot color
96 float fLowerLimit
; // lower bounds
97 float fUpperLimit
; // upper bounds
103 DECLARE_EVENT_TABLE()
104 PlotData_t
*pdsTrends
;
119 wxBitmap
* bmapOldGrid
;
120 wxBitmap
* bmapOldPlot
;
123 void InvalidateGraph() { InvalidateCtrl(true, false); }
124 void InvalidateGrid() { InvalidateCtrl(false, true); }
127 int oldwidth
, oldheight
;
128 bool bRecreateGrid
, bRecreateGraph
, bStopped
;
130 double sLastTimestamp
;
133 void OnTimer(wxTimerEvent
& evt
);
134 void OnPaint(wxPaintEvent
& evt
);
135 void OnSize(wxSizeEvent
& evt
);
136 void ShiftGraph(unsigned cntPoints
);
137 void PlotHistory(unsigned cntPoints
, bool bShiftGraph
, bool bRefresh
);
138 void DrawPoints(const std::vector
<float *> &apf
, unsigned cntPoints
);
139 unsigned GetPlotY(float fPlot
, PlotData_t
* ppds
);
140 void InvalidateCtrl(bool bInvalidateGraph
= true, bool bInvalidateGrid
= true);
144 #endif // OSCOPECTRL_H
145 // File_checked_for_headers