7
7
// Copyright: (C) 2006, Paolo Gava
8
// RCS-ID: $Id: barchartpoints.cpp 4016 2007-05-30 23:08:39Z byo $
8
// RCS-ID: $Id: barchartpoints.cpp 5961 2009-12-08 06:24:32Z mortenmacfly $
9
9
// Licence: wxWindows licence
10
10
/////////////////////////////////////////////////////////////////////////////
32
35
#include "wx/label.h"
33
36
#include "wx/barchartpoints.h"
37
#include "wx/chartsizes.h"
35
39
//+++-S-cf-------------------------------------------------------------------
37
41
// DESC: has to be created on the heap!
38
// PARAMETERS: std::string name,
42
// PARAMETERS: std::string name,
41
45
//----------------------------------------------------------------------E-+++
42
46
wxBarChartPoints::wxBarChartPoints(
46
50
) : wxChartPoints(wxChartPointsTypes::Bar()),
51
m_ShowLabel( showlabel)
55
m_ShowLabel( showlabel)
55
59
//+++-S-cf-------------------------------------------------------------------
58
62
// PARAMETERS: int n
60
64
//----------------------------------------------------------------------E-+++
180
184
//----------------------------------------------------------------------E-+++
181
185
double wxBarChartPoints::GetZoom()
187
return ( m_Sizes->GetXZoom() );
186
190
//+++-S-cf-------------------------------------------------------------------
187
191
// NAME: SetSizes
188
192
// DESC: Set sizes for drawing
189
// PARAMETERS: ChartSizes sizes
193
// PARAMETERS: wxChartSizes sizes
191
195
//----------------------------------------------------------------------E-+++
192
196
void wxBarChartPoints::SetSizes(
200
204
// NAME: GetSizes
201
205
// DESC: Get sizes for drawing
202
206
// PARAMETERS: None
203
// RETURN: ChartSizes sizes
207
// RETURN: wxChartSizes sizes
204
208
//----------------------------------------------------------------------E-+++
205
const ChartSizes& wxBarChartPoints::GetSizes() const
209
wxChartSizes* wxBarChartPoints::GetSizes() const
207
211
return ( m_Sizes );
210
214
//+++-S-cf-------------------------------------------------------------------
211
215
// NAME: GetColor()
213
217
// PARAMETERS: None
214
218
// RETURN: unsigned long
215
219
//----------------------------------------------------------------------E-+++
258
262
//+++-S-cf-------------------------------------------------------------------
260
264
// DESC: Add point
261
// PARAMETERS: std::string name,
265
// PARAMETERS: std::string name,
265
269
//----------------------------------------------------------------------E-+++
266
270
void wxBarChartPoints::Add(
275
279
//+++-S-cf-------------------------------------------------------------------
277
281
// DESC: Add point
278
// PARAMETERS: std::string name,
282
// PARAMETERS: std::string name,
283
287
//----------------------------------------------------------------------E-+++
284
288
void wxBarChartPoints::Add(
288
292
ChartColor WXUNUSED(c)
321
325
//+++-S-cf-------------------------------------------------------------------
323
327
// DESC: Draw Bar chart
324
// PARAMETERS: CHART_HPAINT hp,
328
// PARAMETERS: CHART_HPAINT hp,
325
329
// CHART_HRECT hr
327
331
//----------------------------------------------------------------------E-+++
328
332
void wxBarChartPoints::Draw(
336
340
double iNodes = ceil( static_cast<double>(GetCount()) );
338
342
//-----------------------------------------------------------------------
344
//-----------------------------------------------------------------------
345
wxChartSizes *sizes = GetSizes();
347
//-----------------------------------------------------------------------
339
348
// get max height
340
349
//-----------------------------------------------------------------------
341
double ValMax = ceil( GetMaxY() );
350
double ValMax = ceil( sizes->GetMaxY() );
345
//-----------------------------------------------------------------------
347
//-----------------------------------------------------------------------
348
ChartSizes sizes = GetSizes();
350
354
hp->SetBrush( wxBrush(GetColor(), wxSOLID) );
351
355
hp->SetPen( *wxTRANSPARENT_PEN );
357
361
// Get x-position for iNode bar
358
362
//-------------------------------------------------------------------
359
363
double xVal = ceil( GetXVal(iNode) );
360
x = hr->x + GetZoom() * xVal * ( sizes.wbar * sizes.nbar +
361
sizes.wbar3d * sizes.nbar3d +
364
x = hr->x + GetZoom() * xVal * ( sizes->GetWidthBar() *
366
sizes->GetWidthBar3d() * sizes->GetNumBar3d() +
364
369
//-------------------------------------------------------------------
365
370
// Get y-position for iNode bar
366
371
//-------------------------------------------------------------------
367
y = hr->y + ( (hr->h - sizes.s_height)* GetYVal(iNode) ) / ValMax ;
372
y = hr->y + ( (hr->h - sizes->GetSizeHeight())*
373
GetYVal(iNode) ) / ValMax ;
369
375
hp->DrawRectangle( static_cast<int>(ceil(x)),
370
376
static_cast<int>(ceil(hr->h - y)),
371
static_cast<int>(sizes.wbar * GetZoom()),
377
static_cast<int>(sizes->GetWidthBar() * GetZoom()),
372
378
static_cast<int>(ceil(y)) );
374
380
//-------------------------------------------------------------------
375
381
// Only draw Label if user wants it
376
382
//-------------------------------------------------------------------
382
388
switch ( GetDisplayTag() )
385
lbl.Printf( wxT("%d"), static_cast<int>(xVal));
386
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
387
static_cast<int>(ceil(hr->h - y)),
393
lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iNode)));
394
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
395
static_cast<int>(ceil(hr->h - y)),
401
lbl = GetName(iNode).c_str();
402
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
403
static_cast<int>(ceil(hr->h - y)),
391
lbl.Printf( wxT("%d"), static_cast<int>(xVal));
392
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
393
static_cast<int>(ceil(hr->h - y)),
399
lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iNode)));
400
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
401
static_cast<int>(ceil(hr->h - y)),
407
lbl.Printf( wxT("%4.1f"), xVal);
408
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
409
static_cast<int>(ceil(hr->h - y)),
415
lbl.Printf( wxT("%4.1f"), GetYVal(iNode));
416
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
417
static_cast<int>(ceil(hr->h - y)),
423
lbl = GetName(iNode).c_str();
424
wxLbl.Draw( hp, static_cast<int>(ceil(x)),
425
static_cast<int>(ceil(hr->h - y)),