Audacity  2.2.2
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 241 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 1052 of file Export.cpp.

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

Definition at line 1069 of file Export.cpp.

1070 {
1071 }

Member Function Documentation

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

Definition at line 1212 of file Export.cpp.

Referenced by IsOnLine().

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

Definition at line 1218 of file Export.cpp.

References Distance().

Referenced by OnMouseEvent().

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

Definition at line 1223 of file Export.cpp.

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

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

Definition at line 1095 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().

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

Definition at line 1074 of file Export.cpp.

Referenced by OnPaint().

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

Member Data Documentation

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

Definition at line 254 of file Export.h.

Referenced by OnPaint().

int ExportMixerPanel::mBoxWidth
private

Definition at line 263 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mChannelHeight
private

Definition at line 263 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

ArrayOf<wxRect> ExportMixerPanel::mChannelRects
private

Definition at line 259 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

wxRect ExportMixerPanel::mEnvRect
private

Definition at line 255 of file Export.h.

int ExportMixerPanel::mHeight
private

Definition at line 257 of file Export.h.

Referenced by OnPaint().

MixerSpec* ExportMixerPanel::mMixerSpec
private

Definition at line 258 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mSelectedChannel
private

Definition at line 261 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mSelectedTrack
private

Definition at line 261 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mTrackHeight
private

Definition at line 263 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

wxArrayString ExportMixerPanel::mTrackNames
private

Definition at line 262 of file Export.h.

Referenced by OnPaint().

ArrayOf<wxRect> ExportMixerPanel::mTrackRects
private

Definition at line 260 of file Export.h.

Referenced by OnMouseEvent(), and OnPaint().

int ExportMixerPanel::mWidth
private

Definition at line 256 of file Export.h.

Referenced by OnPaint().


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