2008-01-12 20:31:56 +00:00
|
|
|
/**********************************************/
|
2009-08-08 10:08:37 +00:00
|
|
|
/* vi_edit.cpp: some editing function for vias */
|
2008-01-12 20:31:56 +00:00
|
|
|
/**********************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
2009-08-08 10:08:37 +00:00
|
|
|
void WinEDA_PcbFrame::Via_Edit_Control( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************************************/
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2008-01-12 20:31:56 +00:00
|
|
|
* Execute edit commands relative to vias
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-01-12 20:31:56 +00:00
|
|
|
TRACK* via_struct;
|
2009-08-08 10:08:37 +00:00
|
|
|
SEGVIA* via = (SEGVIA*) GetCurItem();
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2009-08-08 10:08:37 +00:00
|
|
|
wxASSERT( via->Type() == TYPE_VIA);
|
|
|
|
|
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
|
|
|
ITEM_PICKER picker( NULL, UR_CHANGED );
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2009-10-30 17:58:15 +00:00
|
|
|
case ID_POPUP_PCB_VIA_HOLE_TO_VALUE: // Set the via drill to custom
|
|
|
|
if( (GetBoard()->GetCurrentViaDrill() > 0) &&
|
|
|
|
(GetBoard()->GetCurrentViaDrill() < via->m_Width) )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2009-08-08 10:08:37 +00:00
|
|
|
SaveCopyInUndoList(via, UR_CHANGED);
|
|
|
|
via->Draw( DrawPanel, &dc, GR_XOR );
|
2009-10-30 17:58:15 +00:00
|
|
|
via->SetDrillValue( GetBoard()->GetCurrentViaDrill() );
|
2009-08-08 10:08:37 +00:00
|
|
|
via->Draw( DrawPanel, &dc, GR_OR );
|
2008-01-12 20:31:56 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( this, _( "Incorrect value for Via drill. No via drill change" ) );
|
|
|
|
break;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
case ID_POPUP_PCB_VIA_HOLE_EXPORT_TO_OTHERS: // Export the current drill value to via which have the same size
|
2009-01-05 05:21:35 +00:00
|
|
|
via_struct = GetBoard()->m_Track;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; via_struct != NULL; via_struct = via_struct->Next() )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( via_struct->Type() == TYPE_VIA ) /* mise a jour du diametre de la via */
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
|
|
|
if( via_struct->m_Width != via->m_Width )
|
|
|
|
continue;
|
2009-08-08 10:08:37 +00:00
|
|
|
picker.m_PickedItem = via_struct;
|
|
|
|
picker.m_Link = via_struct->Copy();
|
|
|
|
itemsListPicker.PushItem(picker);
|
|
|
|
via_struct->Draw( DrawPanel, &dc, GR_XOR );
|
2008-01-12 20:31:56 +00:00
|
|
|
via_struct->SetDrillValue( via->GetDrillValue() );
|
2009-08-08 10:08:37 +00:00
|
|
|
via_struct->Draw( DrawPanel, &dc, GR_OR );
|
2008-01-12 20:31:56 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-08 10:08:37 +00:00
|
|
|
SaveCopyInUndoList(itemsListPicker, UR_CHANGED);
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_VIA_HOLE_TO_DEFAULT:
|
2009-08-08 10:08:37 +00:00
|
|
|
SaveCopyInUndoList(via, UR_CHANGED);
|
|
|
|
via->Draw( DrawPanel, &dc, GR_XOR );
|
2008-01-12 20:31:56 +00:00
|
|
|
via->SetDrillDefault();
|
2009-08-08 10:08:37 +00:00
|
|
|
via->Draw( DrawPanel, &dc, GR_OR );
|
2008-01-12 20:31:56 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
break;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
case ID_POPUP_PCB_VIA_HOLE_RESET_TO_DEFAULT: // Reset all via drill to default value
|
2009-01-05 05:21:35 +00:00
|
|
|
via_struct = GetBoard()->m_Track;
|
2008-08-29 12:14:45 +00:00
|
|
|
for( ; via_struct != NULL; via_struct = via_struct->Next() )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2009-10-30 17:58:15 +00:00
|
|
|
if( via_struct->Type() == TYPE_VIA ) /* Update via drill */
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2008-08-29 12:14:45 +00:00
|
|
|
if( ! via_struct->IsDrillDefault() )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2009-08-08 10:08:37 +00:00
|
|
|
picker.m_PickedItem = via_struct;
|
|
|
|
picker.m_Link = via_struct->Copy();
|
|
|
|
itemsListPicker.PushItem(picker);
|
|
|
|
via_struct->Draw( DrawPanel, &dc, GR_XOR );
|
2008-01-12 20:31:56 +00:00
|
|
|
via_struct->SetDrillDefault();
|
2009-08-08 10:08:37 +00:00
|
|
|
via_struct->Draw( DrawPanel, &dc, GR_OR );
|
2008-01-12 20:31:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-08 10:08:37 +00:00
|
|
|
SaveCopyInUndoList(itemsListPicker, UR_CHANGED);
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
break;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
case ID_POPUP_PCB_VIA_HOLE_ENTER_VALUE: // Enter a new alternate value for drill via
|
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Via_Edit_Control(): obsolete command" ) );
|
|
|
|
break;
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
default:
|
2009-10-03 17:18:08 +00:00
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Via_Edit_Control() error: unknown command" ) );
|
2008-01-12 20:31:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-08 10:08:37 +00:00
|
|
|
DrawPanel->CursorOn( &dc );
|
2008-01-12 20:31:56 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|