From: drowe67 Date: Sun, 2 Dec 2012 09:18:22 +0000 (+0000) Subject: make axis labels dissapear if windows small enough to make text overlap X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=7e83a4d0b0aed2f16de2d80a111ea5b7df8143ff;p=freetel-svn-tracking.git make axis labels dissapear if windows small enough to make text overlap git-svn-id: https://svn.code.sf.net/p/freetel/code@1110 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/dlg_filter.cpp b/fdmdv2/src/dlg_filter.cpp index ff859a6a..043dfaa4 100644 --- a/fdmdv2/src/dlg_filter.cpp +++ b/fdmdv2/src/dlg_filter.cpp @@ -153,7 +153,7 @@ FilterDlg::FilterDlg(wxWindow* parent, bool running, wxWindowID id, const wxStri m_sdbSizer5OK = new wxButton(this, wxID_OK); bSizer31->Add(m_sdbSizer5OK, 0, wxALL, 2); - bSizer30->Add(bSizer31, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0); + bSizer30->Add(bSizer31, 0, wxALIGN_RIGHT|wxALL, 0); this->SetSizer(bSizer30); this->Layout(); diff --git a/fdmdv2/src/fdmdv2_plot_spectrum.cpp b/fdmdv2/src/fdmdv2_plot_spectrum.cpp index a50f65c9..c08154e6 100644 --- a/fdmdv2/src/fdmdv2_plot_spectrum.cpp +++ b/fdmdv2/src/fdmdv2_plot_spectrum.cpp @@ -119,40 +119,37 @@ void PlotSpectrum::draw(wxAutoBufferedPaintDC& dc) // draw spectrum - if(m_newdata) + int x, y, prev_x, prev_y, index; + float index_to_px, mag_dB_to_py, mag; + + m_newdata = false; + + wxPen pen; + pen.SetColour(DARK_GREEN_COLOR); + pen.SetWidth(1); + dc.SetPen(pen); + + //index_to_px = ((float)FDMDV_MAX_F_HZ/(float)MAX_F_HZ)*(float)m_rGrid.GetWidth()/FDMDV_NSPEC; + index_to_px = (float)m_rGrid.GetWidth()/m_n_magdB; + mag_dB_to_py = (float)m_rGrid.GetHeight()/(m_max_mag_db - m_min_mag_db); + //int last_index = ((float)MAX_F_HZ/(float)FDMDV_MAX_F_HZ)*FDMDV_NSPEC; + + prev_x = PLOT_BORDER + XLEFT_OFFSET; + prev_y = PLOT_BORDER; + for(index = 0; index < m_n_magdB; index++) { - int x, y, prev_x, prev_y, index; - float index_to_px, mag_dB_to_py, mag; - - m_newdata = false; - - wxPen pen; - pen.SetColour(DARK_GREEN_COLOR); - pen.SetWidth(1); - dc.SetPen(pen); - - //index_to_px = ((float)FDMDV_MAX_F_HZ/(float)MAX_F_HZ)*(float)m_rGrid.GetWidth()/FDMDV_NSPEC; - index_to_px = (float)m_rGrid.GetWidth()/m_n_magdB; - mag_dB_to_py = (float)m_rGrid.GetHeight()/(m_max_mag_db - m_min_mag_db); - int last_index = ((float)MAX_F_HZ/(float)FDMDV_MAX_F_HZ)*FDMDV_NSPEC; - - prev_x = PLOT_BORDER + XLEFT_OFFSET; - prev_y = PLOT_BORDER; - for(index = 0; index < m_n_magdB; index++) - { - x = index*index_to_px; - mag = m_magdB[index]; - if (mag > m_max_mag_db) mag = m_max_mag_db; - if (mag < m_min_mag_db) mag = m_min_mag_db; - y = -(mag - m_max_mag_db) * mag_dB_to_py; - - x += PLOT_BORDER + XLEFT_OFFSET; - y += PLOT_BORDER; - - if (index) - dc.DrawLine(x, y, prev_x, prev_y); - prev_x = x; prev_y = y; - } + x = index*index_to_px; + mag = m_magdB[index]; + if (mag > m_max_mag_db) mag = m_max_mag_db; + if (mag < m_min_mag_db) mag = m_min_mag_db; + y = -(mag - m_max_mag_db) * mag_dB_to_py; + + x += PLOT_BORDER + XLEFT_OFFSET; + y += PLOT_BORDER; + + if (index) + dc.DrawLine(x, y, prev_x, prev_y); + prev_x = x; prev_y = y; } // and finally draw Graticule @@ -184,6 +181,16 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC& dc) // lower RH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET + m_rGrid.GetWidth(), // PLOT_BORDER + m_rGrid.GetHeight()) + // Check if small screen size means text will overlap + + int textXStep = STEP_F_HZ*freq_hz_to_px; + int textYStep = STEP_MAG_DB*mag_dB_to_py; + sprintf(buf, "%4.0fHz", (float)MAX_F_HZ - STEP_F_HZ); + GetTextExtent(buf, &text_w, &text_h); + int overlappedText = (text_w > textXStep) || (text_h > textYStep); + //printf("text_w: %d textXStep: %d text_h: %d textYStep: %d overlappedText: %d\n", text_w, textXStep, + // text_h, textYStep, overlappedText); + // Vertical gridlines for(f=STEP_F_HZ; f textXStep) || (text_h > textYStep); + // Major Vertical gridlines and legend //dc.SetPen(m_penShortDash); for(f=STEP_F_HZ; f