Exemplo n.º 1
0
int engine_pi::Init(void)
{
//      printf("engine_pi Init()\n");

      m_pengine_window = NULL;

      // Get a pointer to the opencpn display canvas, to use as a parent for windows created
      m_parent_window = GetOCPNCanvasWindow();

      g_pFontTitle = new wxFont( 10, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL );
      g_pFontData = new wxFont( 14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
      g_pFontLabel = new wxFont( 8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
      g_pFontSmall = new wxFont( 8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );

     
     
     
      // Create the Context Menu Items

      //    In order to avoid an ASSERT on msw debug builds,
      //    we need to create a dummy menu to act as a surrogate parent of the created MenuItems
      //    The Items will be re-parented when added to the real context meenu
      wxMenu dummy_menu;

      wxMenuItem *pmi = new wxMenuItem(&dummy_menu, -1, _("Show Engine Instrumentation"));
      m_show_id = AddCanvasContextMenuItem(pmi, this );
      SetCanvasContextMenuItemViz(m_show_id, true);

      wxMenuItem *pmih = new wxMenuItem(&dummy_menu, -1, _("Hide Engine Instrumentation"));
      m_hide_id = AddCanvasContextMenuItem(pmih, this );
      SetCanvasContextMenuItemViz(m_hide_id, false);

        m_pengine_window = new EngineWindow(m_parent_window, wxID_ANY);

        m_AUImgr = GetFrameAuiManager();
        m_AUImgr->AddPane(m_pengine_window);
        m_AUImgr->GetPane(m_pengine_window).Name(_T("Engine Management"));

        m_AUImgr->GetPane(m_pengine_window).Float();
        m_AUImgr->GetPane(m_pengine_window).FloatingPosition(300,30);

        m_AUImgr->GetPane(m_pengine_window).Caption(_T("Engine Management"));
        m_AUImgr->GetPane(m_pengine_window).CaptionVisible(true);
        m_AUImgr->GetPane(m_pengine_window).GripperTop(true);
        m_AUImgr->GetPane(m_pengine_window).CloseButton(true);
        m_AUImgr->GetPane(m_pengine_window).Show(false);
       m_AUImgr->Update();
//Start( 5000, wxTIMER_CONTINUOUS );
      return (
           INSTALLS_CONTEXTMENU_ITEMS     |
           WANTS_NMEA_SENTENCES           |
           USES_AUI_MANAGER
            );
}
Exemplo n.º 2
0
int route_pi::Init(void)
{
      AddLocaleCatalog( _T("opencpn-route_pi") );

      // Set some default private member parameters
      m_route_dialog_x = 0;
      m_route_dialog_y = 0;
      ::wxDisplaySize(&m_display_width, &m_display_height);

      //    Get a pointer to the opencpn display canvas, to use as a parent for the POI Manager dialog
      m_parent_window = GetOCPNCanvasWindow();

      //    Get a pointer to the opencpn configuration object
      m_pconfig = GetOCPNConfigObject();

      //    And load the configuration items
      LoadConfig();

        // Create the Context Menu Items

        //    In order to avoid an ASSERT on msw debug builds,
        //    we need to create a dummy menu to act as a surrogate parent of the created MenuItems
        //    The Items will be re-parented when added to the real context meenu

        wxMenu dummy_menu;

      wxMenuItem *pmi = new wxMenuItem(&dummy_menu, -1, _("Start Route_pi Here"));
      m_add_start = AddCanvasContextMenuItem(pmi, this );
      SetCanvasContextMenuItemViz(m_add_start, true);

      wxMenuItem *pmih = new wxMenuItem(&dummy_menu, -1, _("Finish Route_pi Here."));
      m_add_finish = AddCanvasContextMenuItem(pmih, this );
      SetCanvasContextMenuItemViz(m_add_finish, true);


      //    This PlugIn needs a toolbar icon, so request its insertion
      m_leftclick_tool_id  = InsertPlugInTool(_T(""), _img_route_pi, _img_route_pi, wxITEM_NORMAL,
            _("Route"), _T(""), NULL,
             CALCULATOR_TOOL_POSITION, 0, this);

      m_pDialog = NULL;

      return (WANTS_TOOLBAR_CALLBACK   |
              INSTALLS_TOOLBAR_TOOL    |
              WANTS_PREFERENCES        |
              WANTS_CURSOR_LATLON      |
              WANTS_CONFIG
           );
}
Exemplo n.º 3
0
int weather_routing_pi::Init(void)
{
      AddLocaleCatalog( _T("opencpn-weather_routing_pi") );

      //    Get a pointer to the opencpn configuration object
      m_pconfig = GetOCPNConfigObject();

      // Get a pointer to the opencpn display canvas, to use as a parent for the WEATHER_ROUTING dialog
      m_parent_window = GetOCPNCanvasWindow();

      m_pWeather_Routing = NULL;

      m_leftclick_tool_id  = InsertPlugInTool
          (_T(""), _img_WeatherRouting, _img_WeatherRouting, wxITEM_CHECK,
           _("Weather_Routing"), _T(""), NULL,
           WEATHER_ROUTING_TOOL_POSITION, 0, this);

      wxMenu dummy_menu;
      m_position_menu_id = AddCanvasContextMenuItem
          (new wxMenuItem(&dummy_menu, -1, _("Weather Route Position")), this );
      SetCanvasContextMenuItemViz(m_position_menu_id, false);

      //    And load the configuration items
      LoadConfig();

      return (WANTS_OVERLAY_CALLBACK |
              WANTS_OPENGL_OVERLAY_CALLBACK |
              WANTS_TOOLBAR_CALLBACK    |
              WANTS_CONFIG              |
              WANTS_CURSOR_LATLON       |
              WANTS_NMEA_EVENTS         |
              WANTS_PLUGIN_MESSAGING
            );
}
Exemplo n.º 4
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