void ExportMixerPanel::OnPaint(wxPaintEvent & evt) { wxPaintDC dc( this ); int width, height; GetSize( &width, &height ); if( !mBitmap || mWidth != width || mHeight != height ) { if( mBitmap ) delete mBitmap; mWidth = width; mHeight = height; mBitmap = new wxBitmap( mWidth, mHeight ); } wxColour bkgnd = GetBackgroundColour(); wxBrush bkgndBrush( bkgnd, wxSOLID ); wxMemoryDC memDC; memDC.SelectObject( *mBitmap ); //draw background wxRect bkgndRect; bkgndRect.x = 0; bkgndRect.y = 0; bkgndRect.width = mWidth; bkgndRect.height = mHeight; memDC.SetBrush( *wxWHITE_BRUSH ); memDC.SetPen( *wxBLACK_PEN ); memDC.DrawRectangle( bkgndRect ); //box dimensions mBoxWidth = mWidth / 6; mTrackHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumTracks() * 4 ); if( mTrackHeight > 30 ) mTrackHeight = 30; mChannelHeight = ( mHeight * 3 ) / ( mMixerSpec->GetNumChannels() * 4 ); if( mChannelHeight > 30 ) mChannelHeight = 30; static double PI = 2 * acos( 0.0 ); double angle = atan( ( 3.0 * mHeight ) / mWidth ); double radius = mHeight / ( 2.0 * sin( PI - 2.0 * angle ) ); double totAngle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 ); //draw tracks memDC.SetBrush( AColor::envelopeBrush ); angle = totAngle / ( mMixerSpec->GetNumTracks() + 1 ); int max = 0, w, h; for( int i = 1; i < mMixerSpec->GetNumTracks(); i++ ) if( mTrackNames[ i ].length() > mTrackNames[ max ].length() ) max = i; SetFont( memDC, mTrackNames[ max ], mBoxWidth, mTrackHeight ); for( int i = 0; i < mMixerSpec->GetNumTracks(); i++ ) { mTrackRects[ i ].x = ( int )( mBoxWidth * 2 + radius - radius * cos( totAngle / 2.0 - angle * ( i + 1 ) ) - mBoxWidth + 0.5 ); mTrackRects[ i ].y = ( int )( mHeight * 0.5 - radius * sin( totAngle * 0.5 - angle * ( i + 1.0 ) ) - 0.5 * mTrackHeight + 0.5 ); mTrackRects[ i ].width = mBoxWidth; mTrackRects[ i ].height = mTrackHeight; memDC.SetPen( mSelectedTrack == i ? *wxRED_PEN : *wxBLACK_PEN ); memDC.DrawRectangle( mTrackRects[ i ] ); memDC.GetTextExtent( mTrackNames[ i ], &w, &h ); memDC.DrawText( mTrackNames[ i ], mTrackRects[ i ].x + ( mBoxWidth - w ) / 2, mTrackRects[ i ].y + ( mTrackHeight - h ) / 2 ); } //draw channels memDC.SetBrush( AColor::playRegionBrush[ 0 ] ); angle = ( asin( mHeight / ( 2.0 * radius ) ) * 2.0 ) / ( mMixerSpec->GetNumChannels() + 1 ); SetFont( memDC, wxT( "Channel: XX" ), mBoxWidth, mChannelHeight ); memDC.GetTextExtent( wxT( "Channel: XX" ), &w, &h ); for( int i = 0; i < mMixerSpec->GetNumChannels(); i++ ) { mChannelRects[ i ].x = ( int )( mBoxWidth * 4 - radius + radius * cos( totAngle * 0.5 - angle * ( i + 1 ) ) + 0.5 ); mChannelRects[ i ].y = ( int )( mHeight * 0.5 - radius * sin( totAngle * 0.5 - angle * ( i + 1 ) ) - 0.5 * mChannelHeight + 0.5 ); mChannelRects[ i ].width = mBoxWidth; mChannelRects[ i ].height = mChannelHeight; memDC.SetPen( mSelectedChannel == i ? *wxRED_PEN : *wxBLACK_PEN ); memDC.DrawRectangle( mChannelRects[ i ] ); memDC.DrawText( wxString::Format( _( "Channel: %2d" ), i + 1 ), mChannelRects[ i ].x + ( mBoxWidth - w ) / 2, mChannelRects[ i ].y + ( mChannelHeight - h ) / 2 ); } //draw links memDC.SetPen( wxPen( *wxBLACK, mHeight / 200 ) ); for( int i = 0; i < mMixerSpec->GetNumTracks(); i++ ) for( int j = 0; j < mMixerSpec->GetNumChannels(); j++ ) if( mMixerSpec->mMap[ i ][ j ] ) memDC.DrawLine( mTrackRects[ i ].x + mBoxWidth, mTrackRects[ i ].y + mTrackHeight / 2, mChannelRects[ j ].x, mChannelRects[ j ].y + mChannelHeight / 2 ); dc.Blit( 0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE ); }
void EqualizationPanel::OnPaint(wxPaintEvent & evt) { wxPaintDC dc(this); int width, height; GetSize(&width, &height); if (!mBitmap || mWidth!=width || mHeight!=height) { if (mBitmap) delete mBitmap; mWidth = width; mHeight = height; mBitmap = new wxBitmap(mWidth, mHeight); } wxColour bkgnd = GetBackgroundColour(); wxBrush bkgndBrush(bkgnd, wxSOLID); wxMemoryDC memDC; memDC.SelectObject(*mBitmap); wxRect bkgndRect; bkgndRect.x = 0; bkgndRect.y = 0; bkgndRect.width = 40; bkgndRect.height = mHeight; memDC.SetBrush(bkgndBrush); memDC.SetPen(*wxTRANSPARENT_PEN); memDC.DrawRectangle(bkgndRect); bkgndRect.y = mHeight - 20; bkgndRect.width = mWidth; bkgndRect.height = 20; memDC.DrawRectangle(bkgndRect); wxRect border; border.x = 40; border.y = 0; border.width = mWidth; border.height = mHeight - 20; memDC.SetBrush(*wxWHITE_BRUSH); memDC.SetPen(*wxBLACK_PEN); memDC.DrawRectangle(border); mEnvRect.x = 44; mEnvRect.width = mWidth - 50; mEnvRect.y = 3; mEnvRect.height = mHeight - 26; // Pure blue x-axis line memDC.SetPen(wxPen(wxColour(0, 0, 255), 1, wxSOLID)); int center = mEnvRect.height/2; memDC.DrawLine(mEnvRect.x, mEnvRect.y + center, mEnvRect.x + mEnvRect.width, mEnvRect.y + center); // Med-blue envelope line memDC.SetPen(wxPen(wxColour(110, 110, 220), 3, wxSOLID)); // Draw envelope double *values = new double[mEnvRect.width]; mEnvelope->GetValues(values, mEnvRect.width, 0.0, 1.0/mEnvRect.width); int x, y, xlast = 0, ylast = 0; for(int i=0; i<mEnvRect.width; i++) { x = mEnvRect.x + i; y = (int)(mEnvRect.height-mEnvRect.height*values[i]); if (i != 0) { memDC.DrawLine(xlast, ylast, x, mEnvRect.y + y); } xlast = x; ylast = y; } delete[] values; memDC.SetPen(*wxBLACK_PEN); mEnvRect.y -= 5; mEnvelope->Draw(memDC, mEnvRect, 0.0, mEnvRect.width, false, 0.0, 1.0); mEnvRect.y += 5; // Paint border again memDC.SetBrush(*wxTRANSPARENT_BRUSH); memDC.SetPen(*wxBLACK_PEN); memDC.DrawRectangle(border); // Ruler Ruler dbRuler; dbRuler.SetBounds(0, 0, 40, mHeight-21); dbRuler.SetOrientation(wxVERTICAL); dbRuler.SetRange(30, -30); dbRuler.SetFormat(Ruler::LinearDBFormat); dbRuler.SetUnits("dB"); dbRuler.Draw(memDC); Ruler freqRuler; freqRuler.SetBounds(41, mHeight-20, mWidth, mHeight); freqRuler.SetOrientation(wxHORIZONTAL); freqRuler.SetLog(true); freqRuler.SetRange(mLoFreq, mHiFreq); freqRuler.SetFormat(Ruler::IntFormat); freqRuler.SetUnits("Hz"); freqRuler.SetFlip(true); freqRuler.Draw(memDC); dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE); }
void EffectScienFilterPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) { wxPaintDC dc(this); int width, height; GetSize(&width, &height); if (!mBitmap || mWidth != width || mHeight != height) { if (mBitmap) { delete mBitmap; } mWidth = width; mHeight = height; mBitmap = new wxBitmap(mWidth, mHeight); } wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); wxMemoryDC memDC; memDC.SelectObject(*mBitmap); wxRect bkgndRect; bkgndRect.x = 0; bkgndRect.y = 0; bkgndRect.width = mWidth; bkgndRect.height = mHeight; memDC.SetBrush(bkgndBrush); memDC.SetPen(*wxTRANSPARENT_PEN); memDC.DrawRectangle(bkgndRect); bkgndRect.y = mHeight; memDC.DrawRectangle(bkgndRect); wxRect border; border.x = 0; border.y = 0; border.width = mWidth; border.height = mHeight; memDC.SetBrush(*wxWHITE_BRUSH); memDC.SetPen(*wxBLACK_PEN); memDC.DrawRectangle(border); mEnvRect = border; mEnvRect.Deflate(2, 2); // Pure blue x-axis line memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxSOLID)); int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5); AColor::Line(memDC, mEnvRect.GetLeft(), mEnvRect.y + center, mEnvRect.GetRight(), mEnvRect.y + center); //Now draw the actual response that you will get. //mFilterFunc has a linear scale, window has a log one so we have to fiddle about memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxSOLID)); double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB double yF; // gain at this freq double loLog = log10(mLoFreq); double step = log10(mHiFreq) - loLog; step /= ((double) mEnvRect.width - 1.0); double freq; // actual freq corresponding to x position int x, y, xlast = 0, ylast = 0; for (int i = 0; i < mEnvRect.width; i++) { x = mEnvRect.x + i; freq = pow(10.0, loLog + i * step); //Hz yF = mEffect->FilterMagnAtFreq (freq); yF = LINEAR_TO_DB(yF); if (yF < mDbMin) { yF = mDbMin; } yF = center-scale * yF; if (yF > mEnvRect.height) { yF = (double) mEnvRect.height - 1.0; } if (yF < 0.0) { yF = 0.0; } y = (int) (yF + 0.5); if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1)) { AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y); } xlast = x; ylast = mEnvRect.y + y; } memDC.SetPen(*wxBLACK_PEN); mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1); mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2); dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE); memDC.SelectObject(wxNullBitmap); }