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

Constructor & Destructor Documentation

◆ EffectScienFilterPanel()

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

Definition at line 452 of file ScienFilter.cpp.

455: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
456{
457 mEffect = effect;
458 mParent = parent;
459
460 mBitmap = NULL;
461 mWidth = 0;
462 mHeight = 0;
463 mLoFreq = 0.0;
464 mHiFreq = 0.0;
465 mDbMin = 0.0;
466 mDbMax = 0.0;
467
468 SetFreqRange(lo, hi);
469}
EffectScienFilter * mEffect
Definition: ScienFilter.h:108
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:117
void SetFreqRange(double lo, double hi)

◆ ~EffectScienFilterPanel()

EffectScienFilterPanel::~EffectScienFilterPanel ( )
virtual

Definition at line 471 of file ScienFilter.cpp.

472{
473}

Member Function Documentation

◆ AcceptsFocus()

bool EffectScienFilterPanel::AcceptsFocus ( ) const

Definition at line 489 of file ScienFilter.cpp.

490{
491 return false;
492}

◆ AcceptsFocusFromKeyboard()

bool EffectScienFilterPanel::AcceptsFocusFromKeyboard ( ) const

Definition at line 494 of file ScienFilter.cpp.

495{
496 return false;
497}

◆ OnPaint()

void EffectScienFilterPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 504 of file ScienFilter.cpp.

505{
506 wxPaintDC dc(this);
507 int width, height;
508 GetSize(&width, &height);
509
510 if (!mBitmap || mWidth != width || mHeight != height)
511 {
512 mWidth = width;
513 mHeight = height;
514 mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
515 }
516
517 wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
518
519 wxMemoryDC memDC;
520 memDC.SelectObject(*mBitmap);
521
522 wxRect bkgndRect;
523 bkgndRect.x = 0;
524 bkgndRect.y = 0;
525 bkgndRect.width = mWidth;
526 bkgndRect.height = mHeight;
527 memDC.SetBrush(bkgndBrush);
528 memDC.SetPen(*wxTRANSPARENT_PEN);
529 memDC.DrawRectangle(bkgndRect);
530
531 bkgndRect.y = mHeight;
532 memDC.DrawRectangle(bkgndRect);
533
534 wxRect border;
535 border.x = 0;
536 border.y = 0;
537 border.width = mWidth;
538 border.height = mHeight;
539
540 memDC.SetBrush(*wxWHITE_BRUSH);
541 memDC.SetPen(*wxBLACK_PEN);
542 memDC.DrawRectangle(border);
543
544 mEnvRect = border;
545 mEnvRect.Deflate(2, 2);
546
547 // Pure blue x-axis line
548 memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
549 int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
550 AColor::Line(memDC,
551 mEnvRect.GetLeft(), mEnvRect.y + center,
552 mEnvRect.GetRight(), mEnvRect.y + center);
553
554 //Now draw the actual response that you will get.
555 //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
556 memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
557 double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
558 double yF; // gain at this freq
559
560 double loLog = log10(mLoFreq);
561 double step = log10(mHiFreq) - loLog;
562 step /= ((double) mEnvRect.width - 1.0);
563 double freq; // actual freq corresponding to x position
564 int x, y, xlast = 0, ylast = 0;
565 for (int i = 0; i < mEnvRect.width; i++)
566 {
567 x = mEnvRect.x + i;
568 freq = pow(10.0, loLog + i * step); //Hz
569 yF = mEffect->FilterMagnAtFreq (freq);
570 yF = LINEAR_TO_DB(yF);
571
572 if (yF < mDbMin)
573 {
574 yF = mDbMin;
575 }
576
577 yF = center-scale * yF;
578 if (yF > mEnvRect.height)
579 {
580 yF = (double) mEnvRect.height - 1.0;
581 }
582 if (yF < 0.0)
583 {
584 yF = 0.0;
585 }
586 y = (int) (yF + 0.5);
587
588 if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
589 {
590 AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
591 }
592 xlast = x;
593 ylast = mEnvRect.y + y;
594 }
595
596 memDC.SetPen(*wxBLACK_PEN);
597 mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
598 mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
599
600 dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
601
602 memDC.SelectObject(wxNullBitmap);
603}
#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:194
RulerPanel * mdBRuler
Definition: ScienFilter.h:81
RulerPanel * mfreqRuler
Definition: ScienFilter.h:82
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
float FilterMagnAtFreq(float Freq)
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), Ruler::DrawGrid(), ScienFilterBase::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 499 of file ScienFilter.cpp.

500{
501 Refresh(false);
502}

◆ SetDbRange()

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

Definition at line 482 of file ScienFilter.cpp.

483{
484 mDbMin = min;
485 mDbMax = max;
486 Refresh(false);
487}
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 475 of file ScienFilter.cpp.

476{
477 mLoFreq = lo;
478 mHiFreq = hi;
479 Refresh(false);
480}

References mHiFreq, and mLoFreq.

Friends And Related Function Documentation

◆ EffectScienFilter

friend class EffectScienFilter
friend

Definition at line 122 of file ScienFilter.h.

Member Data Documentation

◆ mBitmap

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

Definition at line 117 of file ScienFilter.h.

Referenced by OnPaint().

◆ mDbMax

double EffectScienFilterPanel::mDbMax
private

Definition at line 115 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mDbMin

double EffectScienFilterPanel::mDbMin
private

Definition at line 114 of file ScienFilter.h.

Referenced by OnPaint(), and SetDbRange().

◆ mEffect

EffectScienFilter* EffectScienFilterPanel::mEffect
private

Definition at line 108 of file ScienFilter.h.

Referenced by OnPaint().

◆ mEnvRect

wxRect EffectScienFilterPanel::mEnvRect
private

Definition at line 118 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHeight

int EffectScienFilterPanel::mHeight
private

Definition at line 120 of file ScienFilter.h.

Referenced by OnPaint().

◆ mHiFreq

double EffectScienFilterPanel::mHiFreq
private

Definition at line 112 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mLoFreq

double EffectScienFilterPanel::mLoFreq
private

Definition at line 111 of file ScienFilter.h.

Referenced by OnPaint(), and SetFreqRange().

◆ mParent

wxWindow* EffectScienFilterPanel::mParent
private

Definition at line 109 of file ScienFilter.h.

◆ mWidth

int EffectScienFilterPanel::mWidth
private

Definition at line 119 of file ScienFilter.h.

Referenced by OnPaint().


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