Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
EffectScienFilterPanel Class Referencefinal

EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter. More...

#include <ScienFilter.h>

Inheritance diagram for EffectScienFilterPanel:
[legend]
Collaboration diagram for EffectScienFilterPanel:
[legend]

Public Member Functions

 EffectScienFilterPanel (wxWindow *parent, wxWindowID winid, EffectScienFilter *effect, double lo, double hi)
 
virtual ~EffectScienFilterPanel ()
 
bool AcceptsFocus () const
 
bool AcceptsFocusFromKeyboard () const
 
void SetFreqRange (double lo, double hi)
 
void SetDbRange (double min, double max)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 

Private Attributes

EffectScienFiltermEffect
 
wxWindow * mParent
 
double mLoFreq
 
double mHiFreq
 
double mDbMin
 
double mDbMax
 
std::unique_ptr< wxBitmap > mBitmap
 
wxRect mEnvRect
 
int mWidth
 
int mHeight
 

Friends

class EffectScienFilter
 

Detailed Description

EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter.

Definition at line 170 of file ScienFilter.h.

Constructor & Destructor Documentation

◆ EffectScienFilterPanel()

EffectScienFilterPanel::EffectScienFilterPanel ( wxWindow *  parent,
wxWindowID  winid,
EffectScienFilter effect,
double  lo,
double  hi 
)

Definition at line 710 of file ScienFilter.cpp.

713: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
714{
715 mEffect = effect;
716 mParent = parent;
717
718 mBitmap = NULL;
719 mWidth = 0;
720 mHeight = 0;
721 mLoFreq = 0.0;
722 mHiFreq = 0.0;
723 mDbMin = 0.0;
724 mDbMax = 0.0;
725
726 SetFreqRange(lo, hi);
727}
EffectScienFilter * mEffect
Definition: ScienFilter.h:191
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:200
void SetFreqRange(double lo, double hi)

◆ ~EffectScienFilterPanel()

EffectScienFilterPanel::~EffectScienFilterPanel ( )
virtual

Definition at line 729 of file ScienFilter.cpp.

730{
731}

Member Function Documentation

◆ AcceptsFocus()

bool EffectScienFilterPanel::AcceptsFocus ( ) const

Definition at line 747 of file ScienFilter.cpp.

748{
749 return false;
750}

◆ AcceptsFocusFromKeyboard()

bool EffectScienFilterPanel::AcceptsFocusFromKeyboard ( ) const

Definition at line 752 of file ScienFilter.cpp.

753{
754 return false;
755}

◆ OnPaint()

void EffectScienFilterPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 762 of file ScienFilter.cpp.

763{
764 wxPaintDC dc(this);
765 int width, height;
766 GetSize(&width, &height);
767
768 if (!mBitmap || mWidth != width || mHeight != height)
769 {
770 mWidth = width;
771 mHeight = height;
772 mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
773 }
774
775 wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
776
777 wxMemoryDC memDC;
778 memDC.SelectObject(*mBitmap);
779
780 wxRect bkgndRect;
781 bkgndRect.x = 0;
782 bkgndRect.y = 0;
783 bkgndRect.width = mWidth;
784 bkgndRect.height = mHeight;
785 memDC.SetBrush(bkgndBrush);
786 memDC.SetPen(*wxTRANSPARENT_PEN);
787 memDC.DrawRectangle(bkgndRect);
788
789 bkgndRect.y = mHeight;
790 memDC.DrawRectangle(bkgndRect);
791
792 wxRect border;
793 border.x = 0;
794 border.y = 0;
795 border.width = mWidth;
796 border.height = mHeight;
797
798 memDC.SetBrush(*wxWHITE_BRUSH);
799 memDC.SetPen(*wxBLACK_PEN);
800 memDC.DrawRectangle(border);
801
802 mEnvRect = border;
803 mEnvRect.Deflate(2, 2);
804
805 // Pure blue x-axis line
806 memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
807 int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
808 AColor::Line(memDC,
809 mEnvRect.GetLeft(), mEnvRect.y + center,
810 mEnvRect.GetRight(), mEnvRect.y + center);
811
812 //Now draw the actual response that you will get.
813 //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
814 memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
815 double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
816 double yF; // gain at this freq
817
818 double loLog = log10(mLoFreq);
819 double step = log10(mHiFreq) - loLog;
820 step /= ((double) mEnvRect.width - 1.0);
821 double freq; // actual freq corresponding to x position
822 int x, y, xlast = 0, ylast = 0;
823 for (int i = 0; i < mEnvRect.width; i++)
824 {
825 x = mEnvRect.x + i;
826 freq = pow(10.0, loLog + i * step); //Hz
827 yF = mEffect->FilterMagnAtFreq (freq);
828 yF = LINEAR_TO_DB(yF);
829
830 if (yF < mDbMin)
831 {
832 yF = mDbMin;
833 }
834
835 yF = center-scale * yF;
836 if (yF > mEnvRect.height)
837 {
838 yF = (double) mEnvRect.height - 1.0;
839 }
840 if (yF < 0.0)
841 {
842 yF = 0.0;
843 }
844 y = (int) (yF + 0.5);
845
846 if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
847 {
848 AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
849 }
850 xlast = x;
851 ylast = mEnvRect.y + y;
852 }
853
854 memDC.SetPen(*wxBLACK_PEN);
855 mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
856 mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
857
858 dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
859
860 memDC.SelectObject(wxNullBitmap);
861}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:185
RulerPanel * mdBRuler
Definition: ScienFilter.h:129
RulerPanel * mfreqRuler
Definition: ScienFilter.h:130
float FilterMagnAtFreq(float Freq)
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:530
Ruler ruler
Definition: RulerPanel.h:79
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), Ruler::DrawGrid(), EffectScienFilter::FilterMagnAtFreq(), AColor::Line(), LINEAR_TO_DB, mBitmap, mDbMax, mDbMin, EffectScienFilter::mdBRuler, mEffect, mEnvRect, EffectScienFilter::mfreqRuler, mHeight, mHiFreq, mLoFreq, mWidth, RulerPanel::ruler, and theTheme.

Here is the call graph for this function:

◆ OnSize()

void EffectScienFilterPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 757 of file ScienFilter.cpp.

758{
759 Refresh(false);
760}

◆ SetDbRange()

void EffectScienFilterPanel::SetDbRange ( double  min,
double  max 
)

Definition at line 740 of file ScienFilter.cpp.

741{
742 mDbMin = min;
743 mDbMax = max;
744 Refresh(false);
745}
int min(int a, int b)

References mDbMax, mDbMin, and min().

Referenced by EffectScienFilter::TransferGraphLimitsFromWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFreqRange()

void EffectScienFilterPanel::SetFreqRange ( double  lo,
double  hi 
)

Definition at line 733 of file ScienFilter.cpp.

734{
735 mLoFreq = lo;
736 mHiFreq = hi;
737 Refresh(false);
738}

References mHiFreq, and mLoFreq.

Friends And Related Function Documentation

◆ EffectScienFilter

friend class EffectScienFilter
friend

Definition at line 205 of file ScienFilter.h.

Member Data Documentation

◆ mBitmap

std::unique_ptr<wxBitmap> EffectScienFilterPanel::mBitmap
private

Definition at line 200 of file ScienFilter.h.

Referenced by OnPaint().

◆ mDbMax

double EffectScienFilterPanel::mDbMax
private

Definition at line 198 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mDbMin

double EffectScienFilterPanel::mDbMin
private

Definition at line 197 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mEffect

EffectScienFilter* EffectScienFilterPanel::mEffect
private

Definition at line 191 of file ScienFilter.h.

Referenced by OnPaint().

◆ mEnvRect

wxRect EffectScienFilterPanel::mEnvRect
private

Definition at line 201 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHeight

int EffectScienFilterPanel::mHeight
private

Definition at line 203 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHiFreq

double EffectScienFilterPanel::mHiFreq
private

Definition at line 195 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mLoFreq

double EffectScienFilterPanel::mLoFreq
private

Definition at line 194 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mParent

wxWindow* EffectScienFilterPanel::mParent
private

Definition at line 192 of file ScienFilter.h.

◆ mWidth

int EffectScienFilterPanel::mWidth
private

Definition at line 202 of file ScienFilter.h.

Referenced by OnPaint().


The documentation for this class was generated from the following files: