2009-11-12 15:43:38 +00:00
|
|
|
/********************/
|
|
|
|
/* basepcbframe.cpp */
|
|
|
|
/********************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2011-02-21 13:54:29 +00:00
|
|
|
#include "dialog_helpers.h"
|
|
|
|
#include "kicad_device_context.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "bitmaps.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
#include "collectors.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Configuration entry names. */
|
|
|
|
static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) );
|
|
|
|
static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) );
|
|
|
|
static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
static const wxString DisplayPadFillEntry( wxT( "DiPadFi" ) );
|
2009-09-29 04:44:35 +00:00
|
|
|
static const wxString DisplayViaFillEntry( wxT( "DiViaFi" ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
static const wxString DisplayPadNumberEntry( wxT( "DiPadNu" ) );
|
|
|
|
static const wxString DisplayModuleEdgeEntry( wxT( "DiModEd" ) );
|
|
|
|
static const wxString DisplayModuleTextEntry( wxT( "DiModTx" ) );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
/****************************/
|
|
|
|
/* class PCB_BASE_FRAME */
|
|
|
|
/****************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::ProcessItemSelection )
|
|
|
|
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, PCB_BASE_FRAME::OnTogglePolarCoords )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_PADS_SKETCH, PCB_BASE_FRAME::OnTogglePadDrawMode )
|
|
|
|
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, PCB_BASE_FRAME::OnUpdateCoordType )
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_PADS_SKETCH, PCB_BASE_FRAME::OnUpdatePadDrawMode )
|
|
|
|
EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
|
|
|
|
EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
|
|
|
|
|
|
|
|
EVT_UPDATE_UI_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, PCB_BASE_FRAME::OnUpdateSelectZoom )
|
2007-10-07 18:24:15 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-09-12 02:14:07 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father,
|
2011-03-14 15:17:18 +00:00
|
|
|
int idtype,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style) :
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME( father, idtype, title, pos, size, style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
m_InternalUnits = PCB_INTERNAL_UNIT; // Internal unit = 1/10000 inch
|
|
|
|
m_Pcb = NULL;
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2009-04-07 07:24:33 +00:00
|
|
|
m_DisplayPadFill = true; // How to draw pads
|
2009-09-29 04:44:35 +00:00
|
|
|
m_DisplayViaFill = true; // How to draw vias
|
2009-04-07 07:24:33 +00:00
|
|
|
m_DisplayPadNum = true; // show pads number
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2010-01-27 20:07:50 +00:00
|
|
|
m_DisplayModEdge = FILLED; // How to display module drawings (line/ filled / sketch)
|
|
|
|
m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch)
|
2009-04-07 07:24:33 +00:00
|
|
|
m_DisplayPcbTrackFill = true; /* FALSE = sketch , true = filled */
|
2008-12-08 15:27:13 +00:00
|
|
|
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
|
|
|
|
m_ModuleEditFrame = NULL; // Frame for footprint edition
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
m_UserGridSize = wxRealPoint( 100.0, 100.0 );
|
2010-07-12 14:07:09 +00:00
|
|
|
m_UserGridUnit = INCHES;
|
2009-04-05 20:49:15 +00:00
|
|
|
m_Collector = new GENERAL_COLLECTOR();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::~PCB_BASE_FRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
delete m_Collector;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( m_Pcb != g_ModuleEditor_Pcb )
|
2008-04-17 16:25:29 +00:00
|
|
|
delete m_Pcb;
|
2011-02-05 02:21:11 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
m_Pcb = aBoard;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-27 18:05:50 +00:00
|
|
|
/**
|
2007-12-06 07:35:26 +00:00
|
|
|
* Return the "best" zoom, i.e. the zoom which shows the entire board on screen
|
2007-10-27 18:05:50 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_BASE_FRAME::BestZoom( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
int dx, dy, ii, jj;
|
|
|
|
int bestzoom;
|
|
|
|
wxSize size;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
if( m_Pcb == NULL )
|
2009-01-29 14:26:20 +00:00
|
|
|
return 32 * GetScreen()->m_ZoomScalar;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-25 16:23:24 +00:00
|
|
|
m_Pcb->ComputeBoundingBox();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
dx = m_Pcb->m_BoundaryBox.GetWidth();
|
|
|
|
dy = m_Pcb->m_BoundaryBox.GetHeight();
|
2011-02-21 13:54:29 +00:00
|
|
|
size = DrawPanel->GetClientSize();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-14 20:20:59 +00:00
|
|
|
if( size.x )
|
2011-03-01 19:26:17 +00:00
|
|
|
ii = wxRound( ( (double) dx + ((double) size.x / 2.0) ) / (double) size.x );
|
2010-01-14 20:20:59 +00:00
|
|
|
else
|
|
|
|
ii = 31;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-01-14 20:20:59 +00:00
|
|
|
if ( size.y )
|
2011-03-01 19:26:17 +00:00
|
|
|
jj = wxRound( ( (double) dy + ((double) size.y / 2.0) ) / (double) size.y );
|
2010-01-14 20:20:59 +00:00
|
|
|
else
|
|
|
|
jj = 31;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
bestzoom = MAX( ii, jj ) + 1;
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
return bestzoom * GetScreen()->m_ZoomScalar;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos )
|
2007-12-04 07:04:53 +00:00
|
|
|
{
|
|
|
|
// factored out of pcbnew/find.cpp
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2007-12-04 07:04:53 +00:00
|
|
|
wxClientDC dc( DrawPanel );
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* There may be need to reframe the drawing. */
|
2007-12-04 07:04:53 +00:00
|
|
|
if( !DrawPanel->IsPointOnDisplay( aPos ) )
|
|
|
|
{
|
2011-02-17 18:34:27 +00:00
|
|
|
screen->SetCrossHairPosition( aPos );
|
2011-02-11 20:48:13 +00:00
|
|
|
RedrawScreen( aPos, true );
|
2007-12-04 07:04:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-06 07:35:26 +00:00
|
|
|
// Put cursor on item position
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->CrossHairOff( &dc );
|
|
|
|
screen->SetCrossHairPosition( aPos );
|
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
|
|
|
DrawPanel->CrossHairOn( &dc );
|
2007-12-04 07:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 16:16:48 +00:00
|
|
|
// Virtual function
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::ReCreateMenuBar( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
/* Virtual functions: Do nothing for PCB_BASE_FRAME window */
|
|
|
|
void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
// Note: virtual, overridden in PCB_EDIT_FRAME;
|
|
|
|
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, int layer )
|
2007-06-15 12:04:24 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Check if the specified layer matches the present layer
|
|
|
|
if( layer == preslayer )
|
2007-09-05 04:48:47 +00:00
|
|
|
return;
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Copper layers cannot be selected unconditionally; how many
|
|
|
|
// of those layers are currently enabled needs to be checked.
|
2009-12-07 03:46:13 +00:00
|
|
|
if( IsValidCopperLayerIndex( layer ) )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
|
|
|
// If only one copper layer is enabled, the only such layer
|
|
|
|
// that can be selected to is the "Copper" layer (so the
|
|
|
|
// selection of any other copper layer is disregarded).
|
2010-01-31 20:01:46 +00:00
|
|
|
if( m_Pcb->GetCopperLayerCount() < 2 )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer != LAYER_N_BACK )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If more than one copper layer is enabled, the "Copper"
|
|
|
|
// and "Component" layers can be selected, but the total
|
|
|
|
// number of copper layers determines which internal
|
|
|
|
// layers are also capable of being selected.
|
|
|
|
else
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT )
|
2010-01-31 20:01:46 +00:00
|
|
|
&& ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is yet more checking required? E.g. when the layer to be selected
|
|
|
|
// is a non-copper layer, or when switching between a copper layer
|
|
|
|
// and a non-copper layer, or vice-versa?
|
|
|
|
// ...
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
GetScreen()->m_Active_Layer = layer;
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
2011-02-21 21:07:00 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-06-15 12:04:24 +00:00
|
|
|
}
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
SetStatusText( wxEmptyString );
|
|
|
|
DisplayOpt.DisplayPolarCood = !DisplayOpt.DisplayPolarCood;
|
|
|
|
UpdateStatusBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
m_DisplayPadFill = DisplayOpt.DisplayPadFill = !m_DisplayPadFill;
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
aEvent.Check( DisplayOpt.DisplayPolarCood );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
|
|
|
DisplayOpt.DisplayPolarCood ?
|
|
|
|
_( "Display rectangular coordinates" ) :
|
|
|
|
_( "Display polar coordinates" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
aEvent.Check( !m_DisplayPadFill );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
|
|
|
m_DisplayPadFill ?
|
|
|
|
_( "Show pads in outline mode" ) :
|
|
|
|
_( "Show pads in fill mode" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
// No need to update the grid select box if it doesn't exist or the grid setting change
|
|
|
|
// was made using the select box.
|
|
|
|
if( m_SelGridBox == NULL || m_AuxiliaryToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int select = wxNOT_FOUND;
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
if( GetScreen()->GetGridId() == GetScreen()->GetGrid( i ).m_Id )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
select = (int) i;
|
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
if( select != m_SelGridBox->GetSelection() )
|
|
|
|
m_SelGridBox->SetSelection( select );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
if( m_SelZoomBox == NULL || m_AuxiliaryToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int current = 0;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < GetScreen()->m_ZoomList.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
|
|
|
|
{
|
|
|
|
current = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( current != m_SelZoomBox->GetSelection() )
|
|
|
|
m_SelZoomBox->SetSelection( current );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
int id = aEvent.GetId();
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
// index into the collector list:
|
2007-10-07 18:24:15 +00:00
|
|
|
int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( id >= ID_POPUP_PCB_ITEM_SELECTION_START && id <= ID_POPUP_PCB_ITEM_SELECTION_END )
|
2007-10-07 18:24:15 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (*m_Collector)[itemNdx];
|
|
|
|
DrawPanel->m_AbortRequest = false;
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2008-02-05 02:13:16 +00:00
|
|
|
#if 0 && defined (DEBUG)
|
2007-10-07 18:24:15 +00:00
|
|
|
item->Show( 0, std::cout );
|
2007-09-12 02:14:07 +00:00
|
|
|
#endif
|
2007-10-07 18:24:15 +00:00
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
}
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetCurItem( aItem );
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
if( aItem )
|
2007-10-10 12:43:30 +00:00
|
|
|
{
|
2009-10-14 18:14:58 +00:00
|
|
|
if( aDisplayInfo )
|
|
|
|
aItem->DisplayInfo( this );
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2007-10-10 12:43:30 +00:00
|
|
|
aItem->Show( 0, std::cout );
|
|
|
|
#endif
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2007-10-10 12:43:30 +00:00
|
|
|
}
|
2007-09-12 02:14:07 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-10 12:43:30 +00:00
|
|
|
// we can use either of these two:
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
//MsgPanel->EraseMsgBox();
|
2009-04-17 08:51:02 +00:00
|
|
|
m_Pcb->DisplayInfo( this ); // show the BOARD stuff
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2008-02-05 02:13:16 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2007-10-10 12:43:30 +00:00
|
|
|
std::cout << "SetCurItem(NULL)\n";
|
|
|
|
#endif
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
BOARD_ITEM* PCB_BASE_FRAME::GetCurItem()
|
2007-10-07 18:24:15 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
return GetScreen()->GetCurItem();
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
|
2007-09-05 04:48:47 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE guide( m_Pcb->GetVisibleLayers(),
|
2009-11-12 15:43:38 +00:00
|
|
|
( (PCB_SCREEN*)GetScreen())->m_Active_Layer );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
// account for the globals
|
2010-01-31 20:01:46 +00:00
|
|
|
guide.SetIgnoreMTextsMarkedNoShow( ! m_Pcb->IsElementVisible( MOD_TEXT_INVISIBLE ));
|
|
|
|
guide.SetIgnoreMTextsOnCopper( ! m_Pcb->IsElementVisible( MOD_TEXT_BK_VISIBLE ));
|
|
|
|
guide.SetIgnoreMTextsOnCmp( ! m_Pcb->IsElementVisible( MOD_TEXT_FR_VISIBLE ));
|
|
|
|
guide.SetIgnoreModulesOnCu( ! m_Pcb->IsElementVisible( MOD_BK_VISIBLE ) );
|
|
|
|
guide.SetIgnoreModulesOnCmp( ! m_Pcb->IsElementVisible( MOD_FR_VISIBLE ) );
|
2010-02-05 10:56:23 +00:00
|
|
|
guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( PAD_BK_VISIBLE ) );
|
|
|
|
guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( PAD_FR_VISIBLE ) );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
return guide;
|
|
|
|
}
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
|
2008-12-19 13:51:48 +00:00
|
|
|
{
|
|
|
|
bool redraw = false;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2010-07-27 16:49:38 +00:00
|
|
|
if( aId < 0 )
|
2008-12-19 13:51:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// handle color changes for transitions in and out of ID_TRACK_BUTT
|
2011-02-24 20:22:12 +00:00
|
|
|
if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
|
|
|
|
|| ( GetToolId() != ID_TRACK_BUTT && aId== ID_TRACK_BUTT ) )
|
2008-12-19 13:51:48 +00:00
|
|
|
{
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// must do this after the tool has been set, otherwise pad::Draw() does
|
|
|
|
// not show proper color when DisplayOpt.ContrastModeDisplay is true.
|
2008-12-20 13:12:57 +00:00
|
|
|
if( redraw && DrawPanel)
|
|
|
|
DrawPanel->Refresh();
|
2008-12-19 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
/*
|
|
|
|
* Update the status bar information.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::UpdateStatusBar()
|
2008-12-19 13:51:48 +00:00
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::UpdateStatusBar();
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2009-04-09 18:16:16 +00:00
|
|
|
if( DisplayOpt.DisplayPolarCood ) // display polar coordinates
|
|
|
|
{
|
2011-02-05 02:21:11 +00:00
|
|
|
PCB_SCREEN* screen = GetScreen();
|
|
|
|
|
2009-04-09 18:16:16 +00:00
|
|
|
if( !screen )
|
|
|
|
return;
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
wxString Line;
|
|
|
|
double theta, ro;
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
int dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
|
|
|
|
int dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2009-04-09 18:16:16 +00:00
|
|
|
if( dx==0 && dy==0 )
|
2008-12-19 13:51:48 +00:00
|
|
|
theta = 0.0;
|
|
|
|
else
|
|
|
|
theta = atan2( (double) -dy, (double) dx );
|
|
|
|
|
|
|
|
theta = theta * 180.0 / M_PI;
|
|
|
|
|
|
|
|
ro = sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
|
2010-07-12 14:07:09 +00:00
|
|
|
wxString formatter;
|
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case INCHES:
|
|
|
|
formatter = wxT( "Ro %.4f Th %.1f" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MILLIMETRES:
|
|
|
|
formatter = wxT( "Ro %.3f Th %.1f" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
|
|
|
formatter = wxT( "Ro %f Th %f" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
Line.Printf( formatter, To_User_Unit( g_UserUnit, ro, m_InternalUnits ), theta );
|
2009-04-09 18:16:16 +00:00
|
|
|
|
|
|
|
// overwrite the absolute cartesian coordinates
|
|
|
|
SetStatusText( Line, 2 );
|
2008-12-19 13:51:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::unitsChangeRefresh()
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
|
|
|
|
|
|
|
|
updateGridSelectBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* Load PCB base frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get loaded.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::LoadSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::LoadSettings();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// Ensure grid id is an existent grid id:
|
2009-11-07 14:36:54 +00:00
|
|
|
if( (m_LastGridSizeId <= 0) ||
|
|
|
|
(m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
|
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 );
|
|
|
|
cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
|
2011-02-21 13:54:29 +00:00
|
|
|
cfg->Read( m_FrameName + UserGridUnitsEntry, (long*)&m_UserGridUnit, ( long )INCHES );
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
|
2009-11-07 14:36:54 +00:00
|
|
|
cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true );
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true );
|
2011-02-21 13:54:29 +00:00
|
|
|
cfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge, ( long )FILLED );
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
if( m_DisplayModEdge < FILAIRE || m_DisplayModEdge > SKETCH )
|
|
|
|
m_DisplayModEdge = FILLED;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
cfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText, ( long )FILLED );
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
if( m_DisplayModText < FILAIRE || m_DisplayModText > SKETCH )
|
|
|
|
m_DisplayModText = FILLED;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save PCB base frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get saved.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::SaveSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SaveSettings();
|
2009-04-05 20:49:15 +00:00
|
|
|
cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x );
|
|
|
|
cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y );
|
2010-07-12 14:07:09 +00:00
|
|
|
cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnit );
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayPadFill );
|
2009-11-07 14:36:54 +00:00
|
|
|
cfg->Write( m_FrameName + DisplayViaFillEntry, m_DisplayViaFill );
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayPadNum );
|
|
|
|
cfg->Write( m_FrameName + DisplayModuleEdgeEntry, ( long )m_DisplayModEdge );
|
|
|
|
cfg->Write( m_FrameName + DisplayModuleTextEntry, ( long )m_DisplayModText );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2010-02-19 13:23:58 +00:00
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function OnModify
|
2010-02-19 13:23:58 +00:00
|
|
|
* Must be called after a schematic change
|
|
|
|
* in order to set the "modify" flag of the current screen
|
|
|
|
* and update the date in frame reference
|
2010-05-01 12:46:33 +00:00
|
|
|
* do not forget to call this basic OnModify function to update info
|
|
|
|
* in derived OnModify functions
|
2010-02-19 13:23:58 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::OnModify( )
|
2010-02-19 13:23:58 +00:00
|
|
|
{
|
|
|
|
GetScreen()->SetModify( );
|
|
|
|
|
|
|
|
wxString date = GenDate();
|
|
|
|
GetScreen()->m_Date = date;
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::updateGridSelectBox()
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
UpdateStatusBar();
|
|
|
|
DisplayUnitsMsg();
|
|
|
|
|
|
|
|
if( m_SelGridBox == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Update grid values with the current units setting.
|
|
|
|
m_SelGridBox->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, m_InternalUnits );
|
|
|
|
|
|
|
|
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_SelGridBox->Append( msg, (void*) &grid.m_Id );
|
|
|
|
|
|
|
|
if( ( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) == GetScreen()->GetGrid( i ).m_Id )
|
|
|
|
m_SelGridBox->SetSelection( i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::updateZoomSelectBox()
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
if( m_SelZoomBox == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
m_SelZoomBox->Clear();
|
|
|
|
m_SelZoomBox->Append( _( "Auto" ) );
|
|
|
|
m_SelZoomBox->SetSelection( 0 );
|
|
|
|
|
|
|
|
for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
msg = _( "Zoom " );
|
|
|
|
|
|
|
|
if ( ( GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar ) == 0 )
|
|
|
|
msg << GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString value;
|
|
|
|
value.Printf( wxT( "%.1f" ),
|
|
|
|
(float)GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar );
|
|
|
|
msg += value;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_SelZoomBox->Append( msg );
|
|
|
|
|
|
|
|
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
|
|
|
|
m_SelZoomBox->SetSelection( i + 1 );
|
|
|
|
}
|
|
|
|
}
|