1
/////////////////////////////////////////////////////////////////////////////
7
// Copyright: (C) 2006, Paolo Gava
8
// RCS-ID: $Id: chart.cpp 4016 2007-05-30 23:08:39Z byo $
9
// Licence: wxWindows licence
10
/////////////////////////////////////////////////////////////////////////////
12
//----------------------------------------------------------------------------
14
//----------------------------------------------------------------------------
17
// For compilers that support precompilation, includes "wx.h".
18
#include <wx/wxprec.h>
26
//----------------------------------------------------------------------------
27
// Define Array/List of Points
28
//----------------------------------------------------------------------------
29
#include <wx/arrimpl.cpp>
30
WX_DEFINE_OBJARRAY(ListChartPoints);
32
//+++-S-cf-------------------------------------------------------------------
37
//----------------------------------------------------------------------E-+++
42
//+++-S-cf-------------------------------------------------------------------
47
//----------------------------------------------------------------------E-+++
52
size_t num = m_LCP.GetCount();
54
for ( size_t loop = 0;
58
cptmp = m_LCP.Item(loop);
65
//+++-S-cf-------------------------------------------------------------------
68
// PARAMETERS: CChartPoints* cp
70
//----------------------------------------------------------------------E-+++
78
//+++-S-cf-------------------------------------------------------------------
83
//----------------------------------------------------------------------E-+++
89
//+++-S-cf-------------------------------------------------------------------
91
// DESC: Get the max x-val calculated from all chartpoints
94
//----------------------------------------------------------------------E-+++
95
ChartValue wxChart::GetMaxX() const
97
ChartValue valTmp, valRes = 0;
99
size_t num = m_LCP.GetCount();
101
for ( size_t loop = 0;
105
valTmp = (m_LCP.Item(loop))->GetMaxX();
106
if ( valTmp > valRes )
110
//-----------------------------------------------------------------------
111
// if MaxX is 0 could be a Pie chart that doesn't have points like
112
// Bar chart so force this to be something != from 0, otherwise
114
//-----------------------------------------------------------------------
121
//+++-S-cf-------------------------------------------------------------------
123
// DESC: Get the min x-val calculated from all chartpoints
125
// RETURN: ChartValue
126
//----------------------------------------------------------------------E-+++
127
ChartValue wxChart::GetMinX() const
129
ChartValue valTmp, valRes = 0;
131
size_t num = m_LCP.GetCount();
133
for ( size_t loop = 0;
137
valTmp = (m_LCP.Item(loop))->GetMinX();
141
if ( valTmp < valRes )
148
//+++-S-cf-------------------------------------------------------------------
150
// DESC: Get the max y-val calculated from all chartpoints
152
// RETURN: ChartValue
153
//----------------------------------------------------------------------E-+++
154
ChartValue wxChart::GetMaxY() const
156
ChartValue valTmp, valRes = 0;
158
size_t num = m_LCP.GetCount();
160
for ( size_t loop = 0;
164
valTmp = (m_LCP.Item(loop))->GetMaxY();
165
if ( valTmp > valRes )
169
//-----------------------------------------------------------------------
170
// if MaxY is 0 could be a Pie chart that doesn't have points like
171
// Bar chart so force this to be something != from 0, otherwise
173
//-----------------------------------------------------------------------
180
//+++-S-cf-------------------------------------------------------------------
182
// DESC: Get the min y-val calculated from all chartpoints
184
// RETURN: ChartValue
185
//----------------------------------------------------------------------E-+++
186
ChartValue wxChart::GetMinY() const
188
ChartValue valTmp, valRes = 0;
190
size_t num = m_LCP.GetCount();
192
for ( size_t loop = 0;
196
valTmp = (m_LCP.Item(loop))->GetMinY();
200
if ( valTmp < valRes )
207
//+++-S-cf-------------------------------------------------------------------
208
// NAME: GetNumBarPoints()
209
// DESC: Number of bar points is used to calculate the width
213
//----------------------------------------------------------------------E-+++
214
int wxChart::GetNumBarPoints() const
218
size_t num = m_LCP.GetCount();
220
for ( size_t loop = 0;
224
if ( *(m_LCP.Item(loop)) == wxChartPointsTypes::Bar() )
231
//+++-S-cf-------------------------------------------------------------------
232
// NAME: GetNumBar3DPoints()
233
// DESC: Number of bar points is used to calculate the width
237
//----------------------------------------------------------------------E-+++
238
int wxChart::GetNumBar3DPoints() const
242
size_t num = m_LCP.GetCount();
244
for ( size_t loop = 0;
248
if ( *(m_LCP.Item(loop)) == wxChartPointsTypes::Bar3D() )
255
//+++-S-cf-------------------------------------------------------------------
258
// PARAMETERS: double
260
//----------------------------------------------------------------------E-+++
261
void wxChart::SetZoom(
265
size_t num = m_LCP.GetCount();
267
for ( size_t loop = 0;
271
(m_LCP.Item(loop))->SetZoom( z );
275
//+++-S-cf-------------------------------------------------------------------
280
//----------------------------------------------------------------------E-+++
281
double wxChart::GetZoom() const
283
size_t num = m_LCP.GetCount();
285
for ( size_t loop = 0;
289
return (m_LCP.Item(loop))->GetZoom();
292
return 1; // default Zoom set to 1
295
//+++-S-cf-------------------------------------------------------------------
297
// DESC: Set sizes for drawing
298
// PARAMETERS: ChartSizes sizes
300
//----------------------------------------------------------------------E-+++
301
void wxChart::SetSizes(
305
size_t num = m_LCP.GetCount();
307
for ( size_t loop = 0;
311
(m_LCP.Item(loop))->SetSizes( sizes );
315
//+++-S-cf-------------------------------------------------------------------
317
// DESC: Get sizes for drawing
319
// RETURN: ChartSizes sizes
320
//----------------------------------------------------------------------E-+++
321
ChartSizes wxChart::GetSizes() const
323
size_t num = m_LCP.GetCount();
325
for ( size_t loop = 0;
329
return (m_LCP.Item(loop))->GetSizes();
335
//+++-S-cf-------------------------------------------------------------------
338
// PARAMETERS: CHART_HPAINT hp,
341
//----------------------------------------------------------------------E-+++
348
int iBar3DCounter = 0;
351
size_t num = m_LCP.GetCount();
352
for ( size_t loop = 0;
356
//-------------------------------------------------------------------
357
// Count the number of Bar-Bar3d charts so when more than one bar is
358
// present the first one is draw at position x, the second one at
359
// position x+1*bar_width so just next to the previous one
360
//-------------------------------------------------------------------
362
ChartSizes sizes = m_LCP.Item(loop)->GetSizes();
365
static_cast<int>(sizes.wbar * m_LCP.Item(loop)->GetZoom()) +
367
static_cast<int>(sizes.wbar3d * m_LCP.Item(loop)->GetZoom())
370
if ( *(m_LCP.Item(loop)) == wxChartPointsTypes::Bar() )
374
else if ( *m_LCP.Item(loop) == wxChartPointsTypes::Bar3D() )
379
//-------------------------------------------------------------------
381
//-------------------------------------------------------------------
382
m_LCP.Item(loop)->Draw( hp, hr );