I see what's happening to cause our approach to fail and I see how to resolve the problem. It's going to take quite a bit of code and there's absolutely no way to do it cleanly in an object-oriented way (at least that I can see).jerome42 wrote: For the moment I have no inspiration on how to go on
The code is failing here:
Code: Select all
wxASSERT(mPopupMenuTarget
&& mPopupMenuTarget->GetKind() == Track::Wave);The way I see it the best way to resolve this is to create a new public TrackPanel function:
Code: Select all
virtual void OnSetDisplayToSpectrum (WaveTrack * pWaveTrack);Code: Select all
void TrackPanel::OnSetDisplayToSpectrum(WaveTrack * pWaveTrack)Code: Select all
TrackFactory *mFactory;
TrackList *mTracks; // the complete list of all tracksThe place where you will need to do this work is here:
Code: Select all
bool EffectClickRemoval::PromptUser()
{
wxWindow * baseWindow = GetParent();//new public method of Effect class
AudacityProject * currentProject = (AudacityProject *)baseWindow;
TrackPanel * trackPanel = currentProject->GetTrackPanel();
WaveTrack * waveTrack = NULL;
//WaveTrack * waveTrack = ???; //you will need to figure out how to finish this line!
trackPanel->OnSetDisplayToSpectrum(waveTrack);
ClickRemovalDialog dlog(this, mParent);
Right now if you call the function with waveTrack equal to NULL you will just get a message box; if you wish to test out my working code you can do so by removing the comments between "begin test" and "end test":
Code: Select all
void TrackPanel::OnSetDisplay(wxCommandEvent & event)
{
int id = event.GetId();
wxASSERT(id >= OnWaveformID && id <= OnPitchID);
wxASSERT(mPopupMenuTarget
&& mPopupMenuTarget->GetKind() == Track::Wave);
id -= OnWaveformID;
WaveTrack *wt = (WaveTrack *) mPopupMenuTarget;
//begin test
// OnSetDisplayToSpectrum(wt);
// return;
// end testI am going to be out of town on business for the next 14 days with limited access to this forum and email and probably no access to the source code so don't be bummed out if you reply and see nothing from me for a while!
:view I added a command 'Spectrum or Wave toggle' which is activated by pressing the keyboard 'X' - very handy, at least for me.