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

Panel that displays mixing for advanced mixing option. More...

#include <ExportMixerPanel.h>

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

Public Member Functions

 ExportMixerPanel (wxWindow *parent, wxWindowID id, MixerOptions::Downmix *mixerSpec, wxArrayString trackNames, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
virtual ~ExportMixerPanel ()
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
- 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 SetFont (wxMemoryDC &memDC, const wxString &text, int width, int height)
 
double Distance (wxPoint &a, wxPoint &b)
 
bool IsOnLine (wxPoint p, wxPoint la, wxPoint lb)
 

Private Attributes

std::unique_ptr< wxBitmap > mBitmap
 
wxRect mEnvRect
 
int mWidth
 
int mHeight
 
MixerOptions::DownmixmMixerSpec
 
ArrayOf< wxRect > mChannelRects
 
ArrayOf< wxRect > mTrackRects
 
int mSelectedTrack
 
int mSelectedChannel
 
wxArrayString mTrackNames
 
int mBoxWidth
 
int mChannelHeight
 
int mTrackHeight
 

Detailed Description

Panel that displays mixing for advanced mixing option.

Definition at line 25 of file ExportMixerPanel.h.

Constructor & Destructor Documentation

◆ ExportMixerPanel()

ExportMixerPanel::ExportMixerPanel ( wxWindow *  parent,
wxWindowID  id,
MixerOptions::Downmix mixerSpec,
wxArrayString  trackNames,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)

Definition at line 25 of file ExportMixerPanel.cpp.

28 :
29 wxPanelWrapper(parent, id, pos, size)
30 , mMixerSpec{mixerSpec}
33{
34 mBitmap = NULL;
35 mWidth = 0;
36 mHeight = 0;
38
39 mTrackNames = trackNames;
40}
MixerOptions::Downmix * mMixerSpec
std::unique_ptr< wxBitmap > mBitmap
ArrayOf< wxRect > mChannelRects
ArrayOf< wxRect > mTrackRects
wxArrayString mTrackNames
unsigned GetMaxNumChannels() const
Definition: MixerOptions.h:49
unsigned GetNumTracks() const
Definition: MixerOptions.h:50

◆ ~ExportMixerPanel()

ExportMixerPanel::~ExportMixerPanel ( )
virtual

Definition at line 42 of file ExportMixerPanel.cpp.

43{
44}

Member Function Documentation

◆ Distance()

double ExportMixerPanel::Distance ( wxPoint &  a,
wxPoint &  b 
)
private

Definition at line 185 of file ExportMixerPanel.cpp.

186{
187 return sqrt( pow( a.x - b.x, 2.0 ) + pow( a.y - b.y, 2.0 ) );
188}
__finl float_x4 __vecc sqrt(const float_x4 &a)

References staffpad::audio::simd::sqrt().

Referenced by IsOnLine().

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

◆ IsOnLine()

bool ExportMixerPanel::IsOnLine ( wxPoint  p,
wxPoint  la,
wxPoint  lb 
)
private

Definition at line 191 of file ExportMixerPanel.cpp.

192{
193 return Distance( p, la ) + Distance( p, lb ) - Distance( la, lb ) < 0.1;
194}
double Distance(wxPoint &a, wxPoint &b)

References Distance().

Referenced by OnMouseEvent().

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

◆ OnMouseEvent()

void ExportMixerPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 196 of file ExportMixerPanel.cpp.

197{
198 if( event.ButtonDown() )
199 {
200 bool reset = true;
201 //check tracks
202 for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
203 if( mTrackRects[ i ].Contains( event.m_x, event.m_y ) )
204 {
205 reset = false;
206 if( mSelectedTrack == (int)i )
207 mSelectedTrack = -1;
208 else
209 {
210 mSelectedTrack = i;
211 if( mSelectedChannel != -1 )
214 }
215 goto found;
216 }
217
218 //check channels
219 for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
220 if( mChannelRects[ i ].Contains( event.m_x, event.m_y ) )
221 {
222 reset = false;
223 if( mSelectedChannel == (int)i )
224 mSelectedChannel = -1;
225 else
226 {
228 if( mSelectedTrack != -1 )
231 }
232 goto found;
233 }
234
235 //check links
236 for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
237 for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
238 if( mMixerSpec->mMap[ i ][ j ] && IsOnLine( wxPoint( event.m_x,
239 event.m_y ), wxPoint( mTrackRects[ i ].x + mBoxWidth,
240 mTrackRects[ i ].y + mTrackHeight / 2 ),
241 wxPoint( mChannelRects[ j ].x, mChannelRects[ j ].y +
242 mChannelHeight / 2 ) ) )
243 mMixerSpec->mMap[ i ][ j ] = false;
244
245found:
246 if( reset )
248 Refresh( false );
249 }
250}
bool IsOnLine(wxPoint p, wxPoint la, wxPoint lb)
ArraysOf< bool > mMap
Definition: MixerOptions.h:38
unsigned GetNumChannels() const
Definition: MixerOptions.h:47

References MixerOptions::Downmix::GetNumChannels(), MixerOptions::Downmix::GetNumTracks(), IsOnLine(), mBoxWidth, mChannelHeight, mChannelRects, MixerOptions::Downmix::mMap, mMixerSpec, mSelectedChannel, mSelectedTrack, mTrackHeight, and mTrackRects.

Here is the call graph for this function:

◆ OnPaint()

void ExportMixerPanel::OnPaint ( wxPaintEvent &  event)

Definition at line 68 of file ExportMixerPanel.cpp.

69{
70 wxPaintDC dc( this );
71
72 int width, height;
73 GetSize( &width, &height );
74
75 if( !mBitmap || mWidth != width || mHeight != height )
76 {
77 mWidth = width;
78 mHeight = height;
79 mBitmap = std::make_unique<wxBitmap>( mWidth, mHeight,24 );
80 }
81
82 wxColour bkgnd = GetBackgroundColour();
83 wxBrush bkgndBrush( bkgnd, wxBRUSHSTYLE_SOLID );
84
85 wxMemoryDC memDC;
86 memDC.SelectObject( *mBitmap );
87
88 //draw background
89 wxRect bkgndRect;
90 bkgndRect.x = 0;
91 bkgndRect.y = 0;
92 bkgndRect.width = mWidth;
93 bkgndRect.height = mHeight;
94
95 memDC.SetBrush( *wxWHITE_BRUSH );
96 memDC.SetPen( *wxBLACK_PEN );
97 memDC.DrawRectangle( bkgndRect );
98
99 //box dimensions
100 mBoxWidth = mWidth / 6;
101
102 mTrackHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumTracks() * 4 );
103 if( mTrackHeight > 30 )
104 mTrackHeight = 30;
105
106 mChannelHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumChannels() * 4 );
107 if( mChannelHeight > 30 )
108 mChannelHeight = 30;
109
110 static double PI = 2 * acos( 0.0 );
111 double angle = atan( ( 3.0 * mHeight ) / mWidth );
112 double radius = mHeight / ( 2.0 * sin( PI - 2.0 * angle ) );
113 double totAngle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 );
114
115 //draw tracks
116 memDC.SetBrush( AColor::envelopeBrush );
117 angle = totAngle / ( mMixerSpec->GetNumTracks() + 1 );
118
119 int max = 0, w, h;
120 for( unsigned int i = 1; i < mMixerSpec->GetNumTracks(); i++ )
121 if( mTrackNames[ i ].length() > mTrackNames[ max ].length() )
122 max = i;
123
124 SetFont( memDC, mTrackNames[ max ], mBoxWidth, mTrackHeight );
125
126 for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
127 {
128 mTrackRects[ i ].x = (int)( mBoxWidth * 2 + radius - radius *
129 cos( totAngle / 2.0 - angle * ( i + 1 ) ) - mBoxWidth + 0.5 );
130 mTrackRects[ i ].y = (int)( mHeight * 0.5 - radius *
131 sin( totAngle * 0.5 - angle * ( i + 1.0 ) ) -
132 0.5 * mTrackHeight + 0.5 );
133
134 mTrackRects[ i ].width = mBoxWidth;
135 mTrackRects[ i ].height = mTrackHeight;
136
137 memDC.SetPen( mSelectedTrack == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
138 memDC.DrawRectangle( mTrackRects[ i ] );
139
140 memDC.GetTextExtent( mTrackNames[ i ], &w, &h );
141 memDC.DrawText( mTrackNames[ i ],
142 mTrackRects[ i ].x + ( mBoxWidth - w ) / 2,
143 mTrackRects[ i ].y + ( mTrackHeight - h ) / 2 );
144 }
145
146 //draw channels
147 memDC.SetBrush( AColor::playRegionBrush[ 0 ] );
148 angle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 ) /
149 ( mMixerSpec->GetNumChannels() + 1 );
150
151 SetFont( memDC, wxT( "Channel: XX" ), mBoxWidth, mChannelHeight );
152 memDC.GetTextExtent( wxT( "Channel: XX" ), &w, &h );
153
154 for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
155 {
156 mChannelRects[ i ].x = (int)( mBoxWidth * 4 - radius + radius *
157 cos( totAngle * 0.5 - angle * ( i + 1 ) ) + 0.5 );
158 mChannelRects[ i ].y = (int)( mHeight * 0.5 - radius *
159 sin( totAngle * 0.5 - angle * ( i + 1 ) ) -
160 0.5 * mChannelHeight + 0.5 );
161
162 mChannelRects[ i ].width = mBoxWidth;
163 mChannelRects[ i ].height = mChannelHeight;
164
165 memDC.SetPen( mSelectedChannel == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
166 memDC.DrawRectangle( mChannelRects[ i ] );
167
168 memDC.DrawText( wxString::Format( _( "Channel: %2d" ), i + 1 ),
169 mChannelRects[ i ].x + ( mBoxWidth - w ) / 2,
170 mChannelRects[ i ].y + ( mChannelHeight - h ) / 2 );
171 }
172
173 //draw links
174 memDC.SetPen( wxPen( *wxBLACK, mHeight / 200 ) );
175 for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
176 for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
177 if( mMixerSpec->mMap[ i ][ j ] )
178 AColor::Line(memDC, mTrackRects[ i ].x + mBoxWidth,
179 mTrackRects[ i ].y + mTrackHeight / 2, mChannelRects[ j ].x,
180 mChannelRects[ j ].y + mChannelHeight / 2 );
181
182 dc.Blit( 0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE );
183}
wxT("CloseDown"))
#define PI
Definition: Biquad.cpp:18
#define _(s)
Definition: Internat.h:73
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static wxBrush playRegionBrush[1]
Definition: AColor.h:108
static wxBrush envelopeBrush
Definition: AColor.h:117
void SetFont(wxMemoryDC &memDC, const wxString &text, int width, int height)

References _, AColor::envelopeBrush, MixerOptions::Downmix::GetNumChannels(), MixerOptions::Downmix::GetNumTracks(), AColor::Line(), mBitmap, mBoxWidth, mChannelHeight, mChannelRects, mHeight, MixerOptions::Downmix::mMap, mMixerSpec, mSelectedChannel, mSelectedTrack, mTrackHeight, mTrackNames, mTrackRects, mWidth, PI, AColor::playRegionBrush, SetFont(), and wxT().

Here is the call graph for this function:

◆ SetFont()

void ExportMixerPanel::SetFont ( wxMemoryDC &  memDC,
const wxString &  text,
int  width,
int  height 
)
private

Definition at line 47 of file ExportMixerPanel.cpp.

49{
50 int l = 0, u = 13, m, w, h;
51 wxFont font = memDC.GetFont();
52 while( l < u - 1 )
53 {
54 m = ( l + u ) / 2;
55 font.SetPointSize( m );
56 memDC.SetFont( font );
57 memDC.GetTextExtent( text, &w, &h );
58
59 if( w < width && h < height )
60 l = m;
61 else
62 u = m;
63 }
64 font.SetPointSize( l );
65 memDC.SetFont( font );
66}

Referenced by OnPaint().

Here is the caller graph for this function:

Member Data Documentation

◆ mBitmap

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

Definition at line 38 of file ExportMixerPanel.h.

Referenced by OnPaint().

◆ mBoxWidth

int ExportMixerPanel::mBoxWidth
private

Definition at line 47 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mChannelHeight

int ExportMixerPanel::mChannelHeight
private

Definition at line 47 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mChannelRects

ArrayOf<wxRect> ExportMixerPanel::mChannelRects
private

Definition at line 43 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mEnvRect

wxRect ExportMixerPanel::mEnvRect
private

Definition at line 39 of file ExportMixerPanel.h.

◆ mHeight

int ExportMixerPanel::mHeight
private

Definition at line 41 of file ExportMixerPanel.h.

Referenced by OnPaint().

◆ mMixerSpec

MixerOptions::Downmix* ExportMixerPanel::mMixerSpec
private

Definition at line 42 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mSelectedChannel

int ExportMixerPanel::mSelectedChannel
private

Definition at line 45 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mSelectedTrack

int ExportMixerPanel::mSelectedTrack
private

Definition at line 45 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mTrackHeight

int ExportMixerPanel::mTrackHeight
private

Definition at line 47 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mTrackNames

wxArrayString ExportMixerPanel::mTrackNames
private

Definition at line 46 of file ExportMixerPanel.h.

Referenced by OnPaint().

◆ mTrackRects

ArrayOf<wxRect> ExportMixerPanel::mTrackRects
private

Definition at line 44 of file ExportMixerPanel.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mWidth

int ExportMixerPanel::mWidth
private

Definition at line 40 of file ExportMixerPanel.h.

Referenced by OnPaint().


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