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

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

Constructor & Destructor Documentation

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

Definition at line 1051 of file Export.cpp.

1054  :
1055  wxPanelWrapper(parent, id, pos, size)
1056  , mMixerSpec{mixerSpec}
1059 {
1060  mBitmap = NULL;
1061  mWidth = 0;
1062  mHeight = 0;
1064 
1065  mTrackNames = trackNames;
1066 }
int mSelectedChannel
Definition: Export.h:260
ArrayOf< wxRect > mTrackRects
Definition: Export.h:259
int mSelectedTrack
Definition: Export.h:260
unsigned GetNumTracks()
Definition: Mix.h:75
wxArrayString mTrackNames
Definition: Export.h:261
std::unique_ptr< wxBitmap > mBitmap
Definition: Export.h:253
unsigned GetMaxNumChannels()
Definition: Mix.h:74
ArrayOf< wxRect > mChannelRects
Definition: Export.h:258
MixerSpec * mMixerSpec
Definition: Export.h:257
ExportMixerPanel::~ExportMixerPanel ( )
virtual

Definition at line 1068 of file Export.cpp.

1069 {
1070 }

Member Function Documentation

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

Definition at line 1211 of file Export.cpp.

Referenced by IsOnLine().

1212 {
1213  return sqrt( pow( a.x - b.x, 2.0 ) + pow( a.y - b.y, 2.0 ) );
1214 }
bool ExportMixerPanel::IsOnLine ( wxPoint  p,
wxPoint  la,
wxPoint  lb 
)
private

Definition at line 1217 of file Export.cpp.

References Distance().

Referenced by OnMouseEvent().

1218 {
1219  return Distance( p, la ) + Distance( p, lb ) - Distance( la, lb ) < 0.1;
1220 }
double Distance(wxPoint &a, wxPoint &b)
Definition: Export.cpp:1211
void ExportMixerPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1222 of file Export.cpp.

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

1223 {
1224  if( event.ButtonDown() )
1225  {
1226  bool reset = true;
1227  //check tracks
1228  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1229  if( mTrackRects[ i ].Contains( event.m_x, event.m_y ) )
1230  {
1231  reset = false;
1232  if( mSelectedTrack == (int)i )
1233  mSelectedTrack = -1;
1234  else
1235  {
1236  mSelectedTrack = i;
1237  if( mSelectedChannel != -1 )
1240  }
1241  goto found;
1242  }
1243 
1244  //check channels
1245  for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
1246  if( mChannelRects[ i ].Contains( event.m_x, event.m_y ) )
1247  {
1248  reset = false;
1249  if( mSelectedChannel == (int)i )
1250  mSelectedChannel = -1;
1251  else
1252  {
1253  mSelectedChannel = i;
1254  if( mSelectedTrack != -1 )
1257  }
1258  goto found;
1259  }
1260 
1261  //check links
1262  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1263  for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
1264  if( mMixerSpec->mMap[ i ][ j ] && IsOnLine( wxPoint( event.m_x,
1265  event.m_y ), wxPoint( mTrackRects[ i ].x + mBoxWidth,
1266  mTrackRects[ i ].y + mTrackHeight / 2 ),
1267  wxPoint( mChannelRects[ j ].x, mChannelRects[ j ].y +
1268  mChannelHeight / 2 ) ) )
1269  mMixerSpec->mMap[ i ][ j ] = false;
1270 
1271 found:
1272  if( reset )
1274  Refresh( false );
1275  }
1276 }
int mSelectedChannel
Definition: Export.h:260
ArrayOf< wxRect > mTrackRects
Definition: Export.h:259
int mSelectedTrack
Definition: Export.h:260
bool IsOnLine(wxPoint p, wxPoint la, wxPoint lb)
Definition: Export.cpp:1217
unsigned GetNumTracks()
Definition: Mix.h:75
ArraysOf< bool > mMap
Definition: Mix.h:65
unsigned GetNumChannels()
Definition: Mix.h:72
ArrayOf< wxRect > mChannelRects
Definition: Export.h:258
int mChannelHeight
Definition: Export.h:262
int mTrackHeight
Definition: Export.h:262
MixerSpec * mMixerSpec
Definition: Export.h:257
void ExportMixerPanel::OnPaint ( wxPaintEvent &  event)

Definition at line 1094 of file Export.cpp.

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().

1095 {
1096  wxPaintDC dc( this );
1097 
1098  int width, height;
1099  GetSize( &width, &height );
1100 
1101  if( !mBitmap || mWidth != width || mHeight != height )
1102  {
1103  mWidth = width;
1104  mHeight = height;
1105  mBitmap = std::make_unique<wxBitmap>( mWidth, mHeight,24 );
1106  }
1107 
1108  wxColour bkgnd = GetBackgroundColour();
1109  wxBrush bkgndBrush( bkgnd, wxBRUSHSTYLE_SOLID );
1110 
1111  wxMemoryDC memDC;
1112  memDC.SelectObject( *mBitmap );
1113 
1114  //draw background
1115  wxRect bkgndRect;
1116  bkgndRect.x = 0;
1117  bkgndRect.y = 0;
1118  bkgndRect.width = mWidth;
1119  bkgndRect.height = mHeight;
1120 
1121  memDC.SetBrush( *wxWHITE_BRUSH );
1122  memDC.SetPen( *wxBLACK_PEN );
1123  memDC.DrawRectangle( bkgndRect );
1124 
1125  //box dimensions
1126  mBoxWidth = mWidth / 6;
1127 
1128  mTrackHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumTracks() * 4 );
1129  if( mTrackHeight > 30 )
1130  mTrackHeight = 30;
1131 
1132  mChannelHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumChannels() * 4 );
1133  if( mChannelHeight > 30 )
1134  mChannelHeight = 30;
1135 
1136  static double PI = 2 * acos( 0.0 );
1137  double angle = atan( ( 3.0 * mHeight ) / mWidth );
1138  double radius = mHeight / ( 2.0 * sin( PI - 2.0 * angle ) );
1139  double totAngle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 );
1140 
1141  //draw tracks
1142  memDC.SetBrush( AColor::envelopeBrush );
1143  angle = totAngle / ( mMixerSpec->GetNumTracks() + 1 );
1144 
1145  int max = 0, w, h;
1146  for( unsigned int i = 1; i < mMixerSpec->GetNumTracks(); i++ )
1147  if( mTrackNames[ i ].length() > mTrackNames[ max ].length() )
1148  max = i;
1149 
1150  SetFont( memDC, mTrackNames[ max ], mBoxWidth, mTrackHeight );
1151 
1152  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1153  {
1154  mTrackRects[ i ].x = (int)( mBoxWidth * 2 + radius - radius *
1155  cos( totAngle / 2.0 - angle * ( i + 1 ) ) - mBoxWidth + 0.5 );
1156  mTrackRects[ i ].y = (int)( mHeight * 0.5 - radius *
1157  sin( totAngle * 0.5 - angle * ( i + 1.0 ) ) -
1158  0.5 * mTrackHeight + 0.5 );
1159 
1160  mTrackRects[ i ].width = mBoxWidth;
1161  mTrackRects[ i ].height = mTrackHeight;
1162 
1163  memDC.SetPen( mSelectedTrack == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
1164  memDC.DrawRectangle( mTrackRects[ i ] );
1165 
1166  memDC.GetTextExtent( mTrackNames[ i ], &w, &h );
1167  memDC.DrawText( mTrackNames[ i ],
1168  mTrackRects[ i ].x + ( mBoxWidth - w ) / 2,
1169  mTrackRects[ i ].y + ( mTrackHeight - h ) / 2 );
1170  }
1171 
1172  //draw channels
1173  memDC.SetBrush( AColor::playRegionBrush[ 0 ] );
1174  angle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 ) /
1175  ( mMixerSpec->GetNumChannels() + 1 );
1176 
1177  SetFont( memDC, wxT( "Channel: XX" ), mBoxWidth, mChannelHeight );
1178  memDC.GetTextExtent( wxT( "Channel: XX" ), &w, &h );
1179 
1180  for( unsigned int i = 0; i < mMixerSpec->GetNumChannels(); i++ )
1181  {
1182  mChannelRects[ i ].x = (int)( mBoxWidth * 4 - radius + radius *
1183  cos( totAngle * 0.5 - angle * ( i + 1 ) ) + 0.5 );
1184  mChannelRects[ i ].y = (int)( mHeight * 0.5 - radius *
1185  sin( totAngle * 0.5 - angle * ( i + 1 ) ) -
1186  0.5 * mChannelHeight + 0.5 );
1187 
1188  mChannelRects[ i ].width = mBoxWidth;
1189  mChannelRects[ i ].height = mChannelHeight;
1190 
1191  memDC.SetPen( mSelectedChannel == (int)i ? *wxRED_PEN : *wxBLACK_PEN );
1192  memDC.DrawRectangle( mChannelRects[ i ] );
1193 
1194  memDC.DrawText( wxString::Format( _( "Channel: %2d" ), i + 1 ),
1195  mChannelRects[ i ].x + ( mBoxWidth - w ) / 2,
1196  mChannelRects[ i ].y + ( mChannelHeight - h ) / 2 );
1197  }
1198 
1199  //draw links
1200  memDC.SetPen( wxPen( *wxBLACK, mHeight / 200 ) );
1201  for( unsigned int i = 0; i < mMixerSpec->GetNumTracks(); i++ )
1202  for( unsigned int j = 0; j < mMixerSpec->GetNumChannels(); j++ )
1203  if( mMixerSpec->mMap[ i ][ j ] )
1204  AColor::Line(memDC, mTrackRects[ i ].x + mBoxWidth,
1205  mTrackRects[ i ].y + mTrackHeight / 2, mChannelRects[ j ].x,
1206  mChannelRects[ j ].y + mChannelHeight / 2 );
1207 
1208  dc.Blit( 0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE );
1209 }
#define PI
Definition: ScienFilter.cpp:62
int mSelectedChannel
Definition: Export.h:260
ArrayOf< wxRect > mTrackRects
Definition: Export.h:259
int mSelectedTrack
Definition: Export.h:260
void SetFont(wxMemoryDC &memDC, const wxString &text, int width, int height)
Definition: Export.cpp:1073
unsigned GetNumTracks()
Definition: Mix.h:75
ArraysOf< bool > mMap
Definition: Mix.h:65
wxArrayString mTrackNames
Definition: Export.h:261
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
static wxBrush envelopeBrush
Definition: AColor.h:124
std::unique_ptr< wxBitmap > mBitmap
Definition: Export.h:253
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
unsigned GetNumChannels()
Definition: Mix.h:72
ArrayOf< wxRect > mChannelRects
Definition: Export.h:258
int mChannelHeight
Definition: Export.h:262
int mTrackHeight
Definition: Export.h:262
static wxBrush playRegionBrush[2]
Definition: AColor.h:115
MixerSpec * mMixerSpec
Definition: Export.h:257
void ExportMixerPanel::SetFont ( wxMemoryDC &  memDC,
const wxString &  text,
int  width,
int  height 
)
private

Definition at line 1073 of file Export.cpp.

Referenced by OnPaint().

1075 {
1076  int l = 0, u = 13, m, w, h;
1077  wxFont font = memDC.GetFont();
1078  while( l < u - 1 )
1079  {
1080  m = ( l + u ) / 2;
1081  font.SetPointSize( m );
1082  memDC.SetFont( font );
1083  memDC.GetTextExtent( text, &w, &h );
1084 
1085  if( w < width && h < height )
1086  l = m;
1087  else
1088  u = m;
1089  }
1090  font.SetPointSize( l );
1091  memDC.SetFont( font );
1092 }

Member Data Documentation

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

Definition at line 253 of file Export.h.

Referenced by OnPaint().

int ExportMixerPanel::mBoxWidth
private

Definition at line 262 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mChannelHeight
private

Definition at line 262 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

ArrayOf<wxRect> ExportMixerPanel::mChannelRects
private

Definition at line 258 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

wxRect ExportMixerPanel::mEnvRect
private

Definition at line 254 of file Export.h.

int ExportMixerPanel::mHeight
private

Definition at line 256 of file Export.h.

Referenced by OnPaint().

MixerSpec* ExportMixerPanel::mMixerSpec
private

Definition at line 257 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mSelectedChannel
private

Definition at line 260 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mSelectedTrack
private

Definition at line 260 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mTrackHeight
private

Definition at line 262 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

wxArrayString ExportMixerPanel::mTrackNames
private

Definition at line 261 of file Export.h.

Referenced by OnPaint().

ArrayOf<wxRect> ExportMixerPanel::mTrackRects
private

Definition at line 259 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mWidth
private

Definition at line 255 of file Export.h.

Referenced by OnPaint().


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