void GribRequestSetting::OnVpChange(PlugIn_ViewPort *vp) { if(!m_AllowSend) return; SetVpSize(vp); m_MailImage->SetValue( WriteMail() ); }
bool GribRequestSetting::MouseEventHook( wxMouseEvent &event ) { if( m_ZoneSelMode == AUTO_SELECTION || m_ZoneSelMode == SAVED_SELECTION || m_ZoneSelMode == START_SELECTION ) return false; if( event.Moving()) return false; //maintain status bar and tracking dialog updated if( event.LeftDown() ) { m_parent.pParent->SetFocus(); m_ZoneSelMode = DRAW_SELECTION; //restart a new drawing m_parent.SetRequestBitmap( m_ZoneSelMode ); if( this->IsShown() ) this->Hide(); //eventually hide diaog in case of mode change m_RenderZoneOverlay = 0; //eventually hide previous drawing } if( event.LeftUp () && m_RenderZoneOverlay == 2 ) { m_ZoneSelMode = COMPLETE_SELECTION; //ask to complete selection m_parent.SetRequestBitmap( m_ZoneSelMode ); SetCoordinatesText(); m_MailImage->SetValue( WriteMail() ); m_RenderZoneOverlay = 1; } if( event.Dragging() ) { if( m_RenderZoneOverlay < 2 ) { m_StartPoint = event.GetPosition(); //starting selection point m_RenderZoneOverlay = 2; } m_IsMaxLong = m_StartPoint.x > event.GetPosition().x? true: false; //find if startpoint is max longitude GetCanvasLLPix( m_Vp, event.GetPosition(), &m_Lat, &m_Lon); //extend selection if( !m_tMouseEventTimer.IsRunning() ) m_tMouseEventTimer.Start( 20, wxTIMER_ONE_SHOT ); } return true; }
void GribRequestSetting::OnMovingClick( wxCommandEvent& event ) { m_fgMovingParams->ShowItems( m_cMovingGribEnabled->IsChecked() && m_cMovingGribEnabled->IsShown() ); if(m_AllowSend) m_MailImage->SetValue( WriteMail() ); SetRequestDialogSize(); this->Refresh(); }
void GribRequestSetting::OnAnyChange(wxCommandEvent &event) { //permit to send a new message m_MailImage->SetForegroundColour(wxColor( 0, 0, 0 )); m_bSend->Show(); m_MailImage->SetLabel( WriteMail() ); Fit(); }
void GribRequestSetting::OnCoordinatesChange( wxSpinEvent& event ) { SetCoordinatesText(); StopGraphicalZoneSelection(); //eventually stop graphical zone display if( !m_AllowSend ) return; m_MailImage->SetValue( WriteMail() ); }
void GribRequestSetting::OnAnyChange(wxCommandEvent &event) { m_fgAltitudeData->ShowItems(m_pAltitudeData->IsChecked()); m_pWModel->Show( IsZYGRIB && m_pWaves->IsChecked()); if(m_AllowSend) m_MailImage->SetValue( WriteMail() ); SetMailImageSize(); }
void GribRequestSetting::OnModelChange(wxCommandEvent &event) { ApplyRequestConfig( m_pModel->GetCurrentSelection(), m_pResolution->GetCurrentSelection() ); //permit to send a new message m_MailImage->SetForegroundColour(wxColor( 0, 0, 0 )); m_bSend->Show(); m_MailImage->SetLabel( WriteMail() ); Fit(); }
void GribRequestSetting::OnTopChange(wxCommandEvent &event) { ApplyRequestConfig( m_pResolution->GetCurrentSelection(), m_pInterval->GetCurrentSelection(), m_pTimeRange->GetCurrentSelection() ); m_cMovingGribEnabled->Show( m_pMailTo->GetCurrentSelection() == SAILDOCS ); if(m_AllowSend) m_MailImage->SetValue( WriteMail() ); SetMailImageSize(); }
void GribRequestSetting::OnTimeRangeChange(wxCommandEvent &event) { m_pWModel->Show( IsZYGRIB && m_pWaves->IsChecked()); if( m_pModel->GetCurrentSelection() == 0 ) { //gfs if( m_pTimeRange->GetCurrentSelection() > 6 ) { //time range more than 8 days m_pWaves->SetValue(0); m_pWaves->Enable(false); OCPNMessageBox_PlugIn(this, _("You request a forecast for more than 8 days horizon.\nThis is conflicting with Wave data which will be removed from your request.\nDon't forget that beyond the first 8 days, the resolution will be only 2.5\u00B0x2.5\u00B0\nand the time intervall 12 hours."), _("Warning!") ); } else m_pWaves->Enable(true); } if(m_AllowSend) m_MailImage->SetValue( WriteMail() ); SetRequestDialogSize(); }
void GribRequestSetting::InitRequestConfig() { long i,j; ( (wxString) m_RequestConfigBase.GetChar(2) ).ToLong( &i ); ( (wxString) m_RequestConfigBase.GetChar(3) ).ToLong( &j ); ApplyRequestConfig( i, j ); ( (wxString) m_RequestConfigBase.GetChar(4) ).ToLong( &j ); m_pInterval->SetSelection( j ); ( (wxString) m_RequestConfigBase.GetChar(5) ).ToLong( &j ); m_pTimeRange->SetSelection( j ); m_pWind->Enable( false ); m_pPress->Enable( false ); m_MailImage->SetLabel( WriteMail() ); Fit(); }
void GribRequestSetting::SetVpSize(PlugIn_ViewPort *vp) { double lonmax= vp->lon_max; double lonmin= vp->lon_min; if( ( fabs(vp->lat_max ) < 90. ) && ( fabs( lonmax ) < 360. ) ) { if( lonmax < -180. ) lonmax += 360.; if( lonmax > 180. ) lonmax -= 360.; } if( ( fabs( vp->lat_min ) < 90. ) && ( fabs( lonmin ) < 360. ) ) { if( lonmin < -180. ) lonmin += 360.; if( lonmin > 180. ) lonmin -= 360.; } m_spMaxLat->SetValue( (int) ceil( vp->lat_max) ); m_spMinLon->SetValue( (int) floor(lonmin) ); m_spMinLat->SetValue( (int) floor(vp->lat_min) ); m_spMaxLon->SetValue( (int) ceil(lonmax) ); SetCoordinatesText(); m_MailImage->SetValue( WriteMail() ); }
void GribRequestSetting::OnZoneSelectionModeChange( wxCommandEvent& event ) { StopGraphicalZoneSelection(); //eventually stop graphical zone display if( !m_ZoneSelMode ) SetVpSize( m_Vp ); //recompute zone if( event.GetId() == MANSELECT ) { //set temporarily zone selection mode if manual selection set, put it directly in "drawing" position //else put it in "auto selection position m_ZoneSelMode = m_cManualZoneSel->GetValue() ? DRAW_SELECTION : AUTO_SELECTION; m_cUseSavedZone->SetValue( false ); } else if(event.GetId() == SAVEDZONE ) { //set temporarily zone selection mode if saved selection set, put it directly in "no selection" position //else put it directly in "drawing" position m_ZoneSelMode = m_cUseSavedZone->GetValue()? SAVED_SELECTION : DRAW_SELECTION; } m_parent.SetRequestBitmap( m_ZoneSelMode ); //set appopriate bitmap fgZoneCoordinatesSizer->ShowItems( m_ZoneSelMode != AUTO_SELECTION ); //show coordinate if necessary m_cUseSavedZone->Show( m_ZoneSelMode != AUTO_SELECTION ); if(m_AllowSend) m_MailImage->SetValue( WriteMail() ); SetRequestDialogSize(); }
void GribRequestSetting::OnSendMaiL( wxCommandEvent& event ) { wxMailMessage *message = new wxMailMessage( wxT("Grib-Request"), m_MailAdressBase, //to ( saildoc request adresse ) WriteMail() //message ); wxEmail mail ; m_MailImage->SetForegroundColour(wxColor( 255, 0, 0 )); if(mail.Send( *message ) ) { #ifdef __WXMSW__ m_MailImage->SetLabel( _("Your request is ready. An eMail is prepared in your eMail environment. \nYou have just to click 'send' to send it...\nSave or Cancel to finish...or new parameters for a new eMail ...") ); #else m_MailImage->SetLabel( _("Your request was sent \n(if your system has an MTA configured and is able to send eMail).\nSave or Cancel to finish...or new parameters for a new eMail ...")); #endif } else { m_MailImage->SetLabel( _("Request can't be sent. Please verify your eMail systeme parameters.\nYou should also have a look at your log file.\nSave or Cancel to finish...")); } m_bSend->Hide(); Fit(); }
void GribRequestSetting::OnSendMaiL( wxCommandEvent& event ) { if(!m_AllowSend) { m_rButtonCancel->Show(); m_rButtonApply->Show(); m_rButtonYes->SetLabel(_("Send")); m_MailImage->SetForegroundColour(wxColor( 0, 0, 0 )); //permit to send a (new) message m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); SetMailImageSize(); return; } const wxString error[] = { _T("\n\n"), _("Before sending an email to Zygrib you have to enter your Login and Code.\nPlease visit www.zygrib.org/ and follow instructions..."), _("The file size limit is overcome!\nYou can zoom in and/or change parameters...") }; m_MailImage->SetForegroundColour(wxColor( 255, 0, 0 )); m_AllowSend = false; if( m_MailError_Nb ) { // m_MailImage->SetForegroundColour(wxColor( 255, 0, 0 )); if( m_MailError_Nb == 3 ) m_MailImage->SetValue( error[1] + error[0] + error[2] ); else m_MailImage->SetValue( error[m_MailError_Nb] ); m_rButtonCancel->Hide(); m_rButtonApply->Hide(); m_rButtonYes->SetLabel(_("Continue...")); SetMailImageSize(); return; } wxMailMessage *message = new wxMailMessage( wxT("gribauto"), //requested subject (m_pMailTo->GetCurrentSelection() == SAILDOCS) ? m_MailToAddresses.BeforeFirst(_T(';')) //to request address : m_MailToAddresses.AfterFirst(_T(';')), WriteMail(), //message image m_pSenderAddress->GetValue() ); wxEmail mail ; if(mail.Send( *message, m_SendMethod)) { #ifdef __WXMSW__ m_MailImage->SetValue( _("Your request is ready. An email is prepared in your email environment. \nYou have just to verify and send it...\nSave or Cancel to finish...or Continue...") ); #else if(m_SendMethod == 0 ) { m_MailImage->SetValue( _("Your request is ready. An email is prepared in your email environment. \nYou have just to verify and send it...\nSave or Cancel to finish...or Continue...") ); } else { m_MailImage->SetValue( _("Your request was sent \n(if your system has an MTA configured and is able to send email).\nSave or Cancel to finish...or Continue...") ); } #endif } else { m_MailImage->SetValue( _("Request can't be sent. Please verify your email systeme parameters.\nYou should also have a look at your log file.\nSave or Cancel to finish...")); m_rButtonYes->Hide(); } m_rButtonYes->SetLabel(_("Continue...")); SetMailImageSize(); }
//---------------------------------------------------------------------------------------------------------- // GRIB Request Implementation //---------------------------------------------------------------------------------------------------------- void GribRequestSetting::InitRequestConfig() { DimeWindow( this ); //aplly global colours scheme wxFileConfig *pConf = GetOCPNConfigObject(); if(pConf) { pConf->SetPath ( _T( "/PlugIns/GRIB" ) ); wxString l; int m; pConf->Read ( _T( "MailRequestConfig" ), &m_RequestConfigBase, _T( "000220XX........0" ) ); pConf->Read ( _T( "MailSenderAddress" ), &l, _T("") ); m_pSenderAddress->ChangeValue( l ); pConf->Read ( _T( "MailRequestAddresses" ), &m_MailToAddresses, _T("[email protected];[email protected]") ); pConf->Read ( _T( "ZyGribLogin" ), &l, _T("") ); m_pLogin->ChangeValue( l ); pConf->Read ( _T( "ZyGribCode" ), &l, _T("") ); m_pCode->ChangeValue( l ); pConf->Read ( _T( "SendMailMethod" ), &m_SendMethod, 0 ); pConf->Read ( _T( "MovingGribSpeed" ), &m, 0 ); m_sMovingSpeed->SetValue( m ); pConf->Read ( _T( "MovingGribCourse" ), &m, 0 ); m_sMovingCourse->SetValue( m ); //if GriDataConfig has been corrupted , take the standard one to fix a crash if( m_RequestConfigBase.Len() != wxString (_T( "000220XX.............." ) ).Len() ) m_RequestConfigBase = _T( "000220XX.............." ); } //populate model, mail to, waves model choices wxString s1[] = {_T("GFS"),_T("COAMPS"),_T("RTOFS")}; for( unsigned int i= 0; i<(sizeof(s1) / sizeof(wxString));i++) m_pModel->Append( s1[i] ); wxString s2[] = {_T("Saildocs"),_T("zyGrib")}; for( unsigned int i= 0; i<(sizeof(s2) / sizeof(wxString));i++) m_pMailTo->Append( s2[i] ); wxString s3[] = {_T("WW3-GLOBAL"),_T("WW3-MEDIT")}; for( unsigned int i= 0; i<(sizeof(s3) / sizeof(wxString));i++) m_pWModel->Append( s3[i] ); m_rButtonYes->SetLabel(_("Send")); m_rButtonApply->SetLabel(_("Save")); m_tResUnit->SetLabel(wxString::Format( _T("\u00B0"))); m_sCourseUnit->SetLabel(wxString::Format( _T("\u00B0"))); //add tooltips m_pSenderAddress->SetToolTip(_("Address used to send request eMail. (Mandatory for LINUX)")); m_pLogin->SetToolTip(_("This is your zyGrib's forum access Login")); m_pCode->SetToolTip(_("Get this Code in zyGrib's forum ( This is not your password! )")); m_sMovingSpeed->SetToolTip(_("Enter your forescasted Speed (in Knots)")); m_sMovingCourse->SetToolTip(_("Enter your forecasted Course")); long i,j,k; ( (wxString) m_RequestConfigBase.GetChar(0) ).ToLong( &i ); //MailTo m_pMailTo->SetSelection(i); ( (wxString) m_RequestConfigBase.GetChar(1) ).ToLong( &i ); //Model m_pModel->SetSelection(i); m_cMovingGribEnabled->SetValue(m_RequestConfigBase.GetChar(16) == 'X' );//Moving Grib ( (wxString) m_RequestConfigBase.GetChar(2) ).ToLong( &i ); //Resolution ( (wxString) m_RequestConfigBase.GetChar(3) ).ToLong( &j ); //interval ( (wxString) m_RequestConfigBase.GetChar(4) ).ToLong( &k, 16 ); //Time Range k--; // range max = 2 to 16 stored in hexa from 1 to f #ifdef __WXMSW__ //show / hide sender elemants as necessary m_pSenderSizer->ShowItems(false); #else if(m_SendMethod == 0 ) m_pSenderSizer->ShowItems(false); else m_pSenderSizer->ShowItems(true); //possibility to use "sendmail" method with Linux #endif ApplyRequestConfig( i, j ,k); ( (wxString) m_RequestConfigBase.GetChar(5) ).ToLong( &j ); //Waves model m_pWModel->SetSelection( j ); m_pWind->Enable( false ); //always selected if available m_pPress->Enable( false ); m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); SetMailImageSize(); }
void GribRequestSetting::InitRequestConfig() { wxFileConfig *pConf = GetOCPNConfigObject(); if(pConf) { pConf->SetPath ( _T( "/PlugIns/GRIB" ) ); wxString l; int m; pConf->Read ( _T( "MailRequestConfig" ), &m_RequestConfigBase, _T( "000220XX........0" ) ); pConf->Read ( _T( "MailSenderAddress" ), &l, _T("") ); m_pSenderAddress->ChangeValue( l ); pConf->Read ( _T( "MailRequestAddresses" ), &m_MailToAddresses, _T("[email protected];[email protected]") ); pConf->Read ( _T( "ZyGribLogin" ), &l, _T("") ); m_pLogin->ChangeValue( l ); pConf->Read ( _T( "ZyGribCode" ), &l, _T("") ); m_pCode->ChangeValue( l ); pConf->Read ( _T( "SendMailMethod" ), &m_SendMethod, 0 ); pConf->Read ( _T( "MovingGribSpeed" ), &m, 0 ); m_sMovingSpeed->SetValue( m ); pConf->Read ( _T( "MovingGribCourse" ), &m, 0 ); m_sMovingCourse->SetValue( m ); m_cManualZoneSel->SetValue( m_SavedZoneSelMode != AUTO_SELECTION ); //has been read in GriUbICtrlBar dialog implementation or updated previously m_cUseSavedZone->SetValue( m_SavedZoneSelMode == SAVED_SELECTION ); fgZoneCoordinatesSizer->ShowItems( m_SavedZoneSelMode != AUTO_SELECTION ); m_cUseSavedZone->Show( m_SavedZoneSelMode != AUTO_SELECTION ); if( m_cManualZoneSel->GetValue() ) { pConf->Read ( _T( "RequestZoneMaxLat" ), &m, 0 ); m_spMaxLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLat" ), &m, 0 ); m_spMinLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMaxLon" ), &m, 0 ); m_spMaxLon->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLon" ), &m, 0 ); m_spMinLon->SetValue( m ); SetCoordinatesText(); } //if GriDataConfig has been corrupted , take the standard one to fix a crash if( m_RequestConfigBase.Len() != wxString (_T( "000220XX.............." ) ).Len() ) m_RequestConfigBase = _T( "000220XX.............." ); } //populate model, mail to, waves model choices wxString s1[] = {_T("GFS"),_T("COAMPS"),_T("RTOFS")}; for( unsigned int i= 0; i<(sizeof(s1) / sizeof(wxString));i++) m_pModel->Append( s1[i] ); wxString s2[] = {_T("Saildocs"),_T("zyGrib")}; for( unsigned int i= 0; i<(sizeof(s2) / sizeof(wxString));i++) m_pMailTo->Append( s2[i] ); wxString s3[] = {_T("WW3-GLOBAL"),_T("WW3-MEDIT")}; for( unsigned int i= 0; i<(sizeof(s3) / sizeof(wxString));i++) m_pWModel->Append( s3[i] ); m_rButtonYes->SetLabel(_("Send")); m_rButtonApply->SetLabel(_("Save")); m_tResUnit->SetLabel(wxString::Format( _T("\u00B0"))); m_sCourseUnit->SetLabel(wxString::Format( _T("\u00B0"))); //Set wxSpinCtrl sizing int w,h; GetTextExtent( _T("-360"), &w, &h, 0, 0, OCPNGetFont(_("Dialog"), 10)); // optimal text control size w += 30; h += 4; m_sMovingSpeed->SetMinSize( wxSize(w, h) ); m_sMovingCourse->SetMinSize( wxSize(w, h) ); m_spMaxLat->SetMinSize( wxSize(w, h) ); m_spMinLat->SetMinSize( wxSize(w, h) ); m_spMaxLon->SetMinSize( wxSize(w, h) ); m_spMinLon->SetMinSize( wxSize(w, h) ); //add tooltips m_pSenderAddress->SetToolTip(_("Address used to send request eMail. (Mandatory for LINUX)")); m_pLogin->SetToolTip(_("This is your zyGrib's forum access Login")); m_pCode->SetToolTip(_("Get this Code in zyGrib's forum ( This is not your password! )")); m_sMovingSpeed->SetToolTip(_("Enter your forescasted Speed (in Knots)")); m_sMovingCourse->SetToolTip(_("Enter your forecasted Course")); long i,j,k; ( (wxString) m_RequestConfigBase.GetChar(0) ).ToLong( &i ); //MailTo m_pMailTo->SetSelection(i); ( (wxString) m_RequestConfigBase.GetChar(1) ).ToLong( &i ); //Model m_pModel->SetSelection(i); m_cMovingGribEnabled->SetValue(m_RequestConfigBase.GetChar(16) == 'X' );//Moving Grib ( (wxString) m_RequestConfigBase.GetChar(2) ).ToLong( &i ); //Resolution ( (wxString) m_RequestConfigBase.GetChar(3) ).ToLong( &j ); //interval ( (wxString) m_RequestConfigBase.GetChar(4) ).ToLong( &k, 16 ); //Time Range k--; // range max = 2 to 16 stored in hexa from 1 to f #ifdef __WXMSW__ //show / hide sender elemants as necessary m_pSenderSizer->ShowItems(false); #else if(m_SendMethod == 0 ) m_pSenderSizer->ShowItems(false); else m_pSenderSizer->ShowItems(true); //possibility to use "sendmail" method with Linux #endif m_tMouseEventTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( GribRequestSetting::OnMouseEventTimer ), NULL, this); m_RenderZoneOverlay = 0; ApplyRequestConfig( i, j ,k); ( (wxString) m_RequestConfigBase.GetChar(5) ).ToLong( &j ); //Waves model m_pWModel->SetSelection( j ); m_pWind->Enable( false ); //always selected if available m_pPress->Enable( false ); DimeWindow( this ); //aplly global colours scheme m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); }
void GribRequestSetting::OnSendMaiL( wxCommandEvent& event ) { StopGraphicalZoneSelection(); //eventually stop graphical zone display if(!m_AllowSend) { m_rButtonCancel->Show(); m_rButtonApply->Show(); m_rButtonYes->SetLabel(_("Send")); m_MailImage->SetForegroundColour(wxColor( 0, 0, 0 )); //permit to send a (new) message m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); SetRequestDialogSize(); return; } const wxString error[] = { _T("\n\n"), _("Before sending an email to Zygrib you have to enter your Login and Code.\nPlease visit www.zygrib.org/ and follow instructions..."), _("Too big file! zyGrib limit is 2Mb!"), _("Error! Max Lat lower than Min Lat or Max Lon lower than Min Lon!"), _("Too large area! Each side must be less than 180\u00B0!"), _("Too small area for this resolution!") }; ::wxBeginBusyCursor(); m_MailImage->SetForegroundColour(wxColor( 255, 0, 0 )); m_AllowSend = false; if( m_MailError_Nb ) { if( m_MailError_Nb > 7 ) { m_MailImage->SetValue( error[1] + error[0] + error[m_MailError_Nb - 6] ); } else { if( m_MailError_Nb == 6 ) m_MailError_Nb = 1; m_MailImage->SetValue( error[m_MailError_Nb] ); } m_rButtonCancel->Hide(); m_rButtonApply->Hide(); m_rButtonYes->SetLabel(_("Continue...")); m_rButton->Layout(); SetRequestDialogSize(); ::wxEndBusyCursor(); return; } wxMailMessage *message = new wxMailMessage( wxT("gribauto"), //requested subject (m_pMailTo->GetCurrentSelection() == SAILDOCS) ? m_MailToAddresses.BeforeFirst(_T(';')) //to request address : m_MailToAddresses.AfterFirst(_T(';')), WriteMail(), //message image m_pSenderAddress->GetValue() ); wxEmail mail ; if(mail.Send( *message, m_SendMethod)) { #ifdef __WXMSW__ m_MailImage->SetValue( _("Your request is ready. An email is prepared in your email environment. \nYou have just to verify and send it...\nSave or Cancel to finish...or Continue...") ); #else if(m_SendMethod == 0 ) { m_MailImage->SetValue( _("Your request is ready. An email is prepared in your email environment. \nYou have just to verify and send it...\nSave or Cancel to finish...or Continue...") ); } else { m_MailImage->SetValue( _("Your request was sent \n(if your system has an MTA configured and is able to send email).\nSave or Cancel to finish...or Continue...") ); } #endif } else { m_MailImage->SetValue( _("Request can't be sent. Please verify your email systeme parameters.\nYou should also have a look at your log file.\nSave or Cancel to finish...")); m_rButtonYes->Hide(); } m_rButtonYes->SetLabel(_("Continue...")); m_rButton->Layout(); SetRequestDialogSize(); ::wxEndBusyCursor(); }