2 // This file is part of the aMule Project.
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 )
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
34 #include <wx/control.h> // Needed for wxControl
35 #include <wx/timer.h> // Needed for wxTimer
37 #include <wx/bitmap.h>
38 #include <wx/colour.h>
40 #include "Constants.h" // Needed for StatsGraphType
44 /////////////////////////////////////////////////////////////////////////////
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 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
);
65 void RecreateGraph(bool bRefresh
=true);
67 void AppendPoints(double sTimestamp
, const std::vector
<float *> &apf
);
68 void DelayPoints() { nDelayedPoints
++; }
70 StatsGraphType graph_type
;
76 unsigned nShiftPixels
; // amount to shift with each new point
80 wxString strYUnits
, strYMin
, strYMax
;
82 wxColour m_gridColour
;
84 typedef struct PlotDataStruct
{
85 wxColour crPlot
; // data plot color
89 float fLowerLimit
; // lower bounds
90 float fUpperLimit
; // upper bounds
97 PlotData_t
*pdsTrends
;
105 void InvalidateGraph() { InvalidateCtrl(true, false); }
106 void InvalidateGrid() { InvalidateCtrl(false, true); }
109 bool bRecreateGrid
, bRecreateGraph
, bRecreateAll
, bStopped
;
111 double sLastTimestamp
;
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