Audacity  3.0.3
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 <Export.h>

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

Public Member Functions

 ExportMixerPanel (wxWindow *parent, wxWindowID id, MixerSpec *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
 
MixerSpecmMixerSpec
 
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 264 of file Export.h.

Constructor & Destructor Documentation

◆ ExportMixerPanel()

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

Definition at line 1129 of file Export.cpp.

1132  :
1133  wxPanelWrapper(parent, id, pos, size)
1134  , mMixerSpec{mixerSpec}
1137 {
1138  mBitmap = NULL;
1139  mWidth = 0;
1140  mHeight = 0;
1142 
1143  mTrackNames = trackNames;
1144 }

◆ ~ExportMixerPanel()

ExportMixerPanel::~ExportMixerPanel ( )
virtual

Definition at line 1146 of file Export.cpp.

1147 {
1148 }

Member Function Documentation

◆ Distance()

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

Definition at line 1289 of file Export.cpp.

1290 {
1291  return sqrt( pow( a.x - b.x, 2.0 ) + pow( a.y - b.y, 2.0 ) );
1292 }

Referenced by IsOnLine().

Here is the caller graph for this function:

◆ IsOnLine()

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

Definition at line 1295 of file Export.cpp.

1296 {
1297  return Distance( p, la ) + Distance( p, lb ) - Distance( la, lb ) < 0.1;
1298 }

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 1300 of file Export.cpp.

1301 {
1302  if( event.ButtonDown() )
1303  {
1304  bool reset = true;
1305  //check tracks
1306  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1307  if( mTrackRects[ i ].Contains( event.m_x, event.m_y ) )
1308  {
1309  reset = false;
1310  if( mSelectedTrack == (int)i )
1311  mSelectedTrack = -1;
1312  else
1313  {
1314  mSelectedTrack = i;
1315  if( mSelectedChannel != -1 )
1318  }
1319  goto found;
1320  }
1321 
1322  //check channels
1323  for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
1324  if( mChannelRects[ i ].Contains( event.m_x, event.m_y ) )
1325  {
1326  reset = false;
1327  if( mSelectedChannel == (int)i )
1328  mSelectedChannel = -1;
1329  else
1330  {
1331  mSelectedChannel = i;
1332  if( mSelectedTrack != -1 )
1335  }
1336  goto found;
1337  }
1338 
1339  //check links
1340  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1341  for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
1342  if( mMixerSpec->mMap[ i ][ j ] && IsOnLine( wxPoint( event.m_x,
1343  event.m_y ), wxPoint( mTrackRects[ i ].x + mBoxWidth,
1344  mTrackRects[ i ].y + mTrackHeight / 2 ),
1345  wxPoint( mChannelRects[ j ].x, mChannelRects[ j ].y +
1346  mChannelHeight / 2 ) ) )
1347  mMixerSpec->mMap[ i ][ j ] = false;
1348 
1349 found:
1350  if( reset )
1352  Refresh( false );
1353  }
1354 }

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

Here is the call graph for this function:

◆ OnPaint()

void ExportMixerPanel::OnPaint ( wxPaintEvent &  event)

Definition at line 1172 of file Export.cpp.

1173 {
1174  wxPaintDC dc( this );
1175 
1176  int width, height;
1177  GetSize( &width, &height );
1178 
1179  if( !mBitmap || mWidth != width || mHeight != height )
1180  {
1181  mWidth = width;
1182  mHeight = height;
1183  mBitmap = std::make_unique<wxBitmap>( mWidth, mHeight,24 );
1184  }
1185 
1186  wxColour bkgnd = GetBackgroundColour();
1187  wxBrush bkgndBrush( bkgnd, wxBRUSHSTYLE_SOLID );
1188 
1189  wxMemoryDC memDC;
1190  memDC.SelectObject( *mBitmap );
1191 
1192  //draw background
1193  wxRect bkgndRect;
1194  bkgndRect.x = 0;
1195  bkgndRect.y = 0;
1196  bkgndRect.width = mWidth;
1197  bkgndRect.height = mHeight;
1198 
1199  memDC.SetBrush( *wxWHITE_BRUSH );
1200  memDC.SetPen( *wxBLACK_PEN );
1201  memDC.DrawRectangle( bkgndRect );
1202 
1203  //box dimensions
1204  mBoxWidth = mWidth / 6;
1205 
1206  mTrackHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumTracks() * 4 );
1207  if( mTrackHeight > 30 )
1208  mTrackHeight = 30;
1209 
1210  mChannelHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumChannels() * 4 );
1211  if( mChannelHeight > 30 )
1212  mChannelHeight = 30;
1213 
1214  static double PI = 2 * acos( 0.0 );
1215  double angle = atan( ( 3.0 * mHeight ) / mWidth );
1216  double radius = mHeight / ( 2.0 * sin( PI - 2.0 * angle ) );
1217  double totAngle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 );
1218 
1219  //draw tracks
1220  memDC.SetBrush( AColor::envelopeBrush );
1221  angle = totAngle / ( mMixerSpec->GetNumTracks() + 1 );
1222 
1223  int max = 0, w, h;
1224  for( unsigned int i = 1; i < mMixerSpec->GetNumTracks(); i++ )
1225  if( mTrackNames[ i ].length() > mTrackNames[ max ].length() )
1226  max = i;
1227 
1228  SetFont( memDC, mTrackNames[ max ], mBoxWidth, mTrackHeight );
1229 
1230  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1231  {
1232  mTrackRects[ i ].x = (int)( mBoxWidth * 2 + radius - radius *
1233  cos( totAngle / 2.0 - angle * ( i + 1 ) ) - mBoxWidth + 0.5 );
1234  mTrackRects[ i ].y = (int)( mHeight * 0.5 - radius *
1235  sin( totAngle * 0.5 - angle * ( i + 1.0 ) ) -
1236  0.5 * mTrackHeight + 0.5 );
1237 
1238  mTrackRects[ i ].width = mBoxWidth;
1239  mTrackRects[ i ].height = mTrackHeight;
1240 
1241  memDC.SetPen( mSelectedTrack == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
1242  memDC.DrawRectangle( mTrackRects[ i ] );
1243 
1244  memDC.GetTextExtent( mTrackNames[ i ], &w, &h );
1245  memDC.DrawText( mTrackNames[ i ],
1246  mTrackRects[ i ].x + ( mBoxWidth - w ) / 2,
1247  mTrackRects[ i ].y + ( mTrackHeight - h ) / 2 );
1248  }
1249 
1250  //draw channels
1251  memDC.SetBrush( AColor::playRegionBrush[ 0 ] );
1252  angle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 ) /
1253  ( mMixerSpec->GetNumChannels() + 1 );
1254 
1255  SetFont( memDC, wxT( "Channel: XX" ), mBoxWidth, mChannelHeight );
1256  memDC.GetTextExtent( wxT( "Channel: XX" ), &w, &h );
1257 
1258  for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
1259  {
1260  mChannelRects[ i ].x = (int)( mBoxWidth * 4 - radius + radius *
1261  cos( totAngle * 0.5 - angle * ( i + 1 ) ) + 0.5 );
1262  mChannelRects[ i ].y = (int)( mHeight * 0.5 - radius *
1263  sin( totAngle * 0.5 - angle * ( i + 1 ) ) -
1264  0.5 * mChannelHeight + 0.5 );
1265 
1266  mChannelRects[ i ].width = mBoxWidth;
1267  mChannelRects[ i ].height = mChannelHeight;
1268 
1269  memDC.SetPen( mSelectedChannel == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
1270  memDC.DrawRectangle( mChannelRects[ i ] );
1271 
1272  memDC.DrawText( wxString::Format( _( "Channel: %2d" ), i + 1 ),
1273  mChannelRects[ i ].x + ( mBoxWidth - w ) / 2,
1274  mChannelRects[ i ].y + ( mChannelHeight - h ) / 2 );
1275  }
1276 
1277  //draw links
1278  memDC.SetPen( wxPen( *wxBLACK, mHeight / 200 ) );
1279  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1280  for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
1281  if( mMixerSpec->mMap[ i ][ j ] )
1282  AColor::Line(memDC, mTrackRects[ i ].x + mBoxWidth,
1283  mTrackRects[ i ].y + mTrackHeight / 2, mChannelRects[ j ].x,
1284  mChannelRects[ j ].y + mChannelHeight / 2 );
1285 
1286  dc.Blit( 0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE );
1287 }

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

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 1151 of file Export.cpp.

1153 {
1154  int l = 0, u = 13, m, w, h;
1155  wxFont font = memDC.GetFont();
1156  while( l < u - 1 )
1157  {
1158  m = ( l + u ) / 2;
1159  font.SetPointSize( m );
1160  memDC.SetFont( font );
1161  memDC.GetTextExtent( text, &w, &h );
1162 
1163  if( w < width && h < height )
1164  l = m;
1165  else
1166  u = m;
1167  }
1168  font.SetPointSize( l );
1169  memDC.SetFont( font );
1170 }

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 277 of file Export.h.

Referenced by OnPaint().

◆ mBoxWidth

int ExportMixerPanel::mBoxWidth
private

Definition at line 286 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mChannelHeight

int ExportMixerPanel::mChannelHeight
private

Definition at line 286 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mChannelRects

ArrayOf<wxRect> ExportMixerPanel::mChannelRects
private

Definition at line 282 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mEnvRect

wxRect ExportMixerPanel::mEnvRect
private

Definition at line 278 of file Export.h.

◆ mHeight

int ExportMixerPanel::mHeight
private

Definition at line 280 of file Export.h.

Referenced by OnPaint().

◆ mMixerSpec

MixerSpec* ExportMixerPanel::mMixerSpec
private

Definition at line 281 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mSelectedChannel

int ExportMixerPanel::mSelectedChannel
private

Definition at line 284 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mSelectedTrack

int ExportMixerPanel::mSelectedTrack
private

Definition at line 284 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mTrackHeight

int ExportMixerPanel::mTrackHeight
private

Definition at line 286 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mTrackNames

wxArrayString ExportMixerPanel::mTrackNames
private

Definition at line 285 of file Export.h.

Referenced by OnPaint().

◆ mTrackRects

ArrayOf<wxRect> ExportMixerPanel::mTrackRects
private

Definition at line 283 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

◆ mWidth

int ExportMixerPanel::mWidth
private

Definition at line 279 of file Export.h.

Referenced by OnPaint().


The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ExportMixerPanel::mTrackNames
wxArrayString mTrackNames
Definition: Export.h:285
ExportMixerPanel::mBoxWidth
int mBoxWidth
Definition: Export.h:286
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
ExportMixerPanel::SetFont
void SetFont(wxMemoryDC &memDC, const wxString &text, int width, int height)
Definition: Export.cpp:1151
ExportMixerPanel::mBitmap
std::unique_ptr< wxBitmap > mBitmap
Definition: Export.h:277
ExportMixerPanel::mChannelRects
ArrayOf< wxRect > mChannelRects
Definition: Export.h:282
ExportMixerPanel::mTrackHeight
int mTrackHeight
Definition: Export.h:286
PI
#define PI
Definition: Biquad.cpp:18
ExportMixerPanel::mMixerSpec
MixerSpec * mMixerSpec
Definition: Export.h:281
ExportMixerPanel::Distance
double Distance(wxPoint &a, wxPoint &b)
Definition: Export.cpp:1289
ExportMixerPanel::mChannelHeight
int mChannelHeight
Definition: Export.h:286
ExportMixerPanel::mSelectedChannel
int mSelectedChannel
Definition: Export.h:284
MixerSpec::mMap
ArraysOf< bool > mMap
Definition: Mix.h:61
ExportMixerPanel::mTrackRects
ArrayOf< wxRect > mTrackRects
Definition: Export.h:283
MixerSpec::GetNumTracks
unsigned GetNumTracks()
Definition: Mix.h:71
AColor::playRegionBrush
static wxBrush playRegionBrush[1]
Definition: AColor.h:97
ExportMixerPanel::mHeight
int mHeight
Definition: Export.h:280
ExportMixerPanel::mWidth
int mWidth
Definition: Export.h:279
_
#define _(s)
Definition: Internat.h:75
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
ExportMixerPanel::mSelectedTrack
int mSelectedTrack
Definition: Export.h:284
ExportMixerPanel::IsOnLine
bool IsOnLine(wxPoint p, wxPoint la, wxPoint lb)
Definition: Export.cpp:1295
MixerSpec::GetNumChannels
unsigned GetNumChannels()
Definition: Mix.h:68
AColor::envelopeBrush
static wxBrush envelopeBrush
Definition: AColor.h:106
MixerSpec::GetMaxNumChannels
unsigned GetMaxNumChannels()
Definition: Mix.h:70