Audacity  3.0.3
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 132 of file ScienFilter.h.

Constructor & Destructor Documentation

◆ EffectScienFilterPanel()

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

Definition at line 822 of file ScienFilter.cpp.

825 : wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
826 {
827  mEffect = effect;
828  mParent = parent;
829 
830  mBitmap = NULL;
831  mWidth = 0;
832  mHeight = 0;
833  mLoFreq = 0.0;
834  mHiFreq = 0.0;
835  mDbMin = 0.0;
836  mDbMax = 0.0;
837 
838  SetFreqRange(lo, hi);
839 }

◆ ~EffectScienFilterPanel()

EffectScienFilterPanel::~EffectScienFilterPanel ( )
virtual

Definition at line 841 of file ScienFilter.cpp.

842 {
843 }

Member Function Documentation

◆ AcceptsFocus()

bool EffectScienFilterPanel::AcceptsFocus ( ) const

Definition at line 859 of file ScienFilter.cpp.

860 {
861  return false;
862 }

◆ AcceptsFocusFromKeyboard()

bool EffectScienFilterPanel::AcceptsFocusFromKeyboard ( ) const

Definition at line 864 of file ScienFilter.cpp.

865 {
866  return false;
867 }

◆ OnPaint()

void EffectScienFilterPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 874 of file ScienFilter.cpp.

875 {
876  wxPaintDC dc(this);
877  int width, height;
878  GetSize(&width, &height);
879 
880  if (!mBitmap || mWidth != width || mHeight != height)
881  {
882  mWidth = width;
883  mHeight = height;
884  mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
885  }
886 
887  wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
888 
889  wxMemoryDC memDC;
890  memDC.SelectObject(*mBitmap);
891 
892  wxRect bkgndRect;
893  bkgndRect.x = 0;
894  bkgndRect.y = 0;
895  bkgndRect.width = mWidth;
896  bkgndRect.height = mHeight;
897  memDC.SetBrush(bkgndBrush);
898  memDC.SetPen(*wxTRANSPARENT_PEN);
899  memDC.DrawRectangle(bkgndRect);
900 
901  bkgndRect.y = mHeight;
902  memDC.DrawRectangle(bkgndRect);
903 
904  wxRect border;
905  border.x = 0;
906  border.y = 0;
907  border.width = mWidth;
908  border.height = mHeight;
909 
910  memDC.SetBrush(*wxWHITE_BRUSH);
911  memDC.SetPen(*wxBLACK_PEN);
912  memDC.DrawRectangle(border);
913 
914  mEnvRect = border;
915  mEnvRect.Deflate(2, 2);
916 
917  // Pure blue x-axis line
918  memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
919  int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
920  AColor::Line(memDC,
921  mEnvRect.GetLeft(), mEnvRect.y + center,
922  mEnvRect.GetRight(), mEnvRect.y + center);
923 
924  //Now draw the actual response that you will get.
925  //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
926  memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
927  double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
928  double yF; // gain at this freq
929 
930  double loLog = log10(mLoFreq);
931  double step = log10(mHiFreq) - loLog;
932  step /= ((double) mEnvRect.width - 1.0);
933  double freq; // actual freq corresponding to x position
934  int x, y, xlast = 0, ylast = 0;
935  for (int i = 0; i < mEnvRect.width; i++)
936  {
937  x = mEnvRect.x + i;
938  freq = pow(10.0, loLog + i * step); //Hz
939  yF = mEffect->FilterMagnAtFreq (freq);
940  yF = LINEAR_TO_DB(yF);
941 
942  if (yF < mDbMin)
943  {
944  yF = mDbMin;
945  }
946 
947  yF = center-scale * yF;
948  if (yF > mEnvRect.height)
949  {
950  yF = (double) mEnvRect.height - 1.0;
951  }
952  if (yF < 0.0)
953  {
954  yF = 0.0;
955  }
956  y = (int) (yF + 0.5);
957 
958  if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
959  {
960  AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
961  }
962  xlast = x;
963  ylast = mEnvRect.y + y;
964  }
965 
966  memDC.SetPen(*wxBLACK_PEN);
967  mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
968  mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
969 
970  dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
971 
972  memDC.SelectObject(wxNullBitmap);
973 }

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 869 of file ScienFilter.cpp.

870 {
871  Refresh(false);
872 }

◆ SetDbRange()

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

Definition at line 852 of file ScienFilter.cpp.

853 {
854  mDbMin = min;
855  mDbMax = max;
856  Refresh(false);
857 }

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 845 of file ScienFilter.cpp.

846 {
847  mLoFreq = lo;
848  mHiFreq = hi;
849  Refresh(false);
850 }

References mHiFreq, and mLoFreq.

Friends And Related Function Documentation

◆ EffectScienFilter

friend class EffectScienFilter
friend

Definition at line 167 of file ScienFilter.h.

Member Data Documentation

◆ mBitmap

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

Definition at line 162 of file ScienFilter.h.

Referenced by OnPaint().

◆ mDbMax

double EffectScienFilterPanel::mDbMax
private

Definition at line 160 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mDbMin

double EffectScienFilterPanel::mDbMin
private

Definition at line 159 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mEffect

EffectScienFilter* EffectScienFilterPanel::mEffect
private

Definition at line 153 of file ScienFilter.h.

Referenced by OnPaint().

◆ mEnvRect

wxRect EffectScienFilterPanel::mEnvRect
private

Definition at line 163 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHeight

int EffectScienFilterPanel::mHeight
private

Definition at line 165 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHiFreq

double EffectScienFilterPanel::mHiFreq
private

Definition at line 157 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mLoFreq

double EffectScienFilterPanel::mLoFreq
private

Definition at line 156 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mParent

wxWindow* EffectScienFilterPanel::mParent
private

Definition at line 154 of file ScienFilter.h.

◆ mWidth

int EffectScienFilterPanel::mWidth
private

Definition at line 164 of file ScienFilter.h.

Referenced by OnPaint().


The documentation for this class was generated from the following files:
EffectScienFilterPanel::mWidth
int mWidth
Definition: ScienFilter.h:164
EffectScienFilterPanel::mEnvRect
wxRect mEnvRect
Definition: ScienFilter.h:163
EffectScienFilterPanel::mHeight
int mHeight
Definition: ScienFilter.h:165
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
EffectScienFilter::mfreqRuler
RulerPanel * mfreqRuler
Definition: ScienFilter.h:125
EffectScienFilter::FilterMagnAtFreq
float FilterMagnAtFreq(float Freq)
Definition: ScienFilter.cpp:646
EffectScienFilterPanel::mDbMax
double mDbMax
Definition: ScienFilter.h:160
EffectScienFilterPanel::mBitmap
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:162
EffectScienFilterPanel::SetFreqRange
void SetFreqRange(double lo, double hi)
Definition: ScienFilter.cpp:845
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectScienFilterPanel::mHiFreq
double mHiFreq
Definition: ScienFilter.h:157
EffectScienFilterPanel::mEffect
EffectScienFilter * mEffect
Definition: ScienFilter.h:153
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
RulerPanel::ruler
Ruler ruler
Definition: Ruler.h:288
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1057
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:631
EffectScienFilterPanel::mParent
wxWindow * mParent
Definition: ScienFilter.h:154
EffectScienFilterPanel::mLoFreq
double mLoFreq
Definition: ScienFilter.h:156
EffectScienFilterPanel::mDbMin
double mDbMin
Definition: ScienFilter.h:159
Ruler::DrawGrid
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:1521
EffectScienFilter::mdBRuler
RulerPanel * mdBRuler
Definition: ScienFilter.h:124