Exemplo n.º 1
0
void objsearch_pi::ScanArea( int latmin, int lonmin, int latmax, int lonmax, int scale )
{
    double lat = latmin;
    double lon = lonmin;
    double lat_step;
    double lon_step;
    double ppm_scale;
    
    while( !finishing && lat <= latmax )
    {
        JumpToPosition( lat, lon, m_vpppm );
        RequestRefresh(m_parent_window);
        wxMicroSleep(100);
        ppm_scale = CalculatePPM( scale );
        JumpToPosition( lat, lon, ppm_scale );
        RequestRefresh(m_parent_window);
        wxMicroSleep(100);
        lat_step = vplat_max - vplat_min;
        lon_step = vplon_max - vplon_min;
        while( !finishing && lon <= lonmax )
        {
            JumpToPosition(lat, lon, ppm_scale);
            RequestRefresh(m_parent_window);
            //wxMicroSleep(100);
            if (!finishing)
                wxYield();
            lon += lon_step;
        }
        lon = lonmin;
        lat += lat_step;
    }
    
    finishing = false;
}
Exemplo n.º 2
0
void logsWindow::ShowFriendsLogs() {
    wxString layerContents;
    wxString request_url;
    bool isLayerUpdate;

    request_url.Printf(_T("/connections.xml?api_key=%s&email=%s"),
            p_plugin->g_ApiKey.c_str(), p_plugin->g_Email.c_str());

    layerContents = p_plugin->DownloadLayer(request_url);

    if (layerContents.length() > 200) {
        isLayerUpdate = p_plugin->SaveLayer(layerContents, m_LogsFilePath);
        if (isLayerUpdate) {
            if (m_LogsLayer) {
                // hide and delete the current logs layer
                m_LogsLayer->SetVisibleOnChart(false);
                p_plugin->RenderLayerContentsOnChart(m_LogsLayer);
                RequestRefresh(m_parent_window);
                p_plugin->pLayerList->DeleteObject(m_LogsLayer);
            }

            DisplayLogsLayer();

            m_LastLogsRcvd = wxDateTime::Now();
            p_plugin->g_LastLogsRcvd = wxDateTime::GetTimeNow(); //to be saved in config file
            //wxBell();
        }
    } else {
        m_ErrorCondition = _T("Unable to retrieve friends logs: check your credentials and Follow List");
        Refresh(false);
        wxLogMessage(_T("sQuiddio: ")+m_ErrorCondition);
    }
}
Exemplo n.º 3
0
void GRIBUIDialog::TimelineChanged(bool sync)
{
    if(!m_bGRIBActiveFile)
        return;

    wxDateTime time = TimelineTime();
    SetGribTimelineRecordSet(GetTimeLineRecordSet(time));

    /* get closest index to update combo box */
    unsigned int i;
    ArrayOfGribRecordSets *rsa = m_bGRIBActiveFile->GetRecordSetArrayPtr();
    wxDateTime itime, ip1time;
    for(i=0; i<rsa->GetCount()-1; i++) {
        itime = rsa->Item(i).m_Reference_Time;
        ip1time = rsa->Item(i+1).m_Reference_Time;
        if(ip1time >= time)
            break;
    }

    if(time - itime < ip1time - time)
        m_cRecordForecast->SetSelection(i);
    else
        m_cRecordForecast->SetSelection(i+1);

    if(sync)
        return;

//    m_cRecordForecast->ToggleWindowStyle(wxCB_READONLY);
        m_cRecordForecast->SetValue( TToString( time, pPlugIn->GetTimeZone() ) );
//    m_cRecordForecast->ToggleWindowStyle(wxCB_READONLY);
    
    pPlugIn->SendTimelineMessage(time);
    RequestRefresh( pParent );
}
Exemplo n.º 4
0
void WmmUIDialog::EnablePlotChanged( wxCommandEvent& event )
{
    if(m_cbEnablePlot->GetValue())
      m_wmm_pi.RecomputePlot();
    m_wmm_pi.SetShowPlot(m_cbEnablePlot->GetValue());
    RequestRefresh( m_wmm_pi.m_parent_window );
}
Exemplo n.º 5
0
void GribRequestSetting::OnMouseEventTimer( wxTimerEvent & event)
{
    //compute zone starting point lon/lat for zone drawing
    double lat,lon;
    GetCanvasLLPix( m_Vp, m_StartPoint, &lat, &lon);

    //compute rounded coordinates
    if( lat > m_Lat) {
        m_spMaxLat->SetValue( (int) ceil(lat) );
        m_spMinLat->SetValue( (int) floor(m_Lat) );
    }
    else {
        m_spMaxLat->SetValue( (int) ceil(m_Lat) );
        m_spMinLat->SetValue( (int) floor(lat) );
    }
	if(m_IsMaxLong) {
        m_spMaxLon->SetValue( (int) ceil(lon) );
        m_spMinLon->SetValue( (int) floor(m_Lon) );
    }
    else {
        m_spMaxLon->SetValue( (int) ceil(m_Lon) );
        m_spMinLon->SetValue( (int) floor(lon) );
    }

    RequestRefresh( m_parent.pParent );
}
Exemplo n.º 6
0
void EBL::CentreOnBoat( bool bMoveEndPoint )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    pStartPoint->m_lat = g_pfFix.Lat;
    pStartPoint->m_lon = g_pfFix.Lon;

    if(m_dLength == 0.) m_dLength = pEndPoint->m_seg_len;

    if(bMoveEndPoint && !m_bEndPointMoving) {
        if(m_bRotateWithBoat) {
            MaintainWith();
        } else {
            if(!m_bFixedEndPosition) {
                PositionBearingDistanceMercator_Plugin(pStartPoint->m_lat, pStartPoint->m_lon, m_dEBLAngle, m_dLength, &pEndPoint->m_lat, &pEndPoint->m_lon);
            } else {
                double brg;
                double hdg = 0.;
                DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &brg, &m_dLength);
                switch(m_iMaintainWith) {
                    case ID_EBL_MAINTAIN_WITH_HEADING:
                        if(!isnan(g_pfFix.Hdt))
                            hdg = g_pfFix.Hdt;
                        break;
                    case ID_EBL_MAINTAIN_WITH_COG:
                        if(!isnan(g_pfFix.Cog))
                            hdg = g_pfFix.Cog;
                        break;
                }
                if(hdg > brg)
                    m_dEBLAngle = brg + 360 - hdg;
                else if(hdg < brg)
                    m_dEBLAngle = hdg - brg;
                else m_dEBLAngle = 0;
            }
        }
    } else {
        DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &m_dEBLAngle, &m_dLength);
        m_dBoatHeading = g_pfFix.Hdt;
        m_dBoatCOG = g_pfFix.Cog;
    }
    pStartPoint->m_ODPointName = _("Boat");
    m_bCentreOnBoat = true;
    
    UpdateEBL();
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        pStartPoint->SetODPointRangeRingsStep( m_dLength / pStartPoint->GetODPointRangeRingsNumber() );
    }
    
    bool l_bRequestRefresh = true;
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        l_bRequestRefresh = g_pEBLPropDialog->UpdateProperties();
    
    m_bSaveUpdates = false;
    if(l_bRequestRefresh)
        RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    
    return;
}
Exemplo n.º 7
0
void PathProp::OnPathPropOkClick( wxCommandEvent& event )
{
    //    Look in the path list to be sure the path is still available
    //    (May have been deleted by PathManagerDialog...)

    wxPathListNode *node = g_pPathList->GetFirst();
    while( node ) {
        Path *pPath = node->GetData();

        if( pPath == m_pPath ) {
            m_pPath->m_iBlink--;
            SaveChanges();              // write changes to globals and update config
            m_pPath->ClearHighlights();
            break;
        }
        node = node->GetNext();
    }


    m_pEnroutePoint = NULL;
    m_bStartNow = false;

    if( g_pPathManagerDialog && g_pPathManagerDialog->IsShown() ) {
        g_pPathManagerDialog->UpdatePathListCtrl();
    }

    Hide();
    RequestRefresh( GetOCPNCanvasWindow() );
    
    event.Skip();

}
void CMackieControlBase::DispatchRefreshRequest()
{
	if (m_bForceRefreshAllWhenDone)
	{
		RequestRefreshAll(true);
	}
	else
	{
		if (m_bForceRefreshWhenDone)
			RequestRefresh(true);

		if (m_bRefreshAllWhenDone)
			RequestRefreshAll(false);
		else if (m_bRefreshWhenDone && !m_bForceRefreshWhenDone)
			RequestRefresh(false);
	}
}
void CelestialNavigationDialog::OnDelete(wxCommandEvent &event)
{
    // Delete selected_index sight/track
    long selected_index = m_lSights->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    if (selected_index < 0) return;
    
    m_lSights->DeleteItem(selected_index);
    RequestRefresh( GetParent() );
}
void CelestialNavigationDialog::OnDeleteAll(wxCommandEvent &event)
{
    wxMessageDialog mdlg(this, _("Are you sure you want to delete all sights?"),
                         _("Celestial Navigation"), wxYES_NO);
    if(mdlg.ShowModal() == wxID_YES) {
        m_lSights->DeleteAllItems();
        RequestRefresh( GetParent() );
    }
}
Exemplo n.º 11
0
void climatology_pi::OnToolbarToolCallback(int id)
{
    CreateOverlayFactory();

    if(m_pClimatologyDialog->IsShown() && m_pClimatologyDialog->m_cfgdlg)
        m_pClimatologyDialog->m_cfgdlg->Hide();

    m_pClimatologyDialog->Show(!m_pClimatologyDialog->IsShown());
    RequestRefresh(m_parent_window); // refresh main window
}
Exemplo n.º 12
0
void climatology_pi::OnClimatologyDialogClose()
{
    if(m_pClimatologyDialog) {
        if(m_pClimatologyDialog->m_cfgdlg)
            m_pClimatologyDialog->m_cfgdlg->Hide();
        m_pClimatologyDialog->Show(false);
        RequestRefresh(m_parent_window); // refresh main window
    }
    SaveConfig();
}
Exemplo n.º 13
0
void GribRequestSetting::OnClose( wxCloseEvent& event )
{
    m_RenderZoneOverlay = 0;                                    //eventually stop graphical zone display
    RequestRefresh( m_parent.pParent );

    //allow to be back to old value if changes have not been saved
    m_ZoneSelMode = m_SavedZoneSelMode;
    m_parent.SetRequestBitmap( m_ZoneSelMode );                                           //set appopriate bitmap

    this->Hide();
}
Exemplo n.º 14
0
void GRIBUIDialog::SetFactoryOptions()
{
    m_sTimeline->SetMax(m_TimeLineHours*m_OverlaySettings.m_HourDivider);
    if(m_pTimelineSet)
        m_pTimelineSet->ClearCachedData();

    pPlugIn->GetGRIBOverlayFactory()->ClearCachedData();

    UpdateTrackingControls();
    RequestRefresh( pParent );
}
void CelestialNavigationDialog::OnDuplicate(wxCommandEvent &event)
{
    long selected_index = m_lSights->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    if (selected_index < 0) return;

    Sight *psight = (Sight*)wxUIntToPtr(m_lSights->GetItemData(selected_index));
    Sight *ns = new Sight(*psight);
    ns->RebuildPolygons();
    InsertSight(ns);
    RequestRefresh( GetParent() );
}
void ClockCorrectionDialog::OnUpdate( wxSpinEvent& event )
{
    CelestialNavigationDialog *parent((CelestialNavigationDialog*)GetParent());
    wxListCtrl *lSights = parent->m_lSights;
    for(int i = 0; i<lSights->GetItemCount(); i++) {
        Sight *s = (Sight*)wxUIntToPtr(lSights->GetItemData(i));
        s->Recompute(m_sClockCorrection->GetValue());
    }

    parent->UpdateSights();
    RequestRefresh( parent->GetParent() );
}
Exemplo n.º 17
0
void logsWindow::OnTimerTimeout(wxTimerEvent& event) {
    if (p_plugin->CheckIsOnline()) {
        RequestRefresh(m_parent_window);
        ShowFriendsLogs();
        if (m_pTimer->GetInterval() / 1000 < g_RetrieveSecs) {
            // after initial friends update, reset the timer to the required interval
            SetTimer(0);
            SetTimer(g_RetrieveSecs * 1000);
        }
    }
    Refresh(false);
}
void CelestialNavigationDialog::OnNew(wxCommandEvent &event)
{
    wxDateTime now = wxDateTime::Now().ToUTC();

    Sight s(Sight::ALTITUDE, _("Sun"), Sight::LOWER, now, 0, 0, 10);
    SightDialog dialog(GetParent(), s, m_ClockCorrectionDialog.m_sClockCorrection->GetValue());
      
    if( dialog.ShowModal() == wxID_OK ) {
        Sight *ns = new Sight(s);

        dialog.Recompute();
        ns->RebuildPolygons();
        InsertSight(ns);
        RequestRefresh( GetParent() );
    }
}
Exemplo n.º 19
0
void weather_routing_pi::OnCursorLatLonTimer( wxTimerEvent & )
{
    std::list<RouteMapOverlay *>routemapoverlays = m_pWeather_Routing->CurrentRouteMaps();
    bool refresh = false;
    for(std::list<RouteMapOverlay *>::iterator it = routemapoverlays.begin();
        it != routemapoverlays.end(); it++)
        if((*it)->SetCursorLatLon(m_cursor_lat, m_cursor_lon))
            refresh = true;

    m_pWeather_Routing->UpdateCursorPositionDialog();

    if(refresh) {
        RequestRefresh(m_parent_window);
        m_pWeather_Routing->CursorRouteChanged();
    }
}
Exemplo n.º 20
0
void WatchdogDialog::OnLeftDown( wxMouseEvent& event )
{
    if(event.GetX() >= m_lStatus->GetColumnWidth(0))
        return;

    wxPoint pos = event.GetPosition();
    int flags = 0;
    long index = m_lStatus->HitTest(pos, flags);
    if(index < 0)
        return;

    Alarm *alarm = Alarm::s_Alarms[index];
    alarm->m_bEnabled = !alarm->m_bEnabled;
    if(!alarm->m_bEnabled) {
        alarm->m_bFired = false;
        RequestRefresh(GetOCPNCanvasWindow());
    }
    UpdateStatus(index);
}
Exemplo n.º 21
0
void EBL::CentreOnLatLon( double lat, double lon )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    pStartPoint->m_lat = lat;
    pStartPoint->m_lon = lon;
    pStartPoint->m_ODPointName = _("Start");
    if(pStartPoint->GetIconName() != wxEmptyString) {
        pStartPoint->SetIconName( g_sEBLStartIconName );
        pStartPoint->ReLoadIcon();
    }
    m_bCentreOnBoat = false;
    m_bSaveUpdates = true;
    
    UpdateEBL();
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
    
    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    return;
}
void CelestialNavigationDialog::OnEdit( )
{
    // Manipulate selected_index sight/track
    long selected_index = m_lSights->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    if (selected_index < 0) return;

    Sight *psight = (Sight*)wxUIntToPtr(m_lSights->GetItemData(selected_index));
    Sight originalsight = *psight; /* in case of cancel */
    
    SightDialog dialog(GetParent(), *psight, m_ClockCorrectionDialog.m_sClockCorrection->GetValue());
    
    if( dialog.ShowModal() == wxID_OK ) {
        dialog.Recompute();
        psight->RebuildPolygons();
        UpdateSight(selected_index);
    } else
        *psight = originalsight;

    RequestRefresh( GetParent() );
}
Exemplo n.º 23
0
void WeatherRouting::OnWeatherRoutesListLeftDown(wxMouseEvent &event)
{
    wxPoint pos = event.GetPosition();
    int flags = 0;
    long index = m_lWeatherRoutes->HitTest(pos, flags);

    //    Clicking Visibility column?
    if (index > -1 && event.GetX() < m_lWeatherRoutes->GetColumnWidth(0))
    {
        // Process the clicked item
        WeatherRoute *weatherroute =
            reinterpret_cast<WeatherRoute*>(wxUIntToPtr(m_lWeatherRoutes->GetItemData(index)));
        weatherroute->routemapoverlay->m_bEndRouteVisible =
            !weatherroute->routemapoverlay->m_bEndRouteVisible;
        UpdateItem(index);
        RequestRefresh( GetParent() );
    }

    // Allow wx to process...
    event.Skip();
}
Exemplo n.º 24
0
logsWindow::logsWindow(squiddio_pi * plugin, wxWindow *pparent, wxWindowID id) :
        wxWindow(pparent, id, wxPoint(10, 200), wxSize(1000, 25),
                wxSIMPLE_BORDER, _T("OpenCPN PlugIn")) {

    this->SetTransparent(30);
    p_plugin = plugin;
    m_parent_window = pparent;
    m_pTimer = new wxTimer(this, TIMER_ID);
    m_pRefreshTimer = new wxTimer(this, TIMER_ID1);
    m_pRefreshTimer->Start(5000);

    m_LogsLayer = NULL;
    m_ErrorCondition = wxEmptyString;
    m_Notice = wxEmptyString;
    g_RetrieveSecs = period_secs(p_plugin->g_RetrievePeriod);
    m_LastLogSent = p_plugin->g_LastLogSent;
    m_LastLogsRcvd = p_plugin->g_LastLogsRcvd;

    m_LogsFilePath = p_plugin->layerdir;
    p_plugin->appendOSDirSlash(&m_LogsFilePath);
    m_LogsFilePath.Append(_T("logs.gpx"));

    DisplayLogsLayer();

    if (g_RetrieveSecs > 0)  // display friends' logs
            {
        if (wxDateTime::Now().GetTicks() > m_LastLogsRcvd.GetTicks() + g_RetrieveSecs) // overdue request at startup?
        {
            RequestRefresh(m_parent_window);
            if (p_plugin->CheckIsOnline())
                ShowFriendsLogs();
        }
        int nextEvent = g_RetrieveSecs - (wxDateTime::Now().GetTicks() - m_LastLogsRcvd.GetTicks());

        // if update is overdue, delay by a few seconds to prevent get request from interfering with opencpn launch, else schedule it for when it's due
        SetTimer(wxMax(wxMin(nextEvent, g_RetrieveSecs), 7));
    }
}
Exemplo n.º 25
0
void EBL::CentreOnBoat( void )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    pStartPoint->m_lat = g_pfFix.Lat;
    pStartPoint->m_lon = g_pfFix.Lon;
    pStartPoint->m_ODPointName = _("Boat");
    m_bCentreOnBoat = true;
    
    UpdateEBL();
    if(m_bVRM) {
        ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
        ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
        pStartPoint->SetODPointRangeRingsStep( pEndPoint->m_seg_len / pStartPoint->GetODPointRangeRingsNumber() );
    }
    
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();

    m_bSaveUpdates = false;
    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    
    return;
}
Exemplo n.º 26
0
void PathProp::OnPathPropCancelClick( wxCommandEvent& event )
{
    //    Look in the path list to be sure the path is still available
    //    (May have been deleted by PathMangerDialog...)

    wxPathListNode *node = g_pPathList->GetFirst();
    while( node ) {
        Path *pPath = node->GetData();

        if( pPath == m_pPath ) {
            m_pPath->m_iBlink--;
            m_pPath->ClearHighlights();
            break;
        }
        node = node->GetNext();
    }


    m_bStartNow = false;

    Hide();
    RequestRefresh( GetOCPNCanvasWindow() );
    event.Skip();
}
Exemplo n.º 27
0
void EBL::CentreOnLatLon( double lat, double lon )
{
    ODPoint *pStartPoint = m_pODPointList->GetFirst()->GetData();
    ODPoint *pEndPoint = m_pODPointList->GetLast()->GetData();
    pStartPoint->m_lat = lat;
    pStartPoint->m_lon = lon;
    DistanceBearingMercator_Plugin(pEndPoint->m_lat, pEndPoint->m_lon, pStartPoint->m_lat, pStartPoint->m_lon, &m_dEBLAngle, &m_dLength);
    m_bRotateWithBoat = false;
    m_bCentreOnBoat = false;
    pStartPoint->m_ODPointName = _("Start");
    if(pStartPoint->GetIconName() != wxEmptyString) {
        pStartPoint->SetIconName( g_sEBLStartIconName );
        pStartPoint->ReLoadIcon();
    }
    m_bCentreOnBoat = false;
    m_bSaveUpdates = true;
    
    UpdateEBL();
    if(g_pEBLPropDialog && g_pEBLPropDialog->IsShown())
        g_pEBLPropDialog->UpdateProperties();
    
    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    return;
}
bool CelestialNavigationDialog::OpenXML(wxString filename, bool reportfailure)
{
    TiXmlDocument doc;
    wxString error;

    wxFileName fn(filename);

    if(!doc.LoadFile(filename.mb_str()))
        FAIL(_("Failed to load file: ") + filename);
    else {
        TiXmlHandle root(doc.RootElement());

        if(strcmp(root.Element()->Value(), "OpenCPNCelestialNavigation"))
            FAIL(_("Invalid xml file"));

        m_lSights->DeleteAllItems();

        for(TiXmlElement* e = root.FirstChild().Element(); e; e = e->NextSiblingElement()) {
            if(!strcmp(e->Value(), "ClockError")) {
                m_ClockCorrectionDialog.m_sClockCorrection->SetValue(AttributeInt(e, "Seconds", 0));
            } else if(!strcmp(e->Value(), "Sight")) {
                Sight s;

                s.m_bVisible = AttributeBool(e, "Visible", true);
                s.m_Type = (Sight::Type)AttributeInt(e, "Type", 0);
                s.m_Body = wxString::FromUTF8(e->Attribute("Body"));
                s.m_BodyLimb = (Sight::BodyLimb)AttributeInt(e, "BodyLimb", 0);

                s.m_DateTime.ParseISODate(wxString::FromUTF8(e->Attribute("Date")));

                wxDateTime time;
                time.ParseISOTime(wxString::FromUTF8(e->Attribute("Time")));

                if(s.m_DateTime.IsValid() && time.IsValid()) {
                    s.m_DateTime.SetHour(time.GetHour());
                    s.m_DateTime.SetMinute(time.GetMinute());
                    s.m_DateTime.SetSecond(time.GetSecond());
                } else
                    continue; /* skip if invalid */
            
                s.m_TimeCertainty = AttributeDouble(e, "TimeCertainty", 0);

                s.m_Measurement = AttributeDouble(e, "Measurement", 0);
                s.m_MeasurementCertainty = AttributeDouble(e, "MeasurementCertainty", .25);

                s.m_EyeHeight = AttributeDouble(e, "EyeHeight", 2);
                s.m_Temperature = AttributeDouble(e, "Temperature", 10);
                s.m_Pressure = AttributeDouble(e, "Pressure", 1010);
                s.m_IndexError = AttributeDouble(e, "IndexError", 0);

                s.m_ShiftNm = AttributeDouble(e, "ShiftNm", 0);
                s.m_ShiftBearing = AttributeDouble(e, "ShiftBearing", 0);
                s.m_bMagneticShiftBearing = AttributeBool(e, "MagneticShiftBearing", 0);

                s.m_ColourName = wxString::FromUTF8(e->Attribute("ColourName"));
                s.m_Colour = wxColour(wxString::FromUTF8(e->Attribute("Colour")));
                s.m_Colour.Set(s.m_Colour.Red(), s.m_Colour.Green(), s.m_Colour.Blue(),
                               AttributeInt(e, "Transparency", 150));

                Sight *ns = new Sight(s);

                ns->Recompute(m_ClockCorrectionDialog.m_sClockCorrection->GetValue());
                ns->RebuildPolygons();
                InsertSight(ns, false);
            } else
                FAIL(_("Unrecognized xml node"));
        }
    }

    RequestRefresh( GetParent() );
    return true;
failed:

    if(reportfailure) {
        wxMessageDialog mdlg(this, error, _("Celestial Navigation"), wxOK | wxICON_ERROR);
        mdlg.ShowModal();
    }
    return false;
}
Exemplo n.º 29
0
void ODDRDialogImpl::OnOK( wxCommandEvent& event )
{
    if( m_pDR != NULL ) {
        if( g_pPathMan->GetpActivePath() == m_pDR ) g_pPathMan->DeactivatePath( m_pDR );
        
        if( !g_pPathMan->DeletePath( m_pDR ) )
            return;
        if( g_pODPathPropDialog && ( g_pODPathPropDialog->IsShown()) && (m_pDR == g_pODPathPropDialog->GetPath()) ) {
            g_pODPathPropDialog->Hide();
        }
        
        if( g_pPathManagerDialog && g_pPathManagerDialog->IsShown() )
            g_pPathManagerDialog->UpdatePathListCtrl();
        
        if( g_pODPointPropDialog && g_pODPointPropDialog->IsShown() ) {
            g_pODPointPropDialog->ValidateMark();
            g_pODPointPropDialog->UpdateProperties();
        }
        
    }
    
    DR *l_pDR = new(DR);
    g_pDRList->Append( l_pDR );
    g_pPathList->Append( l_pDR );
    l_pDR->m_PathNameString << _("DR") << _T(" ") << g_pDRList->GetCount();
    
    ODPoint *beginPoint = new ODPoint( g_pfFix.Lat, g_pfFix.Lon, wxEmptyString, wxS("Start"), wxT("") );
    beginPoint->SetNameShown( false );
    beginPoint->SetTypeString( wxT("DR Point"));
    beginPoint->m_IconName = g_sDRPointIconName;
    beginPoint->m_bIsolatedMark = false;
    beginPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
    beginPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
    beginPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
    beginPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
    beginPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
    beginPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
    beginPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
    l_pDR->AddPoint( beginPoint, false );

    m_textCtrlSOG->GetValue().ToDouble( &l_pDR->m_dSoG );
    l_pDR->m_iCoG = g_ocpn_draw_pi->GetTrueOrMag( wxAtoi( m_textCtrlCOG->GetValue() ) );
    l_pDR->m_dMagCOG = g_dVar;
    m_textCtrlLength->GetValue().ToDouble( &l_pDR->m_dDRPathLength );
    m_textCtrlDRPointInterval->GetValue().ToDouble( &l_pDR->m_dDRPointInterval );
    
    l_pDR->m_iLengthType = m_radioBoxLengthType->GetSelection();
    l_pDR->m_iIntervalType = m_radioBoxIntervalType->GetSelection();
    l_pDR->m_iDistanceUnits = m_radioBoxDistanceUnits->GetSelection();
    l_pDR->m_iTimeUnits = m_radioBoxTimeUnits->GetSelection();
    
    switch ( m_radioBoxLengthType->GetSelection() ) {
        case ID_LT_TIME: {
            switch ( m_radioBoxTimeUnits->GetSelection() ) {
                case ID_TU_MINUTES:
                    l_pDR->m_dTotalLengthNM = ( l_pDR->m_dSoG / 60 ) * l_pDR->m_dDRPathLength;
                    break;
                case ID_TU_HOURS:
                    l_pDR->m_dTotalLengthNM = l_pDR->m_dSoG * l_pDR->m_dDRPathLength;
                    break;
                case ID_TU_DAYS:
                    l_pDR->m_dTotalLengthNM = ( l_pDR->m_dSoG * l_pDR->m_dDRPathLength ) * 24;
                    break;
            }
            break;
        }
        case ID_LT_DISTANCE: {
            if( m_radioBoxDistanceUnits->GetSelection() == ID_DU_KILOMETRES )
                l_pDR->m_dTotalLengthNM = l_pDR->m_dDRPathLength / 1.852;
            else
                l_pDR->m_dTotalLengthNM = l_pDR->m_dDRPathLength;
            break;
        }
    }
    
    switch ( m_radioBoxIntervalType->GetSelection() ) {
        case ID_IT_TIME: {
            switch ( m_radioBoxTimeUnits->GetSelection() ) {
                case ID_TU_MINUTES:
                    l_pDR->m_dDRPointIntervalNM = ( l_pDR->m_dSoG / 60 ) * l_pDR->m_dDRPointInterval;
                    break;
                case ID_TU_HOURS:
                    l_pDR->m_dDRPointIntervalNM = l_pDR->m_dSoG * l_pDR->m_dDRPointInterval;
                    break;
                case ID_TU_DAYS:
                    l_pDR->m_dDRPointIntervalNM = ( l_pDR->m_dSoG * l_pDR->m_dDRPointInterval ) * 24;
                    break;
            }
            break;
        }
        case ID_IT_DISTANCE: {
            if( m_radioBoxDistanceUnits->GetSelection() == ID_DU_KILOMETRES )
                l_pDR->m_dDRPointIntervalNM = l_pDR->m_dDRPointInterval / 1.852;
            else
                l_pDR->m_dDRPointIntervalNM = l_pDR->m_dDRPointInterval;
            break;
        }
    }
    
    double l_dStartLat = g_pfFix.Lat;
    double l_dStartLon = g_pfFix.Lon;
    double l_dEndLat;
    double l_dEndLon;

    PositionBearingDistanceMercator_Plugin( l_dStartLat, l_dStartLon, l_pDR->m_iCoG, l_pDR->m_dTotalLengthNM, &l_dEndLat, &l_dEndLon );
    
    int l_iNumODPoints = floor( l_pDR->m_dTotalLengthNM / l_pDR->m_dDRPointIntervalNM );
    double l_cumLength = l_pDR->m_dDRPointIntervalNM;
    double l_dSaveLat = l_dStartLat;
    double l_dSaveLon = l_dStartLon;
    for( int i = 0; i < l_iNumODPoints; i++ ) {
        double l_dLat, l_dLon;
        PositionBearingDistanceMercator_Plugin( l_dStartLat, l_dStartLon, l_pDR->m_iCoG, l_cumLength, &l_dLat, &l_dLon );
        ODPoint *l_NewPoint = new ODPoint( l_dLat, l_dLon, g_sDRPointIconName, wxT(""), wxT("") );
        l_NewPoint->SetNameShown( false );
        l_NewPoint->SetTypeString( wxS("DR Point") );
        l_NewPoint->m_bIsolatedMark = FALSE;
        l_NewPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
        l_NewPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
        l_NewPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
        l_NewPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
        l_NewPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
        l_NewPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
        l_NewPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
        l_pDR->AddPoint( l_NewPoint );
        g_pODSelect->AddSelectableODPoint( l_dLat, l_dLon, l_NewPoint );
        g_pODSelect->AddSelectablePathSegment( l_dLat, l_dLon, l_dSaveLat, l_dSaveLon, beginPoint, l_NewPoint, l_pDR );
        l_dSaveLat = l_dLat;
        l_dSaveLon = l_dLon;
        l_cumLength += l_pDR->m_dDRPointIntervalNM;
    }
    
    if( l_dEndLat != l_dSaveLat || l_dEndLon != l_dSaveLon ) {
        ODPoint *l_NewPoint = new ODPoint( l_dEndLat, l_dEndLon, g_sDRPointIconName, wxT(""), wxT("") );
        l_NewPoint->SetNameShown( false );
        l_NewPoint->SetTypeString( wxS("DR Point") );
        l_NewPoint->m_bIsolatedMark = FALSE;
        l_NewPoint->m_bShowODPointRangeRings = g_bDRPointShowRangeRings;
        l_NewPoint->m_iODPointRangeRingsNumber = g_iDRPointRangeRingsNumber;
        l_NewPoint->m_fODPointRangeRingsStep = g_fDRPointRangeRingsStep;
        l_NewPoint->m_iODPointRangeRingsStepUnits = g_iDRPointRangeRingsStepUnits;
        l_NewPoint->m_wxcODPointRangeRingsColour = g_colourDRPointRangeRingsColour;
        l_NewPoint->m_iRangeRingStyle = g_iDRPointRangeRingLineStyle;
        l_NewPoint->m_iRangeRingWidth = g_iDRPointRangeRingLineWidth;
        l_pDR->AddPoint( l_NewPoint );
        g_pODSelect->AddSelectableODPoint( l_dEndLat, l_dEndLon, l_NewPoint );
        g_pODSelect->AddSelectablePathSegment( l_dSaveLat, l_dSaveLon, l_dEndLat, l_dEndLon, beginPoint, l_NewPoint, l_pDR );
    }
    if(l_pDR->m_iPersistenceType == ID_DR_PERSISTENT || l_pDR->m_iPersistenceType == ID_DR_PERSISTENT_CRASH)
        g_pODConfig->AddNewPath( l_pDR, -1 );    // don't save over restart

    RequestRefresh( g_ocpn_draw_pi->m_parent_window );
    Show( false );
#ifdef __WXOSX__    
    EndModal(wxID_CANCEL);
#endif
}
Exemplo n.º 30
0
void grib_pi::OnToolbarToolCallback(int id)
{
    if( !::wxIsBusy() ) ::wxBeginBusyCursor();

    bool starting = false;

    double scale_factor = GetOCPNGUIToolScaleFactor_PlugIn();
    if( scale_factor != m_GUIScaleFactor ) starting = true;

    m_GUIScaleFactor = scale_factor;
    
    if(!m_pGribCtrlBar)
    {
        starting = true;
        long style = m_DialogStyle == ATTACHED_HAS_CAPTION ? wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU : wxBORDER_NONE|wxSYSTEM_MENU;
        m_pGribCtrlBar = new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString, wxDefaultPosition,
                wxDefaultSize, style, this);
        m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
        
        wxMenu* dummy = new wxMenu(_T("Plugin"));
        wxMenuItem* table = new wxMenuItem( dummy, wxID_ANY, wxString( _("Weather table") ), wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
        wxFont *qFont = OCPNGetFont(_("Menu"), 10);
        table->SetFont(*qFont);
#endif
        m_MenuItem = AddCanvasContextMenuItem(table, this);
        SetCanvasContextMenuItemViz(m_MenuItem, false);

        // Create the drawing factory
        m_pGRIBOverlayFactory = new GRIBOverlayFactory( *m_pGribCtrlBar );
        m_pGRIBOverlayFactory->SetTimeZone( m_bTimeZone );
        m_pGRIBOverlayFactory->SetParentSize( m_display_width, m_display_height);
        m_pGRIBOverlayFactory->SetSettings( m_bGRIBUseHiDef, m_bGRIBUseGradualColors );

        m_pGribCtrlBar->OpenFile( m_bLoadLastOpenFile == 0 );

    }

    if( m_pGribCtrlBar->GetFont() != *OCPNGetFont(_("Dialog"), 10) ) starting = true;

    //Toggle GRIB overlay display
    m_bShowGrib = !m_bShowGrib;

    //    Toggle dialog?
    if(m_bShowGrib) {
        if( starting ) {
            SetDialogFont( m_pGribCtrlBar );
	    m_pGribCtrlBar->SetScaledBitmap( m_GUIScaleFactor );
            m_pGribCtrlBar->SetDialogsStyleSizePosition( true );
            m_pGribCtrlBar->Refresh();
        } else {
            MoveDialog( m_pGribCtrlBar, GetCtrlBarXY(), wxPoint( 20, 60) );
            if( m_DialogStyle >> 1 == SEPARATED ) {
                MoveDialog( m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY(), wxPoint( 20, 170));
                m_pGribCtrlBar->GetCDataDialog()->Show( m_pGribCtrlBar->m_CDataIsShown );
                }
        }
        m_pGribCtrlBar->Show();
        if( m_pGribCtrlBar->m_bGRIBActiveFile ) {
            if( m_pGribCtrlBar->m_bGRIBActiveFile->IsOK() ) {
                ArrayOfGribRecordSets *rsa = m_pGribCtrlBar->m_bGRIBActiveFile->GetRecordSetArrayPtr();
                if(rsa->GetCount() > 1) SetCanvasContextMenuItemViz( m_MenuItem, true);
            }
        }
        // Toggle is handled by the CtrlBar but we must keep plugin manager b_toggle updated
        // to actual status to ensure correct status upon CtrlBar rebuild
        SetToolbarItemState( m_leftclick_tool_id, m_bShowGrib );
        RequestRefresh(m_parent_window); // refresh main window
    } else