Skip to content

Commit

Permalink
Adjust length of vertical frequency ticks to prevent overlap with text.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Sep 1, 2023
1 parent 49bdffb commit fda262d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/plot_spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
float f, mag, freq_hz_to_px, mag_dB_to_py;

wxBrush ltGraphBkgBrush;
wxColour foregroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
ltGraphBkgBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT);
ltGraphBkgBrush.SetColour(*wxBLACK);
ltGraphBkgBrush.SetColour(foregroundColor);
ctx->SetBrush(ltGraphBkgBrush);
ctx->SetPen(wxPen(BLACK_COLOR, 1));
ctx->SetPen(wxPen(foregroundColor, 1));

wxGraphicsFont tmpFont = ctx->CreateFont(GetFont(), GetForegroundColour());
ctx->SetFont(tmpFont);
Expand Down Expand Up @@ -228,7 +229,7 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)

ctx->SetPen(m_penShortDash);
ctx->StrokeLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, PLOT_BORDER);
ctx->SetPen(wxPen(BLACK_COLOR, 1));
ctx->SetPen(wxPen(foregroundColor, 1));
ctx->StrokeLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);

snprintf(buf, STR_LENGTH, "%4.0fHz", f);
Expand All @@ -237,7 +238,7 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
ctx->DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
}

ctx->SetPen(wxPen(BLACK_COLOR, 1));
ctx->SetPen(wxPen(foregroundColor, 1));
for(f=STEP_MINOR_F_HZ; f<MAX_F_HZ; f+=STEP_MINOR_F_HZ)
{
x = f*freq_hz_to_px;
Expand Down
6 changes: 3 additions & 3 deletions src/plot_waterfall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,19 @@ void PlotWaterfall::drawGraticule(wxGraphicsContext* ctx)
if (m_graticule)
ctx->StrokeLine(x, m_imgHeight + PLOT_BORDER, x, PLOT_BORDER);
else
ctx->StrokeLine(x, PLOT_BORDER, x, PLOT_BORDER + YBOTTOM_TEXT_OFFSET + 5);
ctx->StrokeLine(x, PLOT_BORDER + 5, x, PLOT_BORDER + YBOTTOM_TEXT_OFFSET + 5);

snprintf(buf, STR_LENGTH, "%4.0fHz", f);
GetTextExtent(buf, &text_w, &text_h);
if (!overlappedText)
ctx->DrawText(buf, x - text_w/2, (YBOTTOM_TEXT_OFFSET/2));
ctx->DrawText(buf, x - text_w/2, (YBOTTOM_TEXT_OFFSET/2) - 5);
}

for(f=STEP_MINOR_F_HZ; f<MAX_F_HZ; f+=STEP_MINOR_F_HZ)
{
x = f*freq_hz_to_px;
x += PLOT_BORDER + XLEFT_OFFSET;
ctx->StrokeLine(x, PLOT_BORDER + 5, x, PLOT_BORDER + YBOTTOM_TEXT_OFFSET + 5);
ctx->StrokeLine(x, PLOT_BORDER + 10, x, PLOT_BORDER + YBOTTOM_TEXT_OFFSET + 5);
}

// Horizontal gridlines
Expand Down

0 comments on commit fda262d

Please sign in to comment.