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 168 of file ScienFilter.h.

Constructor & Destructor Documentation

◆ EffectScienFilterPanel()

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

Definition at line 703 of file ScienFilter.cpp.

706: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
707{
708 mEffect = effect;
709 mParent = parent;
710
711 mBitmap = NULL;
712 mWidth = 0;
713 mHeight = 0;
714 mLoFreq = 0.0;
715 mHiFreq = 0.0;
716 mDbMin = 0.0;
717 mDbMax = 0.0;
718
719 SetFreqRange(lo, hi);
720}
EffectScienFilter * mEffect
Definition: ScienFilter.h:189
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:198
void SetFreqRange(double lo, double hi)

◆ ~EffectScienFilterPanel()

EffectScienFilterPanel::~EffectScienFilterPanel ( )
virtual

Definition at line 722 of file ScienFilter.cpp.

723{
724}

Member Function Documentation

◆ AcceptsFocus()

bool EffectScienFilterPanel::AcceptsFocus ( ) const

Definition at line 740 of file ScienFilter.cpp.

741{
742 return false;
743}

◆ AcceptsFocusFromKeyboard()

bool EffectScienFilterPanel::AcceptsFocusFromKeyboard ( ) const

Definition at line 745 of file ScienFilter.cpp.

746{
747 return false;
748}

◆ OnPaint()

void EffectScienFilterPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 755 of file ScienFilter.cpp.

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

751{
752 Refresh(false);
753}

◆ SetDbRange()

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

Definition at line 733 of file ScienFilter.cpp.

734{
735 mDbMin = min;
736 mDbMax = max;
737 Refresh(false);
738}
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 726 of file ScienFilter.cpp.

727{
728 mLoFreq = lo;
729 mHiFreq = hi;
730 Refresh(false);
731}

References mHiFreq, and mLoFreq.

Friends And Related Function Documentation

◆ EffectScienFilter

friend class EffectScienFilter
friend

Definition at line 203 of file ScienFilter.h.

Member Data Documentation

◆ mBitmap

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

Definition at line 198 of file ScienFilter.h.

Referenced by OnPaint().

◆ mDbMax

double EffectScienFilterPanel::mDbMax
private

Definition at line 196 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mDbMin

double EffectScienFilterPanel::mDbMin
private

Definition at line 195 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mEffect

EffectScienFilter* EffectScienFilterPanel::mEffect
private

Definition at line 189 of file ScienFilter.h.

Referenced by OnPaint().

◆ mEnvRect

wxRect EffectScienFilterPanel::mEnvRect
private

Definition at line 199 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHeight

int EffectScienFilterPanel::mHeight
private

Definition at line 201 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHiFreq

double EffectScienFilterPanel::mHiFreq
private

Definition at line 193 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mLoFreq

double EffectScienFilterPanel::mLoFreq
private

Definition at line 192 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mParent

wxWindow* EffectScienFilterPanel::mParent
private

Definition at line 190 of file ScienFilter.h.

◆ mWidth

int EffectScienFilterPanel::mWidth
private

Definition at line 200 of file ScienFilter.h.

Referenced by OnPaint().


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