2009-10-10 17:27:53 +00:00
|
|
|
/***************************************************************
|
|
|
|
* Tracks and Vias size edition:
|
|
|
|
* Functions to modify sizes of segment, track, net , all vias and/or all tracks
|
|
|
|
***************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +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"
|
2010-09-18 08:29:40 +00:00
|
|
|
#include "drc_stuff.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SetTrackSegmentWidth
|
2009-10-30 17:58:15 +00:00
|
|
|
* Modify one track segment width or one via diameter and drill (using DRC control).
|
2007-12-01 03:42:52 +00:00
|
|
|
* Basic routine used by other routines when editing tracks or vias
|
2009-08-08 06:07:08 +00:00
|
|
|
* @param aTrackItem = the track segment or via to modify
|
|
|
|
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
|
2009-10-10 17:27:53 +00:00
|
|
|
* @param aUseNetclassValue = true to use NetClass value, false to use g_DesignSettings value
|
2009-08-08 06:07:08 +00:00
|
|
|
* @return true if done, false if no not change (because DRC error)
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2009-08-08 06:07:08 +00:00
|
|
|
bool WinEDA_PcbFrame::SetTrackSegmentWidth( TRACK* aTrackItem,
|
2009-10-10 17:27:53 +00:00
|
|
|
PICKED_ITEMS_LIST* aItemsListPicker,
|
|
|
|
bool aUseNetclassValue )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-05 16:24:08 +00:00
|
|
|
int initial_width, new_width;
|
|
|
|
int initial_drill = -1,new_drill = -1;
|
2009-10-10 17:27:53 +00:00
|
|
|
bool change_ok = false;
|
|
|
|
NETINFO_ITEM* net = NULL;
|
|
|
|
|
|
|
|
if( aUseNetclassValue )
|
|
|
|
net = GetBoard()->FindNet( aTrackItem->GetNet() );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
initial_width = aTrackItem->m_Width;
|
2010-12-05 16:24:08 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
if( net )
|
|
|
|
new_width = net->GetTrackWidth();
|
|
|
|
else
|
2009-10-30 17:58:15 +00:00
|
|
|
new_width = GetBoard()->GetCurrentTrackWidth();
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aTrackItem->Type() == TYPE_VIA )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2010-12-05 16:24:08 +00:00
|
|
|
if( !aTrackItem->IsDrillDefault() )
|
|
|
|
initial_drill = aTrackItem->GetDrillValue();
|
2009-10-10 17:27:53 +00:00
|
|
|
if( net )
|
|
|
|
new_width = net->GetViaSize();
|
|
|
|
else
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
|
|
|
new_width = GetBoard()->GetCurrentViaSize();
|
|
|
|
new_drill = GetBoard()->GetCurrentViaDrill();
|
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aTrackItem->m_Shape == VIA_MICROVIA )
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
|
|
|
if( net )
|
|
|
|
new_width = net->GetViaSize();
|
|
|
|
else
|
2009-10-30 17:58:15 +00:00
|
|
|
new_width = net->GetMicroViaSize();
|
2009-10-10 17:27:53 +00:00
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
aTrackItem->m_Width = new_width;
|
2009-08-08 06:07:08 +00:00
|
|
|
if( initial_width < new_width ) /* make a DRC test because the new size is bigger than the old size */
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
int diagdrc = OK_DRC;
|
2007-12-01 03:42:52 +00:00
|
|
|
if( Drc_On )
|
2009-08-08 06:07:08 +00:00
|
|
|
diagdrc = m_drc->Drc( aTrackItem, GetBoard()->m_Track );
|
|
|
|
if( diagdrc == OK_DRC )
|
|
|
|
change_ok = true;
|
|
|
|
}
|
|
|
|
else if( initial_width > new_width )
|
|
|
|
change_ok = true;
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2010-12-05 16:24:08 +00:00
|
|
|
// if new width == initial_width: do nothing,
|
|
|
|
// unless a via has its drill value changed
|
|
|
|
else if( (aTrackItem->Type() == TYPE_VIA) && (initial_drill != new_drill) )
|
|
|
|
change_ok = true;
|
2009-08-08 06:07:08 +00:00
|
|
|
|
|
|
|
if( change_ok )
|
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aItemsListPicker )
|
|
|
|
{
|
|
|
|
aTrackItem->m_Width = initial_width;
|
|
|
|
ITEM_PICKER picker( aTrackItem, UR_CHANGED );
|
|
|
|
picker.m_Link = aTrackItem->Copy();
|
|
|
|
aItemsListPicker->PushItem( picker );
|
|
|
|
aTrackItem->m_Width = new_width;
|
2010-12-05 16:24:08 +00:00
|
|
|
if( aTrackItem->Type() == TYPE_VIA )
|
|
|
|
{
|
|
|
|
// Set new drill value. Note: currently microvias have only a default drill value
|
|
|
|
if( new_drill > 0 )
|
|
|
|
aTrackItem->SetDrillValue(new_drill);
|
|
|
|
else
|
|
|
|
aTrackItem->SetDrillDefault( );
|
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
else
|
2009-08-08 06:07:08 +00:00
|
|
|
aTrackItem->m_Width = initial_width;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
return change_ok;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Edit_TrackSegm_Width
|
2009-08-08 06:07:08 +00:00
|
|
|
* Modify one track segment width or one via diameter (using DRC control).
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aDC = the curred device context (can be NULL)
|
2009-08-08 06:07:08 +00:00
|
|
|
* @param aTrackItem = the track segment or via to modify
|
|
|
|
*/
|
2010-12-29 17:47:32 +00:00
|
|
|
void WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
2009-10-10 17:27:53 +00:00
|
|
|
bool change = SetTrackSegmentWidth( aTrackItem, &itemsListPicker, false );
|
2009-08-08 06:07:08 +00:00
|
|
|
|
|
|
|
if( change == 0 || aTrackItem->m_Flags )
|
|
|
|
return; // No change
|
|
|
|
|
|
|
|
// The segment has changed: redraw it and save it in undo list
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aDC )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
2009-10-07 17:10:37 +00:00
|
|
|
TRACK* oldsegm = (TRACK*) itemsListPicker.GetPickedItemLink( 0 );
|
2009-10-10 17:27:53 +00:00
|
|
|
wxASSERT( oldsegm );
|
2010-12-29 17:47:32 +00:00
|
|
|
DrawPanel->CursorOff( aDC ); // Erase cursor shape
|
|
|
|
oldsegm->Draw( DrawPanel, aDC, GR_XOR ); // Erase old track shape
|
|
|
|
aTrackItem->Draw( DrawPanel, aDC, GR_OR ); // Display new track shape
|
|
|
|
DrawPanel->CursorOn( aDC ); // Display cursor shape
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
|
|
|
SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
|
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Edit_Track_Width
|
2009-08-08 06:07:08 +00:00
|
|
|
* Modify a full track width (using DRC control).
|
|
|
|
* a full track is the set of track segments between 2 ends: pads or a point that has more than 2 segments ends connected
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aDC = the curred device context (can be NULL)
|
2009-08-08 06:07:08 +00:00
|
|
|
* @param aTrackSegment = a segment or via on the track to change
|
|
|
|
*/
|
2010-12-29 17:47:32 +00:00
|
|
|
void WinEDA_PcbFrame::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
TRACK* pt_track;
|
2009-08-08 06:07:08 +00:00
|
|
|
int nb_segm;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aTrackSegment == NULL )
|
2007-12-01 03:42:52 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
pt_track = Marque_Une_Piste( GetBoard(), aTrackSegment, &nb_segm, NULL, true );
|
2009-08-08 06:07:08 +00:00
|
|
|
|
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
|
|
|
bool change = false;
|
|
|
|
for( int ii = 0; ii < nb_segm; ii++, pt_track = pt_track->Next() )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
pt_track->SetState( BUSY, OFF );
|
2009-10-10 17:27:53 +00:00
|
|
|
if( SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !change )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Some segment have changed: redraw them and save in undo list
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aDC )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
2010-12-29 17:47:32 +00:00
|
|
|
DrawPanel->CursorOff( aDC ); // Erase cursor shape
|
2009-08-08 06:07:08 +00:00
|
|
|
for( unsigned ii = 0; ii < itemsListPicker.GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
TRACK* segm = (TRACK*) itemsListPicker.GetPickedItemLink( ii );
|
2010-12-29 17:47:32 +00:00
|
|
|
segm->Draw( DrawPanel, aDC, GR_XOR ); // Erase old track shape
|
2009-08-08 06:07:08 +00:00
|
|
|
segm = (TRACK*) itemsListPicker.GetPickedItem( ii );
|
2010-12-29 17:47:32 +00:00
|
|
|
segm->Draw( DrawPanel, aDC, GR_OR ); // Display new track shape
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
DrawPanel->CursorOn( aDC ); // Display cursor shape
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
|
|
|
|
SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Change_Net_Tracks_And_Vias_Sizes
|
2009-10-30 17:58:15 +00:00
|
|
|
* Reset all tracks width and vias diameters and drill
|
|
|
|
* to their default Netclass value ou current values
|
|
|
|
* @param aNetcode : the netcode of the net to edit
|
|
|
|
* @param aUseNetclassValue : bool. True to use netclass values, false to use current values
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2009-10-30 17:58:15 +00:00
|
|
|
bool WinEDA_PcbFrame::Change_Net_Tracks_And_Vias_Sizes(
|
|
|
|
int aNetcode, bool aUseNetclassValue )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
if( aNetcode <= 0 )
|
2009-10-30 17:58:15 +00:00
|
|
|
return false;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
/* Examine segments */
|
2009-08-08 06:07:08 +00:00
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
|
|
|
bool change = false;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
if( aNetcode != pt_segm->GetNet() ) /* not in net */
|
2007-12-01 03:42:52 +00:00
|
|
|
continue;
|
2009-10-10 17:27:53 +00:00
|
|
|
/* we have found a item member of the net */
|
2009-10-30 17:58:15 +00:00
|
|
|
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, aUseNetclassValue ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !change )
|
2009-10-30 17:58:15 +00:00
|
|
|
return false;
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
// Some segment have changed: save them in undo list
|
2009-08-08 06:07:08 +00:00
|
|
|
SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
|
2009-10-30 17:58:15 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2009-10-30 17:58:15 +00:00
|
|
|
bool WinEDA_PcbFrame::Reset_All_Tracks_And_Vias_To_Netclass_Values(
|
|
|
|
bool aTrack, bool aVia )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
/* read and edit tracks and vias if required */
|
2009-08-08 06:07:08 +00:00
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
|
|
|
bool change = false;
|
|
|
|
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-10-30 17:58:15 +00:00
|
|
|
if( (pt_segm->Type() == TYPE_VIA ) && aVia )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, true ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
change = true;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
if( (pt_segm->Type() == TYPE_TRACK ) && aTrack )
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
|
|
|
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, true ) )
|
|
|
|
change = true;;
|
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
if( !change )
|
|
|
|
return false;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
// Some segment have changed: save them in undo list
|
2009-08-08 06:07:08 +00:00
|
|
|
SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
|
|
|
|
|
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|