MCPcopy Create free account
hub / github.com/audacity/audacity / DrawPlot

Method DrawPlot

src/FreqWindow.cpp:603–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603void FrequencyPlotDialog::DrawPlot()
604{
605 if (!mData || mDataLen < mWindowSize || mAnalyst->GetProcessedSize() == 0) {
606 wxMemoryDC memDC;
607
608 vRuler->ruler.SetUpdater(&LinearUpdater::Instance());
609 vRuler->ruler.SetRange(0.0, -dBRange);
610
611 hRuler->ruler.SetUpdater(&LinearUpdater::Instance());
612 hRuler->ruler.SetRange(0, 1);
613
614 DrawBackground(memDC);
615
616 if (mDataLen < mWindowSize) {
617 wxString msg = _("Not enough data selected.");
618 wxSize sz = memDC.GetTextExtent(msg);
619 memDC.DrawText(msg,
620 (mPlotRect.GetWidth() - sz.GetWidth()) / 2,
621 (mPlotRect.GetHeight() - sz.GetHeight()) / 2);
622 }
623
624 memDC.SelectObject(wxNullBitmap);
625
626 mFreqPlot->Refresh();
627
628 Refresh();
629
630 return;
631 }
632
633 float yRange = mYMax - mYMin;
634 float yTotal = yRange * ((float) mZoomSlider->GetValue() / 100.0f);
635
636 int sTotal = yTotal * 100;
637 int sRange = yRange * 100;
638 int sPos = mPanScroller->GetThumbPosition() + ((mPanScroller->GetThumbSize() - sTotal) / 2);
639 mPanScroller->SetScrollbar(sPos, sTotal, sRange, sTotal);
640
641 float yMax = mYMax - ((float)sPos / 100);
642 float yMin = yMax - yTotal;
643
644 // Set up y axis ruler
645
646 if (mAlg == SpectrumAnalyst::Spectrum) {
647 vRuler->ruler.SetUnits(XO("dB"));
648 vRuler->ruler.SetFormat(&LinearDBFormat::Instance());
649 } else {
650 vRuler->ruler.SetUnits({});
651 vRuler->ruler.SetFormat(&RealFormat::LinearInstance());
652 }
653 int w1, w2, h;
654 vRuler->ruler.GetMaxSize(&w1, &h);
655 vRuler->ruler.SetRange(yMax, yMin); // Note inversion for vertical.
656 vRuler->ruler.GetMaxSize(&w2, &h);
657 if( w1 != w2 ) // Reduces flicker
658 {
659 vRuler->SetMinSize(wxSize(w2,h));
660 Layout();

Callers

nothing calls this directly

Calls 15

wxPenClass · 0.85
GetProcessedSizeMethod · 0.80
SetUpdaterMethod · 0.80
DrawTextMethod · 0.80
GetHeightMethod · 0.80
SetScrollbarMethod · 0.80
SetUnitsMethod · 0.80
GetProcessedValueMethod · 0.80
DrawGridMethod · 0.80
InstanceClass · 0.50
wxSizeClass · 0.50
SetRangeMethod · 0.45

Tested by

no test coverage detected