//+++-S-cf------------------------------------------------------------------- // NAME: DrawArrow() // DESC: Draw arrow // PARAMETERS: CHART_HPAINT hp, // int x, // int y, // int size, // int pos, // bool over // RETURN: None //----------------------------------------------------------------------E-+++ void wxLegend::DrawArrow( CHART_HPAINT hp, int x, int y, int size, int pos, bool over ) { if ( pos == ARROW_DOWN ) size *= (-1); wxPoint points[] = { wxPoint( x, y ), wxPoint( x - size, y + size ), wxPoint( x + size, y + size) }; hp->DrawPolygon( 3, points ); if ( pos == ARROW_UP ) { m_ArrowUp.m_x = x; m_ArrowUp.m_y = y; m_ArrowUp.m_d = y + size/2; m_ArrowUp.m_sel = over; } else { m_ArrowDown.m_x = x; m_ArrowDown.m_y = y; m_ArrowDown.m_d = y + size/2;; m_ArrowDown.m_sel = over; } }
//+++-S-cf------------------------------------------------------------------- // NAME: Draw() // DESC: Draw Bar chart // PARAMETERS: CHART_HPAINT hp, // CHART_HRECT hr // RETURN: None //----------------------------------------------------------------------E-+++ void wxBar3DChartPoints::Draw( CHART_HPAINT hp, CHART_HRECT hr ) { //----------------------------------------------------------------------- // get number of bars //----------------------------------------------------------------------- double iNodes = ceil( static_cast<double>(GetCount()) ); //----------------------------------------------------------------------- // Get sizes //----------------------------------------------------------------------- wxChartSizes *sizes = GetSizes(); //----------------------------------------------------------------------- // get max height //----------------------------------------------------------------------- double ValMax = ceil( sizes->GetMaxY() ); if ( ValMax == 0 ) ValMax = 1; hp->SetBrush( wxBrush(GetColor(), wxSOLID) ); //hp->SetPen( *wxTRANSPARENT_PEN ); //hp->SetPen( *wxLIGHT_GREY_PEN ); hp->SetPen( wxPen(wxChartColors::GetDarkColor(GetColor(), 15)) ); double x, y, w, h; //----------------------------------------------------------------------- // Get the real width of the bar // Assume 80% of sizes->GetWidthBar3d() //----------------------------------------------------------------------- w = sizes->GetWidthBar3d() * 0.80; //----------------------------------------------------------------------- // Get how mutch high deep the bar should start. // Suppose we to use 30 degree // rad = 2 * pi / 360 * grd //----------------------------------------------------------------------- h = ( sizes->GetWidthBar3d() - w ) / cos( 0.5236 ) * sin( 0.5236 ); h *= GetZoom(); for ( int iNode = 0; iNode < iNodes; ++ iNode ) { //------------------------------------------------------------------- // Get x-position for iNode bar //------------------------------------------------------------------- double xVal = ceil( GetXVal(iNode) ); x = hr->x + GetZoom() * xVal * ( sizes->GetWidthBar() * sizes->GetNumBar() + sizes->GetWidthBar3d() * sizes->GetNumBar3d() + sizes->GetGap() ); //------------------------------------------------------------------- // Get y-position for iNode bar //------------------------------------------------------------------- y = hr->y + ( (hr->h - sizes->GetSizeHeight() )* GetYVal(iNode) ) / ValMax ; hp->DrawRectangle( static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), static_cast<int>(ceil(w * GetZoom())), static_cast<int>(ceil(y))); //------------------------------------------------------------------- // Draw Poligon next to main Rectangle //------------------------------------------------------------------- hp->SetBrush( wxBrush(wxChartColors::GetDarkColor(GetColor(), 10), wxSOLID) ); //------------------------------------------------------------------- // Make sure that the difference y and y - h is at lease 1 //------------------------------------------------------------------- int y1 = static_cast<int>(ceil(static_cast<double>(hr->h))); int y2 = static_cast<int>(ceil(static_cast<double>(hr->h - h))); int y3 = static_cast<int>(ceil(static_cast<double>(hr->h - y - h))); int y4 = static_cast<int>(ceil(static_cast<double>(hr->h - y))); int d = y1 - y2 > y4 - y3 ? y1 - y2 : y4 - y3; if ( d == 0 ) d += 1; wxPoint next[] = { wxPoint( static_cast<int>(ceil(x + w * GetZoom())), y1 ), wxPoint( static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), y1 - d ), wxPoint( static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), y4 - d ), wxPoint( static_cast<int>(ceil(x + w * GetZoom())), y4 ), }; hp->DrawPolygon( 4, next ); //------------------------------------------------------------------- // Draw Poligon on top of main Rectangle //------------------------------------------------------------------- wxPoint top[] = { wxPoint( static_cast<int>(ceil(x)), y4 ), wxPoint( static_cast<int>(ceil(x + w * GetZoom())), y4 ), wxPoint( static_cast<int>(ceil(x + sizes->GetWidthBar3d() * GetZoom())), y4 - d ), wxPoint( static_cast<int>(ceil(x + (sizes->GetWidthBar3d() - w) * GetZoom())), y4 - d ), }; hp->DrawPolygon( 4, top ); hp->SetBrush( wxBrush(GetColor(), wxSOLID) ); //------------------------------------------------------------------- // Only draw Label if user wants it //------------------------------------------------------------------- if (!m_ShowLabel) continue; wxString lbl; wxLabel wxLbl; switch ( GetDisplayTag() ) { case XVALUE: lbl.Printf( wxT("%d"), static_cast<int>(xVal)); wxLbl.Draw( hp, static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), GetColor(), lbl, UP); break; case YVALUE: lbl.Printf( wxT("%d"), static_cast<int>(GetYVal(iNode))); wxLbl.Draw( hp, static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), GetColor(), lbl, UP ); break; case XVALUE_FLOAT: lbl.Printf( wxT("%4.1f"), xVal); wxLbl.Draw( hp, static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), GetColor(), lbl, UP); break; case YVALUE_FLOAT: lbl.Printf( wxT("%4.1f"), GetYVal(iNode)); wxLbl.Draw( hp, static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), GetColor(), lbl, UP ); break; case NAME: lbl = GetName(iNode).c_str(); wxLbl.Draw( hp, static_cast<int>(ceil(x)), static_cast<int>(ceil(hr->h - y)), GetColor(), lbl, UP ); break; default: break; } } hp->SetPen( *wxBLACK_PEN ); }