193 if( dc.GetPen().IsOk() ==
false ) { dc.SetPen(*wxBLACK); }
195 dc.DrawLine(bx, ay, bx, by);
196 dc.DrawLine(bx, by, ax, by);
197 dc.DrawLine(ax, ay, bx, ay);
198 dc.DrawLine(ax, by, ax, ay);
213 wxPen oldPen(dc.GetPen());
216 dc.DrawLine(bx, ay, bx, by);
217 dc.DrawLine(bx, by, ax, by);
220 dc.DrawLine(ax, by, ax, ay);
221 dc.DrawLine(ax, ay, bx, ay);
230 wxPen oldPen(dc.GetPen());
233 dc.DrawLine(bx, ay, bx, by);
234 dc.DrawLine(bx, by, ax, by);
237 dc.DrawLine(ax, by, ax, ay);
238 dc.DrawLine(ax, ay, bx, ay);
415void SG_DC_Draw_Text (wxDC &dc,
int Align,
int x,
int y,
double Angle,
const wxString &Text,
int Effect, wxColour Effect_Color,
int Effect_Size)
419 wxColour oldColor = dc.GetTextForeground(); dc.SetTextForeground(Effect_Color);
421 if( Effect_Size <= 1 )
436 for(
int d=1; d<=Effect_Size; d++)
450 for(
int dy=y-Effect_Size; dy<=y+Effect_Size; dy++)
452 for(
int dx=x-Effect_Size; dx<=x+Effect_Size; dx++)
459 dc.SetTextForeground(oldColor);
476void SG_DC_Draw_Scale(wxDC &dc,
const wxRect &r,
double zMin,
double zMax,
int Orientation,
int Tick,
int Style,
const wxString &Unit,
bool bUseDCFont)
481 if( zMin >= zMax || Width < 5 || Height < 5 )
487 wxPen oldPen (dc.GetPen ());
488 wxBrush oldBrush(dc.GetBrush());
489 wxFont oldFont (dc.GetFont ());
496 wxRect rTmp; wxColour oldColour(dc.GetTextForeground());
498 dc.SetPen(wxPen(*wxWHITE)); dc.SetTextForeground(*wxWHITE);
500 rTmp = r; rTmp.Offset( 0, 1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
501 rTmp = r; rTmp.Offset( 1, 1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
502 rTmp = r; rTmp.Offset( 1, 0);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
503 rTmp = r; rTmp.Offset( 1, -1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
504 rTmp = r; rTmp.Offset( 0, -1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
505 rTmp = r; rTmp.Offset(-1, -1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
506 rTmp = r; rTmp.Offset(-1, 0);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
507 rTmp = r; rTmp.Offset(-1, 1);
SG_DC_Draw_Scale(dc, rTmp, zMin, zMax, Orientation, Tick, Style, Unit, bUseDCFont);
509 dc.SetPen(oldPen); dc.SetTextForeground(oldColour);
515 wxFont Font(dc.GetFont());
522 wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL
527 double zToDC = (double)Width / (zMax - zMin);
528 double dz = pow(10., floor(log10(zMax - zMin)) - 1.);
529 int Decimals = dz >= 1. ? 0 : (int)floor(-log10(dz));
531 int h = dc.GetTextExtent(wxString::Format(
"%.*f", Decimals, zMax)).GetWidth();
533 while( zToDC * dz < h +
TEXTSPACE ) { dz *= 2; }
536 int Align, x[2], y[2]; h = 0;
559 for(
double z=dz*floor(zMin/dz); !std::isinf(z) && z<=zMax; z+=dz)
564 ? Width - 1 - (int)(zToDC * (z - zMin))
565 : (int)(zToDC * (z - zMin));
569 int xLast = x[0]; x[0] = x[1] = r.GetLeft() + zDC;
573 dc.SetBrush(h++ % 2 ? *wxWHITE : *wxBLACK);
575 dc.DrawRectangle(xLast, y[0], x[1] - xLast, y[1] - y[0]);
580 int yLast = y[0]; y[0] = y[1] = r.GetTop () + zDC;
584 dc.SetBrush(h++ % 2 ? *wxWHITE : *wxBLACK);
586 dc.DrawRectangle(x[0], yLast, x[1] - x[0], y[1] - yLast);
592 dc.DrawLine(x[0], y[0], x[1], y[1]);
596 wxString::Format(
"%.*f", Decimals, z)
606 dc.DrawLine(r.GetLeft(), y[0], x[1], y[0]);
609 if( !Unit.IsEmpty() )
625 dc.DrawLine(x[0], r.GetTop(), x[0], y[1]);
628 if( !Unit.IsEmpty() )
643 dc.SetBrush(oldBrush);
644 dc.SetFont (oldFont );
664bool SG_DC_Draw_Ruler(wxDC &dc,
const wxRect &r,
bool bHorizontal,
double zMin,
double zMax,
bool bAscendent,
int FontSize,
const wxColour &Colour)
666 if( zMin < zMax && r.GetWidth() > 0 && r.GetHeight() > 0 )
669 dc.SetFont(wxFont(FontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
670 dc.SetTextForeground(Colour);
672 double Width = bHorizontal ? r.GetWidth() : r.GetHeight();
675 int xMax = r.GetX() + r.GetWidth();
676 int yMin = r.GetY() + r.GetHeight();
680 double zToDC = (double)Width / (zMax - zMin);
682 double dz = pow(10., floor(log10(zMax - zMin)) - 1.);
683 int Decimals = dz >= 1. ? 0 : (int)fabs(log10(dz));
685 wxSize
Extent = dc.GetTextExtent(wxString::Format(
"%.*f", Decimals, zMax));
689 double zDC = 2 *
Extent.x;
696 double z = dz * floor(zMin / dz);
if( z < zMin ) z += dz;
698 for(; z<=zMax; z+=dz)
700 zDC = bAscendent ? zToDC * (z - zMin) : Width - zToDC * (z - zMin);
704 int zPos = (int)(xMin + zDC);
705 dc.DrawLine(zPos, yMin, zPos, yMax);
706 dc.DrawText(wxString::Format(
"%.*f", Decimals, z), zPos + dxFont, yMin - dyFont);
710 int zPos = (int)(yMin - zDC);
711 dc.DrawLine(xMin, zPos, xMax, zPos);
712 dc.DrawText(wxString::Format(
"%.*f", Decimals, z), xMin + dxFont, zPos - dyFont);