Audacity  2.2.2
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:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

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

Constructor & Destructor Documentation

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

Definition at line 1015 of file ScienFilter.cpp.

1018 : wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
1019 {
1020  mEffect = effect;
1021  mParent = parent;
1022 
1023  mBitmap = NULL;
1024  mWidth = 0;
1025  mHeight = 0;
1026  mLoFreq = 0.0;
1027  mHiFreq = 0.0;
1028  mDbMin = 0.0;
1029  mDbMax = 0.0;
1030 
1031  SetFreqRange(lo, hi);
1032 }
void SetFreqRange(double lo, double hi)
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:170
EffectScienFilter * mEffect
Definition: ScienFilter.h:161
EffectScienFilterPanel::~EffectScienFilterPanel ( )
virtual

Definition at line 1034 of file ScienFilter.cpp.

1035 {
1036 }

Member Function Documentation

bool EffectScienFilterPanel::AcceptsFocus ( ) const

Definition at line 1052 of file ScienFilter.cpp.

1053 {
1054  return false;
1055 }
bool EffectScienFilterPanel::AcceptsFocusFromKeyboard ( ) const

Definition at line 1057 of file ScienFilter.cpp.

1058 {
1059  return false;
1060 }
void EffectScienFilterPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 1067 of file ScienFilter.cpp.

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.

1068 {
1069  wxPaintDC dc(this);
1070  int width, height;
1071  GetSize(&width, &height);
1072 
1073  if (!mBitmap || mWidth != width || mHeight != height)
1074  {
1075  mWidth = width;
1076  mHeight = height;
1077  mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight);
1078  }
1079 
1080  wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
1081 
1082  wxMemoryDC memDC;
1083  memDC.SelectObject(*mBitmap);
1084 
1085  wxRect bkgndRect;
1086  bkgndRect.x = 0;
1087  bkgndRect.y = 0;
1088  bkgndRect.width = mWidth;
1089  bkgndRect.height = mHeight;
1090  memDC.SetBrush(bkgndBrush);
1091  memDC.SetPen(*wxTRANSPARENT_PEN);
1092  memDC.DrawRectangle(bkgndRect);
1093 
1094  bkgndRect.y = mHeight;
1095  memDC.DrawRectangle(bkgndRect);
1096 
1097  wxRect border;
1098  border.x = 0;
1099  border.y = 0;
1100  border.width = mWidth;
1101  border.height = mHeight;
1102 
1103  memDC.SetBrush(*wxWHITE_BRUSH);
1104  memDC.SetPen(*wxBLACK_PEN);
1105  memDC.DrawRectangle(border);
1106 
1107  mEnvRect = border;
1108  mEnvRect.Deflate(2, 2);
1109 
1110  // Pure blue x-axis line
1111  memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxSOLID));
1112  int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
1113  AColor::Line(memDC,
1114  mEnvRect.GetLeft(), mEnvRect.y + center,
1115  mEnvRect.GetRight(), mEnvRect.y + center);
1116 
1117  //Now draw the actual response that you will get.
1118  //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
1119  memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxSOLID));
1120  double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
1121  double yF; // gain at this freq
1122 
1123  double loLog = log10(mLoFreq);
1124  double step = log10(mHiFreq) - loLog;
1125  step /= ((double) mEnvRect.width - 1.0);
1126  double freq; // actual freq corresponding to x position
1127  int x, y, xlast = 0, ylast = 0;
1128  for (int i = 0; i < mEnvRect.width; i++)
1129  {
1130  x = mEnvRect.x + i;
1131  freq = pow(10.0, loLog + i * step); //Hz
1132  yF = mEffect->FilterMagnAtFreq (freq);
1133  yF = LINEAR_TO_DB(yF);
1134 
1135  if (yF < mDbMin)
1136  {
1137  yF = mDbMin;
1138  }
1139 
1140  yF = center-scale * yF;
1141  if (yF > mEnvRect.height)
1142  {
1143  yF = (double) mEnvRect.height - 1.0;
1144  }
1145  if (yF < 0.0)
1146  {
1147  yF = 0.0;
1148  }
1149  y = (int) (yF + 0.5);
1150 
1151  if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
1152  {
1153  AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
1154  }
1155  xlast = x;
1156  ylast = mEnvRect.y + y;
1157  }
1158 
1159  memDC.SetPen(*wxBLACK_PEN);
1160  mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
1161  mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
1162 
1163  dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
1164 
1165  memDC.SelectObject(wxNullBitmap);
1166 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:170
RulerPanel * mfreqRuler
Definition: ScienFilter.h:133
float FilterMagnAtFreq(float Freq)
RulerPanel * mdBRuler
Definition: ScienFilter.h:132
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0)
Definition: Ruler.cpp:1465
#define LINEAR_TO_DB(x)
Definition: Audacity.h:217
EffectScienFilter * mEffect
Definition: ScienFilter.h:161
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
Ruler ruler
Definition: Ruler.h:306
void EffectScienFilterPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 1062 of file ScienFilter.cpp.

1063 {
1064  Refresh(false);
1065 }
void EffectScienFilterPanel::SetDbRange ( double  min,
double  max 
)

Definition at line 1045 of file ScienFilter.cpp.

References mDbMax, mDbMin, and min().

Referenced by EffectScienFilter::TransferGraphLimitsFromWindow().

1046 {
1047  mDbMin = min;
1048  mDbMax = max;
1049  Refresh(false);
1050 }
int min(int a, int b)
void EffectScienFilterPanel::SetFreqRange ( double  lo,
double  hi 
)

Definition at line 1038 of file ScienFilter.cpp.

References mHiFreq, and mLoFreq.

1039 {
1040  mLoFreq = lo;
1041  mHiFreq = hi;
1042  Refresh(false);
1043 }

Friends And Related Function Documentation

friend class EffectScienFilter
friend

Definition at line 175 of file ScienFilter.h.

Member Data Documentation

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

Definition at line 170 of file ScienFilter.h.

Referenced by OnPaint().

double EffectScienFilterPanel::mDbMax
private

Definition at line 168 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

double EffectScienFilterPanel::mDbMin
private

Definition at line 167 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

EffectScienFilter* EffectScienFilterPanel::mEffect
private

Definition at line 161 of file ScienFilter.h.

Referenced by OnPaint().

wxRect EffectScienFilterPanel::mEnvRect
private

Definition at line 171 of file ScienFilter.h.

Referenced by OnPaint().

int EffectScienFilterPanel::mHeight
private

Definition at line 173 of file ScienFilter.h.

Referenced by OnPaint().

double EffectScienFilterPanel::mHiFreq
private

Definition at line 165 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

double EffectScienFilterPanel::mLoFreq
private

Definition at line 164 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

wxWindow* EffectScienFilterPanel::mParent
private

Definition at line 162 of file ScienFilter.h.

int EffectScienFilterPanel::mWidth
private

Definition at line 172 of file ScienFilter.h.

Referenced by OnPaint().


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