1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef LINE_CHART_RENDERER_H 6 #define LINE_CHART_RENDERER_H 7 8 #include <InterfaceDefs.h> 9 #include <Rect.h> 10 11 #include <ObjectList.h> 12 13 #include "chart/ChartDataRange.h" 14 #include "chart/ChartRenderer.h" 15 16 17 class BView; 18 19 20 class LineChartRenderer : public ChartRenderer { 21 public: 22 class DataSourceConfig; 23 24 public: 25 LineChartRenderer(); 26 virtual ~LineChartRenderer(); 27 28 virtual bool AddDataSource(ChartDataSource* dataSource, 29 int32 index, 30 ChartRendererDataSourceConfig* config); 31 virtual void RemoveDataSource(ChartDataSource* dataSource); 32 33 virtual void SetFrame(const BRect& frame); 34 virtual void SetDomain(const ChartDataRange& domain); 35 virtual void SetRange(const ChartDataRange& range); 36 37 virtual void Render(BView* view, BRect updateRect); 38 39 private: 40 struct DataSourceInfo; 41 42 typedef BObjectList<DataSourceInfo> DataSourceList; 43 44 private: 45 void _InvalidateSamples(); 46 bool _UpdateSamples(); 47 48 private: 49 DataSourceList fDataSources; 50 BRect fFrame; 51 ChartDataRange fDomain; 52 ChartDataRange fRange; 53 }; 54 55 56 class LineChartRendererDataSourceConfig : public ChartRendererDataSourceConfig { 57 public: 58 LineChartRendererDataSourceConfig(); 59 LineChartRendererDataSourceConfig( 60 const rgb_color& color); 61 virtual ~LineChartRendererDataSourceConfig(); 62 63 const rgb_color& Color() const; 64 void SetColor(const rgb_color& color); 65 66 private: 67 rgb_color fColor; 68 }; 69 70 71 #endif // LINE_CHART_RENDERER_H 72