make axis labels dissapear if windows small enough to make text overlap
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Dec 2012 09:18:22 +0000 (09:18 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Dec 2012 09:18:22 +0000 (09:18 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1110 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/dlg_filter.cpp
fdmdv2/src/fdmdv2_plot_spectrum.cpp
fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp

index ff859a6ada46197fe91f74f91882c3a02fe8a2d5..043dfaa4c0c005a615d4c52349f7679e7f1baab2 100644 (file)
@@ -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();
index a50f65c933fb3a0c5953691f2f0d8d344da629b9..c08154e65ac2664a05aebd0dd2762a7bd39c6f47 100644 (file)
@@ -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<MAX_F_HZ; f+=STEP_F_HZ) {
@@ -197,7 +204,8 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
 
         sprintf(buf, "%4.0fHz", f);
        GetTextExtent(buf, &text_w, &text_h);
-        dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
+        if (!overlappedText)
+            dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
     }
 
     dc.SetPen(wxPen(BLACK_COLOR, 1));
@@ -218,7 +226,8 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
                    (m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
         sprintf(buf, "%3.0fdB", mag);
        GetTextExtent(buf, &text_w, &text_h);
-        dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
+        if (!overlappedText)
+            dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
     }
 
     // red rx tuning line
index a4fc3148c09007d7c0e60bf85d4b3768f763480e..2ad1fb155b9329a1921bac9858492a380ec418a1 100644 (file)
@@ -246,6 +246,14 @@ void PlotWaterfall::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 = WATERFALL_SECS_STEP*time_s_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);
+
     // Major Vertical gridlines and legend
     //dc.SetPen(m_penShortDash);
     for(f=STEP_F_HZ; f<MAX_F_HZ; f+=STEP_F_HZ) 
@@ -260,7 +268,8 @@ void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc)
             
         sprintf(buf, "%4.0fHz", f);
         GetTextExtent(buf, &text_w, &text_h);
-        dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
+        if (!overlappedText)
+            dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
     }
 
     for(f=STEP_MINOR_F_HZ; f<MAX_F_HZ; f+=STEP_MINOR_F_HZ) 
@@ -281,7 +290,8 @@ void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc)
                         (m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
         sprintf(buf, "%3.0fs", time);
        GetTextExtent(buf, &text_w, &text_h);
-        dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
+        if (!overlappedText)
+            dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
    }
 
     // red rx tuning line