Example #1
0
void PCB_BASE_FRAME::updateGridSelectBox()
{
    UpdateStatusBar();
    DisplayUnitsMsg();

    if( m_gridSelectBox == NULL )
        return;

    // Update grid values with the current units setting.
    m_gridSelectBox->Clear();

    wxString msg;
    wxString format = _( "Grid");

    switch( g_UserUnit )
    {
    case INCHES:
        format += wxT( " %.1f" );
        break;

    case MILLIMETRES:
        format += wxT( " %.3f" );
        break;

    case UNSCALED_UNITS:
        format += wxT( " %f" );
        break;
    }

    for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
    {
        GRID_TYPE& grid = GetScreen()->GetGrid( i );
        double value = To_User_Unit( g_UserUnit, grid.m_Size.x );

        if( grid.m_Id != ID_POPUP_GRID_USER )
        {
            switch( g_UserUnit )
            {
            case INCHES:
                msg.Printf( format.GetData(), value * 1000 );
                break;

            case MILLIMETRES:
            case UNSCALED_UNITS:
                msg.Printf( format.GetData(), value );
                break;
            }
        }
        else
            msg = _( "User Grid" );

        m_gridSelectBox->Append( msg, (void*) &grid.m_Id );

        if( ( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) == GetScreen()->GetGrid( i ).m_Id )
            m_gridSelectBox->SetSelection( i );
    }
}
void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
{
    bool enable;

    enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (g_UserUnit == MILLIMETRES))
            || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (g_UserUnit == INCHES)) );

    aEvent.Check( enable );
    DisplayUnitsMsg();
}
Example #3
0
void EDA_DRAW_FRAME::UpdateStatusBar()
{
    SetStatusText( GetZoomLevelIndicator(), 1 );

    // Absolute and relative cursor positions are handled by overloading this function and
    // handling the internal to user units conversion at the appropriate level.

    // refresh units display
    DisplayUnitsMsg();
}
void EDA_DRAW_FRAME::UpdateStatusBar()
{
    wxString        Line;
    BASE_SCREEN*    screen = GetScreen();

    if( !screen )
        return;

    // Display Zoom level: zoom = zoom_coeff/ZoomScalar
    Line.Printf( wxT( "Z %g" ), screen->GetZoom() );

    SetStatusText( Line, 1 );

    // Absolute and relative cursor positions are handled by overloading this function and
    // handling the internal to user units conversion at the appropriate level.

    // refresh units display
    DisplayUnitsMsg();
}
void PCB_BASE_FRAME::updateGridSelectBox()
{
    UpdateStatusBar();
    DisplayUnitsMsg();

    if( m_gridSelectBox == NULL )
        return;

    // Update grid values with the current units setting.
    m_gridSelectBox->Clear();
    wxArrayString gridsList;
    int icurr = GetScreen()->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES );

    for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
    {
        GRID_TYPE& grid = GetScreen()->GetGrid( i );
        m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
    }

    m_gridSelectBox->SetSelection( icurr );
}
Example #6
0
void SCH_BASE_FRAME::UpdateStatusBar()
{
    wxString        line;
    int             dx, dy;
    BASE_SCREEN*    screen = GetScreen();

    if( !screen )
        return;

    EDA_DRAW_FRAME::UpdateStatusBar();

    // Display absolute coordinates:
    double dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
    double dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );

    if ( g_UserUnit == MILLIMETRES )
    {
        dXpos = RoundTo0( dXpos, 100.0 );
        dYpos = RoundTo0( dYpos, 100.0 );
    }

    wxString absformatter;
    wxString locformatter;

    switch( g_UserUnit )
    {
    case INCHES:
        absformatter = wxT( "X %.3f  Y %.3f" );
        locformatter = wxT( "dx %.3f  dy %.3f  d %.3f" );
        break;

    case MILLIMETRES:
        absformatter = wxT( "X %.2f  Y %.2f" );
        locformatter = wxT( "dx %.2f  dy %.2f  d %.2f" );
        break;

    case UNSCALED_UNITS:
        absformatter = wxT( "X %f  Y %f" );
        locformatter = wxT( "dx %f  dy %f  d %f" );
        break;
    }

    line.Printf( absformatter, dXpos, dYpos );
    SetStatusText( line, 2 );

    // Display relative coordinates:
    dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
    dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;

    dXpos = To_User_Unit( g_UserUnit, dx );
    dYpos = To_User_Unit( g_UserUnit, dy );

    if( g_UserUnit == MILLIMETRES )
    {
        dXpos = RoundTo0( dXpos, 100.0 );
        dYpos = RoundTo0( dYpos, 100.0 );
    }

    // We already decided the formatter above
    line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
    SetStatusText( line, 3 );

    // refresh units display
    DisplayUnitsMsg();
}
void WinEDA_ModuleEditFrame::SetToolbars(void)
/*********************************************/
{
bool active, islib = TRUE;

	if( m_HToolBar == NULL ) return;

	if ( m_CurrentLib == wxEmptyString ) islib = FALSE;

	m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,islib);
	m_HToolBar->EnableTool(ID_LIBEDIT_DELETE_PART,islib);

	if ( m_Pcb->m_Modules == NULL ) active = FALSE;
	else active = TRUE;

	m_HToolBar->EnableTool(ID_LIBEDIT_EXPORT_PART,active);
	m_HToolBar->EnableTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,active);
	m_HToolBar->EnableTool(ID_MODEDIT_SAVE_LIBMODULE,active && islib);
	m_HToolBar->EnableTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD,active);
	if ( GetScreen() )
	{
		m_HToolBar->EnableTool(ID_MODEDIT_UNDO,GetScreen()->m_UndoList && active);
		m_HToolBar->EnableTool(ID_MODEDIT_REDO,GetScreen()->m_RedoList && active);
	}

	if ( m_Parent->m_PcbFrame->m_Pcb->m_Modules )
		{
		m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,TRUE);
		}
	else
		{
		m_HToolBar->EnableTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD,FALSE);
		}


	if ( m_VToolBar )
		{
		m_VToolBar->EnableTool(ID_MODEDIT_ADD_PAD,active);
		m_VToolBar->EnableTool(ID_LINE_COMMENT_BUTT,active);
		m_VToolBar->EnableTool(ID_PCB_CIRCLE_BUTT,active);
		m_VToolBar->EnableTool(ID_PCB_ARC_BUTT,active);
		m_VToolBar->EnableTool(ID_TEXT_COMMENT_BUTT,active);
		m_VToolBar->EnableTool(ID_MODEDIT_PLACE_ANCHOR,active);
		m_VToolBar->EnableTool(ID_PCB_DELETE_ITEM_BUTT,active);
		}

	if ( m_OptionsToolBar )
		{
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM,
			UnitMetric == MILLIMETRE ? TRUE : FALSE);
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH,
			UnitMetric == INCHES ? TRUE : FALSE);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD,
			DisplayOpt.DisplayPolarCood);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID,
			m_Draw_Grid);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,
			g_CursorShape);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH,
			! m_DisplayPadFill);
		}

	if ( m_AuxiliaryToolBar )
		{
		int ii, jj;
		if ( m_SelZoomBox )
			{
			int kk = m_SelZoomBox->GetSelection();
			for ( jj = 0, ii = 1; ii <= 1048; ii <<= 1, jj++ )
				{
				if ( GetScreen() && (GetScreen()->GetZoom() == ii) )
					{
					if ( kk != jj )m_SelZoomBox->SetSelection(jj);
					kk = jj;
					break;
					}
				}
			if ( kk != jj )m_SelZoomBox->SetSelection(-1);
			}

		if ( m_SelGridBox && GetScreen() )
			{
			int kk = m_SelGridBox->GetSelection();
			for ( ii = 0; g_GridList[ii].x > 0; ii++ )
				{
				if ( !GetScreen()->m_UserGridIsON &&
					(GetScreen()->GetGrid().x == g_GridList[ii].x) &&
					(GetScreen()->GetGrid().y == g_GridList[ii].y))
					{
					if ( kk != ii )m_SelGridBox->SetSelection(ii);
					kk = ii;
					break;
					}
				}
			if ( kk != ii )
				m_SelGridBox->SetSelection(ii);	/* User Grid */
			}
		}

	DisplayUnitsMsg();
}
Example #8
0
void WinEDA_PcbFrame::SetToolbars(void)
/***************************************/
/*
Active ou desactive les tools des toolbars, en fonction des commandes
en cours
*/
{
int ii, jj;

	if ( m_ID_current_state == ID_TRACK_BUTT )
	{
		if ( Drc_On ) DrawPanel->SetCursor(wxCursor(wxCURSOR_PENCIL));
		else DrawPanel->SetCursor(wxCursor(wxCURSOR_QUESTION_ARROW));
	}


	if( m_HToolBar == NULL ) return;

	m_HToolBar->EnableTool(ID_SAVE_BOARD,m_CurrentScreen->IsModify());

	if ( m_CurrentScreen->BlockLocate.m_Command == BLOCK_MOVE )
		{
		m_HToolBar->EnableTool(wxID_CUT,TRUE);
		m_HToolBar->EnableTool(wxID_COPY,TRUE);
		}
	else
		{
		m_HToolBar->EnableTool(wxID_CUT,FALSE);
		m_HToolBar->EnableTool(wxID_COPY,FALSE);
		}

	if ( g_UnDeleteStackPtr )
		{
		m_HToolBar->EnableTool(wxID_PASTE,TRUE);
		}
	else
		{
		m_HToolBar->EnableTool(wxID_PASTE,FALSE);
		}

	if ( g_UnDeleteStackPtr )
		{
		m_HToolBar->EnableTool(ID_UNDO_BUTT,TRUE);
		}
	else m_HToolBar->EnableTool(ID_UNDO_BUTT,FALSE);

	if ( m_OptionsToolBar )
	{
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_DRC_OFF,
			! Drc_On);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_DRC_OFF,
			Drc_On ? _("DCR Off (Disable !!!), Currently: DRC is active") : _("DRC On (Currently: DRC is DISABLE !!!)"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM,
			UnitMetric == MILLIMETRE ? TRUE : FALSE);
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH,
			UnitMetric == INCHES ? TRUE : FALSE);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD,
			DisplayOpt.DisplayPolarCood);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_POLAR_COORD,
			DisplayOpt.DisplayPolarCood ? _("Polar Coords not show") : _("Display Polar Coords"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID,
			m_Draw_Grid);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID,
			m_Draw_Grid ? _("Grid not show") : _("Show Grid"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,
			g_CursorShape);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_RATSNEST,
			g_Show_Ratsnest);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_RATSNEST,
			g_Show_Ratsnest ? _("General ratsnest not show") : _("Show General ratsnest"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
			g_Show_Module_Ratsnest);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
			g_Show_Module_Ratsnest ? _("Module ratsnest not show") : _("Show Module ratsnest"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_AUTO_DEL_TRACK,
			g_AutoDeleteOldTrack);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_AUTO_DEL_TRACK,
			g_AutoDeleteOldTrack ? _("Disable Auto Delete old Track") : _("Enable Auto Delete old Track"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_ZONES,
			DisplayOpt.DisplayZones);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_ZONES,
			DisplayOpt.DisplayZones ? _("Do not Show Zones") : _("Show Zones"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH,
			! m_DisplayPadFill);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_PADS_SKETCH,
			m_DisplayPadFill ? _("Show Pads Sketch mode") : _("Show pads filled mode"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
			 ! m_DisplayPcbTrackFill);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
			m_DisplayPcbTrackFill ? _("Show Tracks Sketch mode") : _("Show Tracks filled mode"));

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE,
			DisplayOpt.ContrastModeDisplay);
		m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE,
			DisplayOpt.ContrastModeDisplay ? _("Normal Contrast Mode Display") : _("Hight Contrast Mode Display"));

	}

	if ( m_AuxiliaryToolBar )
		{
		wxString msg;
		if ( m_SelTrackWidthBox && m_SelTrackWidthBox_Changed)
			{
			m_SelTrackWidthBox_Changed = FALSE;
			m_SelTrackWidthBox->Clear();
			wxString format = _("Track");
			if ( UnitMetric == INCHES ) format += wxT(" %.1f");
			else format += wxT(" %.3f");
			for ( ii = 0; ii < HIST0RY_NUMBER; ii++)
				{
				if ( g_DesignSettings.m_TrackWidhtHistory[ii] == 0 ) break;	// Fin de liste
				double value = To_User_Unit(UnitMetric,
					g_DesignSettings.m_TrackWidhtHistory[ii], PCB_INTERNAL_UNIT);

				if ( UnitMetric == INCHES )
					msg.Printf(format.GetData(), value * 1000);
				else
					msg.Printf(format.GetData(), value);
				m_SelTrackWidthBox->Append(msg);
				if ( g_DesignSettings.m_TrackWidhtHistory[ii] == g_DesignSettings.m_CurrentTrackWidth )
					m_SelTrackWidthBox->SetSelection(ii);
				}
			}

		if ( m_SelViaSizeBox && m_SelViaSizeBox_Changed )
			{
			m_SelViaSizeBox_Changed = FALSE;
			m_SelViaSizeBox->Clear();
			wxString format = _("Via");
			if ( UnitMetric == INCHES ) format += wxT(" %.1f");
			else format += wxT(" %.3f");
			for ( ii = 0; ii < HIST0RY_NUMBER; ii++)
				{
				if ( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break;	// Fin de liste
				double value = To_User_Unit(UnitMetric,
					g_DesignSettings.m_ViaSizeHistory[ii], PCB_INTERNAL_UNIT);

				if ( UnitMetric == INCHES )
					msg.Printf(format.GetData(), value * 1000);
				else
					msg.Printf(format.GetData(), value);
				m_SelViaSizeBox->Append(msg);
				if ( g_DesignSettings.m_ViaSizeHistory[ii] == g_DesignSettings.m_CurrentViaSize )
					m_SelViaSizeBox->SetSelection(ii);
				}
			}

		if ( m_SelZoomBox )
			{
			int kk = m_SelZoomBox->GetSelection();
			for ( jj = 0, ii = 1; ii <= 2048; ii <<= 1, jj++ )
				{
				if ( m_CurrentScreen && (m_CurrentScreen->GetZoom() == ii) )
					{
					if ( kk != jj )m_SelZoomBox->SetSelection(jj);
					kk = jj;
					break;
					}
				}
			if ( kk != jj )m_SelZoomBox->SetSelection(-1);
			}

		if ( m_SelGridBox && m_CurrentScreen)
			{
			int kk = m_SelGridBox->GetSelection();
			for ( ii = 0; g_GridList[ii].x > 0; ii++ )
				{
				if ( !m_CurrentScreen->m_UserGridIsON &&
					(m_CurrentScreen->GetGrid().x == g_GridList[ii].x) &&
					(m_CurrentScreen->GetGrid().y == g_GridList[ii].y) )
					{
					if (kk != ii) m_SelGridBox->SetSelection(ii);
					kk = ii;
					break;
					}
				}
			if ( kk != ii )
				m_SelGridBox->SetSelection(ii);	/* User Grid */
			}
		}

	ReCreateLayerBox(NULL);

	DisplayUnitsMsg();
}
void WinEDA_GerberFrame::SetToolbars(void)
/*******************************************/
/* Active ou desactive les tools du toolbar horizontal, en fonction des commandes
en cours
*/
{
int layer = GetScreen()->m_Active_Layer;
GERBER_Descr * Gerber_layer_descr	= g_GERBER_Descr_List[layer];

	if( m_HToolBar == NULL ) return;

	if ( GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
	{
		m_HToolBar->EnableTool(wxID_CUT,TRUE);
		m_HToolBar->EnableTool(wxID_COPY,TRUE);
	}
	else
	{
		m_HToolBar->EnableTool(wxID_CUT,FALSE);
		m_HToolBar->EnableTool(wxID_COPY,FALSE);
	}

	if ( g_UnDeleteStackPtr )
	{
		m_HToolBar->EnableTool(wxID_PASTE,TRUE);
		m_HToolBar->EnableTool(ID_UNDO_BUTT,TRUE);
	}
	else
	{
		m_HToolBar->EnableTool(wxID_PASTE,FALSE);
		m_HToolBar->EnableTool(ID_UNDO_BUTT,FALSE);
	}


	if ( m_SelLayerBox->GetSelection() != GetScreen()->m_Active_Layer )
	{
		m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer );
	}

	if ( Gerber_layer_descr )
	{
		int sel_index;
		m_SelLayerTool->Enable(TRUE);
		if ( Gerber_layer_descr->m_Selected_Tool < FIRST_DCODE ) // No tool selected
			sel_index = 0;
		else
			sel_index = Gerber_layer_descr->m_Selected_Tool - FIRST_DCODE + 1;

		if ( sel_index != m_SelLayerTool->GetSelection() )
		{
			m_SelLayerTool->SetSelection(sel_index);
		}
	}
	else
	{
		m_SelLayerTool->SetSelection(0);
		m_SelLayerTool->Enable(FALSE);
	}

	if ( m_OptionsToolBar )
	{
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM,
			g_UnitMetric == MILLIMETRE ? TRUE : FALSE);
		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH,
			g_UnitMetric == INCHES ? TRUE : FALSE);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_POLAR_COORD,
			DisplayOpt.DisplayPolarCood);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID,
			m_Draw_Grid);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,
			g_CursorShape);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH,
			! m_DisplayPadFill);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
			 ! m_DisplayPcbTrackFill);

		m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_DCODES,
			 DisplayOpt.DisplayPadNum);
	}

	DisplayUnitsMsg();
}