Exemple #1
0
void GRIBUIDialog::OpenFile(bool newestFile)
{
    m_bpPlay->SetBitmap(*m_bPlay);
    m_bpPlay->SetToolTip(_("Play"));
    m_tPlayStop.Stop();

    m_cRecordForecast->Clear();
    /* this should be un-commented to avoid a memory leak,
       but for some reason it crbashes windows */
//    delete m_bGRIBActiveFile;
    m_pTimelineSet = NULL;

    //get more recent file in default directory if necessary
    wxFileName f( m_file_name );
    if( newestFile || f.GetFullName().IsEmpty() ) m_file_name = GetNewestFileInDirectory();

    m_bGRIBActiveFile = new GRIBFile( m_file_name,
                                      pPlugIn->GetCopyFirstCumRec(),
                                      pPlugIn->GetCopyMissWaveRec() );    

    ArrayOfGribRecordSets *rsa = m_bGRIBActiveFile->GetRecordSetArrayPtr();
    if(rsa->GetCount() < 2)
        m_TimeLineHours = 0;
    else {
        GribRecordSet &first=rsa->Item(0), &last = rsa->Item(rsa->GetCount()-1);
        
        wxTimeSpan span = wxDateTime(last.m_Reference_Time) - wxDateTime(first.m_Reference_Time);
        m_TimeLineHours = span.GetHours();
        m_sTimeline->Enable();
    }
    m_sTimeline->SetValue(0);
    
    wxFileName fn( m_file_name );
    SetLabel( fn.GetFullName() );

    if( m_bGRIBActiveFile ) {
        if( m_bGRIBActiveFile->IsOK() ) { 
            //there could be valid but empty file
            if( rsa->GetCount() == 0 ) {
                m_bGRIBActiveFile = NULL;
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( _("Error:  No valid data in this file!") );
            } else
                PopulateComboDataList( 0 );
        } else {
            if( fn.IsDir() ) {
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( _("Warning:  Empty directory!") );
                SetLabel( fn.GetFullPath() );
            }
            else
                pPlugIn->GetGRIBOverlayFactory()->SetMessage( m_bGRIBActiveFile->GetLastMessage() );
	}
        SetFactoryOptions();
        DisplayDataGRS();
        PopulateTrackingControls();
    }
}
Exemple #2
0
void GRIBUIDialog::OpenFile()
{
    m_tbPlayStop->SetValue(false);
    m_tPlayStop.Stop();

    m_cRecordForecast->Clear();
    /* this should be un-commented to avoid a memory leak,
       but for some reason it crbashes windows */
//    delete m_bGRIBActiveFile;
    m_bGRIBActiveFile = new GRIBFile( m_file_name,
                                      pPlugIn->GetCopyFirstCumRec(),
                                      pPlugIn->GetCopyMissWaveRec() );    

    ArrayOfGribRecordSets *rsa = m_bGRIBActiveFile->GetRecordSetArrayPtr();
    if(rsa->GetCount() < 2)
        m_TimeLineHours = 0;
    else {
        GribRecordSet &first=rsa->Item(0), &last = rsa->Item(rsa->GetCount()-1);
        
        wxTimeSpan span = wxDateTime(last.m_Reference_Time) - wxDateTime(first.m_Reference_Time);
        m_TimeLineHours = span.GetHours();
        m_sTimeline->Enable();
    }
    m_sTimeline->SetValue(0);
    
    wxFileName fn( m_file_name );
    SetLabel( fn.GetFullName() );
    
    if( m_bGRIBActiveFile ) {
        if( m_bGRIBActiveFile->IsOK() ) { 
            PopulateComboDataList( 0 );
            SetFactoryOptions();
            DisplayDataGRS();
            PopulateTrackingControls();
        } else 
            pPlugIn->GetGRIBOverlayFactory()->SetMessage( m_bGRIBActiveFile->GetLastMessage() );
    }    
}