Commit 89535a13 authored by charras's avatar charras

some enhancements and cleanup. Fixed problem when deleting Netclasses in Design rules dialog window

parent ae12e698
......@@ -150,8 +150,9 @@ public:
* of "selecting" an item more formal, and to indivisibly tie the operation
* of selecting an item to displaying it using BOARD_ITEM::Display_Infos().
* @param aItem The BOARD_ITEM to make the selected item or NULL if none.
* @param aDisplayInfo = true to display item info, false if not (default = true)
*/
void SetCurItem( BOARD_ITEM* aItem );
void SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo = true );
BOARD_ITEM* GetCurItem();
/**
......
......@@ -126,7 +126,6 @@ set(PCBNEW_SRCS
plot_rtn.cpp
queue.cpp
ratsnest.cpp
router.cpp
set_color.cpp
set_grid.cpp
solve.cpp
......
......@@ -245,14 +245,15 @@ void WinEDA_BasePcbFrame::ProcessItemSelection( wxCommandEvent& event )
/*****************************************************************/
void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem )
void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
/*****************************************************************/
{
GetScreen()->SetCurItem( aItem );
if( aItem )
{
aItem->DisplayInfo( this );
if( aDisplayInfo )
aItem->DisplayInfo( this );
#if 0 && defined(DEBUG)
aItem->Show( 0, std::cout );
......
......@@ -133,7 +133,7 @@ int TRACK::GetDrillValue() const
double TRACK::GetLength()
{
wxPoint delta = m_End - m_Start;
return sqrt( (double)delta.x*delta.x + (double)delta.y*delta.y );
return sqrt( ((double)delta.x*delta.x) + ((double)delta.y*delta.y ) );
}
/***********************/
......@@ -902,6 +902,31 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
// see class_track.h
void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
{
wxString msg;
BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard();
// Display basic infos
DisplayInfoBase( frame );
// Display full track length (in pcbnew)
if( frame->m_Ident == PCB_FRAME )
{
int trackLen = 0;
Marque_Une_Piste( board, this, NULL, &trackLen, false );
valeur_param( trackLen, msg );
frame->MsgPanel->AppendMessage( _( "Track Len" ), msg, DARKCYAN );
}
}
/*
* Function DisplayInfoBase
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Display info about the track segment only, and does not calculate the full track length
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
void TRACK::DisplayInfoBase( WinEDA_DrawFrame* frame )
{
wxString msg;
BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard();
......@@ -1018,15 +1043,6 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
valeur_param( wxRound( GetLength() ), msg );
frame->MsgPanel->AppendMessage( _( "Seg Len" ), msg, DARKCYAN );
}
// Display full track length (in pcbnew)
if( frame->m_Ident == PCB_FRAME )
{
int trackLen;
Marque_Une_Piste( board, this, NULL, &trackLen, false );
valeur_param( trackLen, msg );
frame->MsgPanel->AppendMessage( _( "Track Len" ), msg, DARKCYAN );
}
}
......
......@@ -201,10 +201,19 @@ public:
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct.
* Display info about the track segment and the full track length
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
void DisplayInfo( WinEDA_DrawFrame* frame );
/**
* Function DisplayInfoBase
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Display info about the track segment only, and does not calculate the full track length
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
void DisplayInfoBase( WinEDA_DrawFrame* frame );
/**
* Function ShowWidth
......
......@@ -57,9 +57,9 @@ void RemoteCommand( const char* cmdline )
module = frame->GetBoard()->FindModuleByReference( modName );
if( module )
msg.Printf( _( "%s found" ), modName.GetData() );
msg.Printf( _( "%s found" ), GetChars( modName ) );
else
msg.Printf( _( "%s not found" ), modName.GetData() );
msg.Printf( _( "%s not found" ), GetChars( modName ) );
frame->Affiche_Message( msg );
if( module )
......@@ -103,17 +103,17 @@ void RemoteCommand( const char* cmdline )
}
if( module == NULL )
msg.Printf( _( "%s not found" ), modName.GetData() );
msg.Printf( _( "%s not found" ), GetChars( modName ) );
else if( pad == NULL )
{
msg.Printf( _( "%s pin %s not found" ),
modName.GetData(), pinName.GetData() );
GetChars( modName ), GetChars( pinName ) );
frame->SetCurItem( module );
}
else
{
msg.Printf( _( "%s pin %s found" ),
modName.GetData(), pinName.GetData() );
GetChars( modName ), GetChars( pinName ) );
frame->SetCurItem( pad );
}
......
......@@ -205,7 +205,7 @@ bool DIALOG_COPPER_LAYERS_SETUP::TestDataValidity()
wxString text;
text.Printf( _(
"<small>This layer name <b>%s</b> is already existing<br>" ),
value.GetData() );
GetChars( value ) );
m_MessagesList->AppendToPage( text );
success = false;
}
......
......@@ -119,9 +119,9 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings( )
}
/**************************************/
/******************************************/
void DIALOG_DESIGN_RULES::InitDialogRules()
/**************************************/
/******************************************/
{
SetFocus();
SetReturnCode( 0 );
......@@ -470,28 +470,51 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
InitializeRulesSelectionBoxes();
}
// Sort function for wxArrayInt. Itelms (ints) are sorted by decreasing value
// used in DIALOG_DESIGN_RULES::OnRemoveNetclassClick
int sort_int(int *first, int *second)
{
return * second - *first;
}
/**************************************************************************/
void DIALOG_DESIGN_RULES::OnRemoveNetclassClick( wxCommandEvent& event )
/**************************************************************************/
{
wxArrayInt select = m_grid->GetSelectedRows();
for( int ii = select.GetCount() - 1; ii >= 0; ii-- )
// Sort selection by decreasing index order:
select.Sort(sort_int);
bool reinit = false;
// rows labels seem have problems when deleting rows: they are not deleted properly.
// Workaround: store them, delete rows and reinit row labels (wxWidgets <= 2.9 )
wxArrayString labels;
for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ )
labels.Add(m_grid->GetRowLabelValue(ii));
// Delete rows from last to first (this is the order wxArrayInt select after sorting) )
// This order is Ok when removing rows
for( unsigned ii = 0; ii < select.GetCount(); ii++ )
{
int grid_row = select[ii];
if( grid_row != 0 ) // Do not remove the default class
{
wxString classname = m_grid->GetRowLabelValue( grid_row );
m_grid->DeleteRows( grid_row );
labels.RemoveAt(grid_row);
reinit = true;
// reset the net class to default for members of the removed class
swapNetClass( classname, NETCLASS::Default );
}
else
wxMessageBox(_("The defaut Netclass cannot be removed") );
}
if( reinit )
{
// Workaround: reinit labels (wxWidgets <= 2.9 )
for( unsigned ii = 1; ii < labels.GetCount(); ii++ )
m_grid->SetRowLabelValue(ii, labels[ii]);
InitializeRulesSelectionBoxes();
InitializeRulesSelectionBoxes();
}
}
/*
......
......@@ -84,8 +84,8 @@ void DialogEditModuleText::Init( )
{
wxString format = m_ModuleInfoText->GetLabel();
msg.Printf( format,
m_Module->m_Reference->m_Text.GetData(),
m_Module->m_Value->m_Text.GetData(),
GetChars( m_Module->m_Reference->m_Text ),
GetChars( m_Module->m_Value->m_Text ),
(float) m_Module->m_Orient / 10 );
}
......
......@@ -598,7 +598,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_MODULE_REQUEST:
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
......@@ -622,7 +622,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_MODULE:
DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
......@@ -637,7 +637,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
......@@ -652,7 +652,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
......@@ -666,7 +666,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
......@@ -680,7 +680,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_MODULE:
// If the current Item is a pad, text module ...: Get the parent
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
......@@ -941,14 +941,6 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
Swap_Layers( event );
break;
case ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER:
GlobalRoute( &dc );
break;
case ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA:
ReadAutoroutedTracks( &dc );
break;
case ID_PCB_USER_GRID_SETUP:
InstallGridFrame( pos );
break;
......
......@@ -55,7 +55,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
frame->MsgPanel->EraseMsgBox();
// Undo pending changes (mainly a lock point cretion) and clear the undo picker list:
frame->PutDataInPreviousState(&s_ItemsListPicker, false, false);
frame->PutDataInPreviousState( &s_ItemsListPicker, false, false );
s_ItemsListPicker.ClearListAndDeleteItems();
// Delete current (new) track
......@@ -135,7 +135,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
else // no starting point, but a filled zone area can exist. This is also a good starting point.
{
ZONE_CONTAINER* zone = GetBoard()->HitTestForAnyFilledArea( pos,
GetScreen()->m_Active_Layer );
GetScreen()->
m_Active_Layer );
if( zone )
g_HightLigth_NetCode = zone->GetNet();
}
......@@ -188,8 +189,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
D( g_CurrentTrackList.VerifyListIntegrity(); );
g_CurrentTrackSegment->DisplayInfo( this );
SetCurItem( g_CurrentTrackSegment );
g_CurrentTrackSegment->DisplayInfoBase( this );
SetCurItem( g_CurrentTrackSegment, false );
DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( Drc_On )
......@@ -267,15 +268,14 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
newTrack->m_Width = g_DesignSettings.m_CurrentTrackWidth;
}
D( g_CurrentTrackList.VerifyListIntegrity(); );
D( g_CurrentTrackList.VerifyListIntegrity(); );
/* Show the new position */
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
}
g_CurrentTrackSegment->DisplayInfo( this );
}
}
SetCurItem( g_CurrentTrackSegment );
SetCurItem( g_CurrentTrackSegment, false );
return g_CurrentTrackSegment;
}
......@@ -476,7 +476,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End,
adr_buf,
g_CurrentTrackSegment,
&s_ItemsListPicker);
&s_ItemsListPicker );
}
}
......@@ -514,9 +514,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
// erase the old track, if exists
if( g_AutoDeleteOldTrack )
{
EraseRedundantTrack( DC, firstTrack, newCount, & s_ItemsListPicker );
EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker );
}
SaveCopyInUndoList(s_ItemsListPicker, UR_UNSPECIFIED);
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
/* compute the new rastnest : */
......@@ -669,11 +669,12 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
{
D( g_CurrentTrackList.VerifyListIntegrity(); );
PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen();
PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen();
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
bool Track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
bool Track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
DisplayOpt.DisplayPcbTrackFill = true;
int showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode;
int showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode;
NETCLASS* netclass = g_FirstTrackSegment->GetNetClass();
......@@ -685,7 +686,7 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
{
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
( (WinEDA_BasePcbFrame*)(panel->m_Parent) )->trace_ratsnest_pad( DC );
frame->trace_ratsnest_pad( DC );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) // Show the via area
{
......@@ -760,13 +761,35 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
color );
}
/* Display info about currrent segment and the full new track:
* Choose the interesting segment: because we are using a 2 segments step,
* the last segment can be null, and the previous segment can be the interesting segment.
*/
TRACK* isegm = g_CurrentTrackSegment;
if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
isegm = g_CurrentTrackSegment->Back();
// display interesting segment info only:
isegm->DisplayInfoBase( frame );
// Add current track length
int trackLen = 0;
wxString msg;
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
trackLen += track->GetLength();
valeur_param( trackLen, msg );
frame->MsgPanel->AppendMessage( _( "Track Len" ), msg, DARKCYAN );
// Add current segments count (number of segments in this new track):
msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() );
frame->MsgPanel->AppendMessage( _( "Segs Count" ), msg, DARKCYAN );
DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode;
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
( (WinEDA_BasePcbFrame*)(panel->m_Parent) )->
build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, false );
( (WinEDA_BasePcbFrame*)(panel->m_Parent) )->trace_ratsnest_pad( DC );
frame->build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, false );
frame->trace_ratsnest_pad( DC );
}
......
......@@ -464,7 +464,8 @@ void CreateSignalsSection( FILE* file, BOARD* pcb )
pad->ReturnStringPadName( padname );
msg.Printf( wxT( "NODE %s %.4s" ),
module->m_Reference->m_Text.GetData(), padname.GetData() );
GetChars( module->m_Reference->m_Text ),
GetChars( padname ) );
fputs( CONV_TO_UTF8( msg ), file );
fputs( "\n", file );
......
......@@ -108,8 +108,8 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
case ID_NEW_BOARD:
Clear_Pcb( true );
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
wxGetCwd().GetData(), DIR_SEP,
PcbExtBuffer.GetData() );
GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbExtBuffer ) );
SetTitle( GetScreen()->m_FileName );
ReCreateLayerBox( NULL );
break;
......@@ -187,7 +187,7 @@ bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, bool Append
if( source == NULL )
{
msg.Printf( _( "File <%s> not found" ),
GetScreen()->m_FileName.GetData() );
GetChars( GetScreen()->m_FileName ) );
DisplayError( this, msg );
return false;
}
......
......@@ -116,7 +116,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
if( FindMarker )
msg = _( "Marker found" );
else
msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() );
msg.Printf( _( "<%s> Found" ), GetChars( s_OldStringFound ) );
m_Parent->Affiche_Message( msg );
......@@ -131,7 +131,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
if( FindMarker )
msg = _( "Marker not found" );
else
msg.Printf( _( "<%s> Not Found" ), s_OldStringFound.GetData() );
msg.Printf( _( "<%s> Not Found" ), GetChars( s_OldStringFound ) );
DisplayError( this, msg, 10 );
EndModal( 0 );
......
......@@ -448,7 +448,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
}
fprintf( rptfile, "$EndMODULE %s\n\n",
(const char*) Module->m_Reference->m_Text.GetData() );
CONV_TO_UTF8(Module->m_Reference->m_Text ) );
}
/* Write board Edges */
......
......@@ -27,8 +27,8 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************/
/* Routine de sortie du menu EDIT PADS.
* Sortie simple si pad de pad en mouvement
* Remise en etat des conditions initiales avant move si move en cours
* Sortie simple si pad de pad en mouvement
* Remise en etat des conditions initiales avant move si move en cours
*/
{
D_PAD* pad = s_CurrentSelectedPad;
......@@ -59,7 +59,7 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
EraseDragListe();
s_CurrentSelectedPad = NULL;
g_Drag_Pistes_On = FALSE;
g_Drag_Pistes_On = FALSE;
}
......@@ -123,7 +123,7 @@ void WinEDA_BasePcbFrame::Export_Pad_Settings( D_PAD* pt_pad )
g_Pad_Master.m_Masque_Layer = pt_pad->m_Masque_Layer;
g_Pad_Master.m_Orient = pt_pad->m_Orient -
( (MODULE*) pt_pad->GetParent() )->m_Orient;
g_Pad_Master.m_Size = pt_pad->m_Size;
g_Pad_Master.m_Size = pt_pad->m_Size;
g_Pad_Master.m_DeltaSize = pt_pad->m_DeltaSize;
pt_pad->ComputeRayon();
......@@ -138,9 +138,9 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
/***********************************************************************/
/* Met a jour les nouvelles valeurs de dimensions du pad pointe par pt_pad
* - Source : valeurs choisies des caracteristiques generales
* - les dimensions sont modifiees
* - la position et les noms ne sont pas touches
* - Source : valeurs choisies des caracteristiques generales
* - les dimensions sont modifiees
* - la position et les noms ne sont pas touches
*/
{
if( aDraw )
......@@ -152,10 +152,10 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->m_PadShape = g_Pad_Master.m_PadShape;
aPad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer;
aPad->m_Attribut = g_Pad_Master.m_Attribut;
aPad->m_Orient = g_Pad_Master.m_Orient +
( (MODULE*) aPad->GetParent() )->m_Orient;
aPad->m_Size = g_Pad_Master.m_Size;
aPad->m_Attribut = g_Pad_Master.m_Attribut;
aPad->m_Orient = g_Pad_Master.m_Orient +
( (MODULE*) aPad->GetParent() )->m_Orient;
aPad->m_Size = g_Pad_Master.m_Size;
aPad->m_DeltaSize = wxSize( 0, 0 );
aPad->m_Offset = g_Pad_Master.m_Offset;
aPad->m_Drill = g_Pad_Master.m_Drill;
......@@ -208,7 +208,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
/* Mise a jour des caract de la pastille : */
Import_Pad_Settings( Pad, false );
Pad->SetNetname(wxEmptyString);
Pad->SetNetname( wxEmptyString );
Pad->m_Pos = GetScreen()->m_Curseur;
......@@ -222,8 +222,8 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
/* Increment automatique de la reference courante Current_PadName */
long num = 0; int ponder = 1;
while( g_Current_PadName.Len() && g_Current_PadName.Last() >= '0' &&
g_Current_PadName.Last() <= '9' )
while( g_Current_PadName.Len() && g_Current_PadName.Last() >= '0'
&& g_Current_PadName.Last() <= '9' )
{
num += (g_Current_PadName.Last() - '0') * ponder;
g_Current_PadName.RemoveLast();
......@@ -237,7 +237,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
/* Redessin du module */
Module->Set_Rectangle_Encadrement();
Pad->DisplayInfo( this );
if ( draw )
if( draw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
}
......@@ -257,7 +257,8 @@ void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad )
Module->m_LastEdit_Time = time( NULL );
line.Printf( _( "Delete Pad (module %s %s) " ),
Module->m_Reference->m_Text.GetData(), Module->m_Value->m_Text.GetData() );
GetChars( Module->m_Reference->m_Text ),
GetChars( Module->m_Value->m_Text ) );
if( !IsOK( this, line ) )
return;
......@@ -309,48 +310,49 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
/*********************************************************/
/* Routine to Place a moved pad */
{
int dX, dY;
TRACK* Track;
MODULE* Module;
int dX, dY;
TRACK* Track;
MODULE* Module;
if( Pad == NULL )
return;
Module = (MODULE*) Pad->GetParent();
ITEM_PICKER picker(NULL, UR_CHANGED);
ITEM_PICKER picker( NULL, UR_CHANGED );
PICKED_ITEMS_LIST pickList;
/* Save dragged track segments in undo list */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; pt_drag; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
// Set the old state
wxPoint t_start = Track->m_Start;
wxPoint t_end = Track->m_End;
wxPoint t_end = Track->m_End;
if( pt_drag->m_Pad_Start )
Track->m_Start = Pad_OldPos;
if( pt_drag->m_Pad_End )
Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track;
pickList.PushItem(picker);
pickList.PushItem( picker );
}
/* Save old module and old items values */
wxPoint pad_curr_position = Pad->m_Pos;
Pad->m_Pos = Pad_OldPos;
if ( g_DragSegmentList == NULL )
if( g_DragSegmentList == NULL )
SaveCopyInUndoList( Module, UR_CHANGED );
else
{
picker.m_PickedItem = Module;
pickList.PushItem(picker);
pickList.PushItem( picker );
}
if ( g_DragSegmentList )
if( g_DragSegmentList )
SaveCopyInUndoList( pickList, UR_CHANGED );
/* Placement du pad */
......@@ -359,9 +361,10 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Pad->Draw( DrawPanel, DC, GR_XOR );
/* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; pt_drag; pt_drag = pt_drag->Pnext )
for( DRAG_SEGM* pt_drag = g_DragSegmentList; pt_drag; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
// Set the new state
if( pt_drag->m_Pad_Start )
Track->m_Start = Pad->m_Pos;
......@@ -369,7 +372,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Track->m_End = Pad->m_Pos;
Track->SetState( EDIT, OFF );
if ( DC )
if( DC )
Track->Draw( DrawPanel, DC, GR_OR );
}
......@@ -383,7 +386,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Pad->m_Flags = 0;
if ( DC )
if( DC )
Pad->Draw( DrawPanel, DC, GR_OR );
Module->Set_Rectangle_Encadrement();
......@@ -404,7 +407,7 @@ void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC )
/**********************************************************/
/* Tourne de 90 degres le pad selectionne :
* c.a.d intervertit dim X et Y et offsets
* c.a.d intervertit dim X et Y et offsets
*/
{
MODULE* Module;
......@@ -417,7 +420,7 @@ void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC )
GetScreen()->SetModify();
if ( DC )
if( DC )
Module->Draw( DrawPanel, DC, GR_XOR );
EXCHG( Pad->m_Size.x, Pad->m_Size.y );
......@@ -427,11 +430,11 @@ void WinEDA_BasePcbFrame::RotatePad( D_PAD* Pad, wxDC* DC )
EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y );
Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; /* ceci est la variation
* de la dim Y sur l'axe X */
* de la dim Y sur l'axe X */
Module->Set_Rectangle_Encadrement();
Pad->DisplayInfo( this );
if ( DC )
if( DC )
Module->Draw( DrawPanel, DC, GR_OR );
}
......@@ -190,6 +190,9 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
DisplayOpt.DisplayPcbTrackFill = track_fill_copy;
// Display track length
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
Track->DisplayInfo( frame );
}
......@@ -439,6 +442,9 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
tSegmentToStart->Draw( panel, DC, draw_mode );
if( tSegmentToEnd )
tSegmentToEnd->Draw( panel, DC, draw_mode );
// Display track length
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
Track->DisplayInfo( frame );
}
......
......@@ -114,7 +114,7 @@ bool OpenNetlistFile( const wxString& aFullFileName )
if( source == 0 )
{
wxString msg;
msg.Printf( _( "Netlist file %s not found" ), aFullFileName.GetData() );
msg.Printf( _( "Netlist file %s not found" ), GetChars( aFullFileName ) );
DisplayError( NULL, msg );
return FALSE;
}
......@@ -181,7 +181,7 @@ void ReadPcbNetlist( WinEDA_PcbFrame* aFrame,
State = 0; LineNum = 0; Comment = 0;
s_NbNewModules = 0;
wxBusyCursor dummy; // Shows an hourglass while calculating
wxBusyCursor dummy; // Shows an hourglass while calculating
/* First, read the netlist: Build the list of footprints to load (new footprints)
*/
......@@ -486,8 +486,9 @@ MODULE* ReadNetModule( WinEDA_PcbFrame* aFrame,
msg.Printf(
_(
"Component \"%s\": Mismatch! module is [%s] and netlist said [%s]\n" ),
TextCmpName.GetData(), Module->m_LibRef.GetData(),
NameLibCmp.GetData() );
GetChars( TextCmpName ),
GetChars( Module->m_LibRef ),
GetChars( NameLibCmp ) );
if( aMessageWindow )
aMessageWindow->AppendText( msg );
......@@ -520,7 +521,7 @@ MODULE* ReadNetModule( WinEDA_PcbFrame* aFrame,
if( aMessageWindow )
{
wxString msg;
msg.Printf( _( "Component [%s] not found" ), TextCmpName.GetData() );
msg.Printf( _( "Component [%s] not found" ), GetChars( TextCmpName ) );
aMessageWindow->AppendText( msg + wxT( "\n" ) );
}
}
......@@ -586,7 +587,8 @@ int SetPadNetName( wxWindow* frame, char* Text, MODULE* Module, wxTextCtrl* aMes
{
wxString pin_name = CONV_FROM_UTF8( TextPinName );
Msg.Printf( _( "Module [%s]: Pad [%s] not found" ),
Module->m_Reference->m_Text.GetData(), pin_name.GetData() );
GetChars( Module->m_Reference->m_Text ),
GetChars( pin_name ) );
aMessageWindow->AppendText( Msg + wxT( "\n" ) );
}
}
......@@ -658,7 +660,7 @@ void TestFor_Duplicate_Missing_And_Extra_Footprints( wxWindow* aFrame,
*/
#define MAX_LEN_TXT 32
{
int ii;
int ii;
MODULE* Module, * pt_aux;
int NbModulesNetListe, nberr = 0;
WinEDA_TextFrame* List;
......@@ -870,7 +872,7 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp,
{
wxString msg;
msg.Printf( _( "File <%s> not found, use Netlist for lib module selection" ),
CmpFullFileName.GetData() );
GetChars( CmpFullFileName ) );
DisplayError( NULL, msg, 20 );
return 0;
}
......@@ -1001,7 +1003,8 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame )
{
wxString msg;
msg.Printf( _( "Component [%s]: footprint <%s> not found" ),
cmp->m_CmpName.GetData(), cmp->m_LibName.GetData() );
GetChars( cmp->m_CmpName ),
GetChars( cmp->m_LibName ) );
DisplayError( NULL, msg );
continue;
}
......
......@@ -215,8 +215,10 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
else if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC );
if( track ) // c'est a dire si OK
SetCurItem( DrawStruct = track );
// SetCurItem() must not write to the msg panel
// because a track info is displayed while moving the mouse cursor
if( track ) // A new segment was created
SetCurItem( DrawStruct = track, false );
DrawPanel->m_AutoPAN_Request = true;
}
break;
......
......@@ -153,7 +153,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE )
{
if( !flags )
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _( "Autoroute" ) );
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _( "Autoroute Module" ) );
}
break;
......@@ -345,21 +345,13 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE )
{
wxMenu* commands = new wxMenu;
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Global Autoroute" ), commands );
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Autoroute" ), commands );
ADD_MENUITEM( commands, ID_POPUP_PCB_SELECT_LAYER_PAIR,
_( "Select Layer Pair" ), select_layer_pair_xpm );
commands->AppendSeparator();
commands->Append( ID_POPUP_PCB_AUTOROUTE_ALL_MODULES, _( "Autoroute All Modules" ) );
commands->AppendSeparator();
commands->Append( ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED, _( "Reset Unrouted" ) );
if( GetBoard()->m_Modules )
{
commands->AppendSeparator();
commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER,
_( "Global AutoRouter" ) );
commands->Append( ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA,
_( "Read Global AutoRouter Data" ) );
}
aPopMenu->AppendSeparator();
}
......
......@@ -125,8 +125,6 @@ enum pcbnew_ids
ID_POPUP_PCB_LOCK_OFF_NET,
ID_POPUP_PCB_SETFLAGS_TRACK_MNU,
ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER,
ID_POPUP_PCB_AUTOROUTE_GET_AUTOROUTER_DATA,
ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE,
ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE,
ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE,
......
......@@ -143,7 +143,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
errMsg.Printf(
_( "Your BOARD has a bad layer number of %u for module\n %s's \"reference\" text." ),
textLayer, Module->GetReference().GetData() );
textLayer, GetChars( Module->GetReference() ) );
DisplayError( this, errMsg );
return;
}
......@@ -163,7 +163,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
errMsg.Printf(
_( "Your BOARD has a bad layer number of %u for module\n %s's \"value\" text." ),
textLayer, Module->GetReference().GetData() );
textLayer, GetChars( Module->GetReference() ) );
DisplayError( this, errMsg );
return;
}
......@@ -201,7 +201,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
errMsg.Printf(
_(
"Your BOARD has a bad layer number of %u for module\n %s's \"module text\" text of %s." ),
textLayer, Module->GetReference().GetData(), pt_texte->m_Text.GetData() );
textLayer, GetChars( Module->GetReference() ),
GetChars( pt_texte->m_Text ) );
DisplayError( this, errMsg );
return;
}
......@@ -477,8 +478,8 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
return;
/* calcul des parametres du texte :*/
size = pt_texte->m_Size;
pos = pt_texte->m_Pos;
size = pt_texte->m_Size;
pos = pt_texte->m_Pos;
orient = pt_texte->m_Orient;
thickness = (trace_mode==FILAIRE) ? -1 : pt_texte->m_Width;
......@@ -575,15 +576,15 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
if( trace_mode == FILLED )
{
// Plot the current filled area polygon
if( aZone->m_FillMode == 0 ) // We are using solid polygons (if != 0: using segments )
if( aZone->m_FillMode == 0 ) // We are using solid polygons (if != 0: using segments )
plotter->poly( corners_count, CornersBuffer, FILLED_SHAPE );
else // We are using areas filled by segments: plot hem )
else // We are using areas filled by segments: plot hem )
{
for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ )
{
wxPoint start = aZone->m_FillSegmList[iseg].m_Start;
wxPoint end = aZone->m_FillSegmList[iseg].m_End ;
plotter->thick_segment(start, end, aZone->m_ZoneMinThickness, trace_mode );
wxPoint end = aZone->m_FillSegmList[iseg].m_End;
plotter->thick_segment( start, end, aZone->m_ZoneMinThickness, trace_mode );
}
}
......
/****************************************/
/* EDITEUR de PCB: Menus d'AUTOROUTAGE: */
/****************************************/
// #define ROUTER
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "autorout.h"
#include "zones.h"
#include "cell.h"
#include "trigo.h"
#include "protos.h"
#define PSCALE 1
/* routines internes */
#ifdef ROUTER
static void Out_Pads( BOARD* Pcb, FILE* outfile );
static int GenEdges( BOARD* Pcb, FILE* outfile );
#endif
static void GenExistantTracks( BOARD* Pcb, FILE* outfile, int current_net_code, int type );
static void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias, int* nb_tracks );
/* variables locales */
static int min_layer, max_layer;
/******************************************/
void WinEDA_PcbFrame::GlobalRoute( wxDC* DC )
/******************************************/
{
#ifdef ROUTER
wxFileName fn;
FILE* outfile;
wxString ExecFileName, msg;
int ii;
int net_number;
#ifdef __UNIX__
ExecFileName = FindKicadFile( wxT( "anneal" ) );
#else
ExecFileName = FindKicadFile( wxT( "anneal.exe" ) );
#endif
/* test de la presence du fichier et execution si present */
if( !wxFileExists( ExecFileName ) )
{
msg.Printf( wxT( "File <%s> not found" ), ExecFileName.GetData() );
DisplayError( this, msg, 20 );
return;
}
/* Calcule du nom du fichier intermediaire de communication */
fn = GetScreen()->m_FileName;
fn.SetExt( wxT( "ipt" ) );
if( ( outfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
msg = _( "Unable to create temporary file " ) + fn.GetFullPath();
DisplayError( this, msg, 20 );
return;
}
msg = _( "Create temporary file " ) + fn.GetFullPath();
SetStatusText( msg );
/* calcul ratsnest */
GetBoard()->m_Status_Pcb = 0;
Compile_Ratsnest( DC, TRUE );
GetBoard()->ComputeBoundaryBox();
g_GridRoutingSize = GetScreen()->GetGrid().x;
// Sortie de la dimension hors tout du pcb (dimensions + marge + g_GridRoutingSize)
#define B_MARGE 1000 // en 1/10000 inch
fprintf( outfile, "j %d %d %d %d",
( -B_MARGE - g_GridRoutingSize + GetBoard()->m_BoundaryBox.GetX() ) / PSCALE,
( -B_MARGE - g_GridRoutingSize + GetBoard()->m_BoundaryBox.GetY() ) / PSCALE,
( B_MARGE + g_GridRoutingSize + GetBoard()->m_BoundaryBox.GetRight() ) / PSCALE,
( B_MARGE + g_GridRoutingSize + GetBoard()->m_BoundaryBox.GetBottom() ) / PSCALE );
/* calcul du nombre de couches cuivre */
min_layer = 1; /* -> couche soudure = min layer */
max_layer = GetBoard()->m_BoardSettings->m_CopperLayerCount;
fprintf( outfile, " %d %d", min_layer, max_layer );
net_number = GetBoard()->m_Equipots.GetCount();
fprintf( outfile, " %d", net_number );
fprintf( outfile, " %d", g_GridRoutingSize / PSCALE );
fprintf( outfile, " %d %d %d", /* isolation Pad, track, via */
g_DesignSettings.m_TrackClearance / PSCALE,
g_DesignSettings.m_TrackClearance / PSCALE,
g_DesignSettings.m_TrackClearance / PSCALE );
fprintf( outfile, " 0" ); /* via type */
fprintf( outfile, " %d", g_DesignSettings.m_CurrentViaSize / PSCALE ); /* via diam */
fprintf( outfile, " n" ); /* via enterree non permise */
fprintf( outfile, " 0" ); /* unused */
fprintf( outfile, " %d", g_DesignSettings.m_CurrentTrackWidth / PSCALE ); /* default track width */
fprintf( outfile, " 0" ); /* unused */
fprintf( outfile, " 0 0 0\n" ); /* unused */
fprintf( outfile, "k 0 0 0 0 0 0 0 0 0 0\n" ); /* spare record */
fprintf( outfile, "m 0 0 0 0 0 0 0 0 0 0\n" ); /* cost record */
for( ii = min_layer; ii <= max_layer; ii++ )
{
int dir;
dir = 3; /* horizontal */
if( ii & 1 )
dir = 1; /* vertical */
fprintf( outfile, "l %d %d\n", ii, dir ); /* layer direction record */
}
Out_Pads( GetBoard(), outfile );
GenEdges( GetBoard(), outfile );
fclose( outfile );
ExecFileName += wxT( " " ) + fn.GetFullPath();
Affiche_Message( ExecFileName );
ProcessExecute( ExecFileName );
#else
wxMessageBox( wxT( "TODO, currently not available" ) );
#endif
}
/************************************************/
void Out_Pads( BOARD* Pcb, FILE* outfile )
/************************************************/
{
D_PAD* pt_pad;
int netcode, mod_num, nb_pads, plink;
LISTE_PAD* pt_liste_pad, * pt_start_liste,
* pt_end_liste, * pt_liste_pad_limite;
int pin_min_layer, pin_max_layer;
int no_conn = Pcb->GetPadsCount() + 1;/* valeur incrementee pour indiquer
* que le pad n'est pas deja connecte a une piste*/
pt_liste_pad = pt_start_liste = &Pcb->m_NetInfo->m_PadsFullList[0];
pt_liste_pad_limite = pt_start_liste + Pcb->GetPadsCount();
if( pt_liste_pad == NULL )
return;
netcode = (*pt_liste_pad)->GetNet();
nb_pads = 1;
plink = 0;
for( ; pt_liste_pad < pt_liste_pad_limite; )
{
/* Recherche de la fin de la liste des pads du net courant */
for( pt_end_liste = pt_liste_pad + 1; ; pt_end_liste++ )
{
if( pt_end_liste >= pt_liste_pad_limite )
break;
if( (*pt_end_liste)->GetNet() != netcode )
break;
nb_pads++;
}
/* fin de liste trouvee : */
if( netcode > 0 )
{
int nb_vias, nb_tracks;
ReturnNbViasAndTracks( Pcb, netcode, &nb_vias, &nb_tracks );
if( nb_pads < 2 )
{
wxString Line;
NETINFO_ITEM* net = Pcb->FindNet( netcode );
Line.Printf( wxT( "Warning: %d pad, net %s" ),
nb_pads, net->GetNetname().GetData() );
DisplayError( NULL, Line, 20 );
}
fprintf( outfile, "r %d %d %d %d %d %d 1 1\n",
netcode, nb_pads, nb_vias + nb_pads, nb_tracks, 0,
g_DesignSettings.m_CurrentTrackWidth / PSCALE );
}
for( ; pt_liste_pad < pt_end_liste; pt_liste_pad++ )
{
pt_pad = *pt_liste_pad;
netcode = pt_pad->GetNet();
plink = pt_pad->GetSubNet();
/* plink = numero unique si pad non deja connecte a une piste */
if( plink <= 0 )
plink = no_conn++;
if( netcode <= 0 ) /* pad non connecte */
fprintf( outfile, "u 0" );
else
fprintf( outfile, "p %d", netcode );
/* position */
fprintf( outfile, " %d %d",
pt_pad->m_Pos.x / PSCALE, pt_pad->m_Pos.y / PSCALE );
/* layers */
pin_min_layer = 0; pin_max_layer = max_layer;
if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CUIVRE_LAYER )
pin_min_layer = pin_max_layer = min_layer;
else if( (pt_pad->m_Masque_Layer & ALL_CU_LAYERS) == CMP_LAYER )
pin_min_layer = pin_max_layer = max_layer;
fprintf( outfile, " %d %d", pin_min_layer, pin_min_layer );
/* link */
fprintf( outfile, " %d", plink );
/* type of device (1 = IC, 2 = edge conn, 3 = discret, 4 = other */
switch( pt_pad->m_Attribut )
{
case PAD_STANDARD:
case PAD_SMD:
fprintf( outfile, " %d", 1 );
break;
case PAD_CONN:
fprintf( outfile, " %d", 2 );
break;
case PAD_HOLE_NOT_PLATED:
fprintf( outfile, " %d", 4 );
break;
}
/* pin number */
fprintf( outfile, " %ld", (long) (pt_pad->m_Padname) );
/* layer size number (tj = 1) */
fprintf( outfile, " %d", 1 );
/* device number */
mod_num = 1; /* A CHANGER */
fprintf( outfile, " %d", mod_num );
/* orientations pins 1 et 2 */
fprintf( outfile, " x" );
/* spare */
fprintf( outfile, " 0 0\n" );
/* output layer size record */
fprintf( outfile, "q" );
switch( pt_pad->m_PadShape ) /* out type, dims */
{
case PAD_CIRCLE:
fprintf( outfile, " c 0 %d 0",
pt_pad->m_Size.x / PSCALE );
break;
case PAD_OVAL:
case PAD_RECT:
case PAD_TRAPEZOID:
int lmax = pt_pad->m_Size.x;
int lmin = pt_pad->m_Size.y;
int angle = pt_pad->m_Orient / 10;
while( angle < 0 )
angle += 180;
while( angle > 180 )
angle -= 180;
while( angle > 135 )
{
angle -= 90;
EXCHG( lmax, lmin );
}
fprintf( outfile, " r %d %d %d",
angle,
lmax / PSCALE, lmin / PSCALE );
break;
}
/* layers */
fprintf( outfile, " %d %d\n", pin_min_layer, pin_max_layer );
}
/* fin generation liste pads pour 1 net */
if( netcode )
{
GenExistantTracks( Pcb, outfile, netcode, TYPE_VIA );
GenExistantTracks( Pcb, outfile, netcode, TYPE_TRACK );
}
nb_pads = 1;
pt_liste_pad = pt_start_liste = pt_end_liste;
if( pt_start_liste < pt_liste_pad_limite )
netcode = (*pt_start_liste)->GetNet();
}
}
/**************************************************************************/
void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias,
int* nb_tracks )
/**************************************************************************/
/* calcule le nombre de vias et segments de pistes pour le net netcode
*/
{
TRACK* track;
*nb_vias = 0;
*nb_tracks = 0;
track = Pcb->m_Track;
if( track == NULL )
return;
for( ; track != NULL; track = track->Next() )
{
if( track->GetNet() > netcode )
return;
if( track->GetNet() != netcode )
continue;
if( track->Type() == TYPE_VIA )
(*nb_vias)++;
if( track->Type() == TYPE_TRACK )
(*nb_tracks)++;
}
}
/*************************************************************/
void GenExistantTracks( BOARD* Pcb, FILE* outfile,
int current_net_code, int type )
/*************************************************************/
/* generation des pistes existantes */
{
int netcode, plink;
int via_min_layer, via_max_layer;
TRACK* track;
track = Pcb->m_Track;
if( track == NULL )
return;
for( ; track != NULL; track = track->Next() )
{
netcode = track->GetNet();
if( netcode > current_net_code )
return;
if( netcode != current_net_code )
continue;
plink = track->GetSubNet();
via_min_layer = track->GetLayer();
if( track->Type() != type )
continue;
if( track->Type() == TYPE_VIA )
{
via_min_layer &= 15;
via_max_layer = (track->GetLayer() >> 4) & 15;
if( via_min_layer == via_max_layer )
{
track->SetLayer( 0xF );
via_min_layer = 0; via_max_layer = 15;
}
if( via_max_layer < via_min_layer )
EXCHG( via_max_layer, via_min_layer );
if( via_max_layer == CMP_N )
via_max_layer = max_layer;
else
via_max_layer++;
if( via_min_layer == COPPER_LAYER_N )
via_min_layer = min_layer;
else
via_min_layer++;
fprintf( outfile, "v 0 " );
fprintf( outfile, " %d %d", track->m_Start.x / PSCALE, track->m_Start.y / PSCALE );
fprintf( outfile, " %d %d", via_min_layer, via_max_layer );
fprintf( outfile, " %d", plink );
fprintf( outfile, " %d\n", 1 );
/* layer size record */
fprintf( outfile, "q c 0 %d 0 0 0\n", track->m_Width / PSCALE );
}
if( track->Type() == TYPE_TRACK )
{
fprintf( outfile, "t 0 %d", track->m_Width / PSCALE );
fprintf( outfile, " %d %d", track->m_Start.x / PSCALE, track->m_Start.y / PSCALE );
fprintf( outfile, " %d %d", track->m_End.x / PSCALE, track->m_End.y / PSCALE );
if( via_min_layer == CMP_N )
via_min_layer = max_layer;
else
via_min_layer++;
fprintf( outfile, " %d", via_min_layer );
fprintf( outfile, " %d\n", 1 ); /*Number of corners */
/* output corner */
fprintf( outfile, "c" );
fprintf( outfile, " %d %d\n", track->m_End.x / PSCALE, track->m_End.y / PSCALE );
}
}
}
/***********************************************/
int GenEdges( BOARD* Pcb, FILE* outfile )
/***********************************************/
/* Generation des contours (edges).
* Il sont gnrs comme des segments de piste placs sur chaque couche routable.
*/
{
#define NB_CORNERS 4
EDA_BaseStruct* PtStruct;
DRAWSEGMENT* PtDrawSegment;
int ii;
int dx, dy, width, angle;
int ox, oy, fx, fy;
wxPoint lim[4];
int NbItems = 0;
/* impression des contours */
for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue;
PtDrawSegment = (DRAWSEGMENT*) PtStruct;
if( PtDrawSegment->GetLayer() != EDGE_N )
continue;
fx = PtDrawSegment->m_End.x; ox = PtDrawSegment->m_Start.x;
fy = PtDrawSegment->m_End.y; oy = PtDrawSegment->m_Start.y;
dx = fx - ox; dy = fy - oy;
if( (dx == 0) && (dy == 0) )
continue;
/* elimination des segments non horizontaux, verticaux ou 45 degres,
* non grs par l'autorouteur */
if( (dx != 0) && (dy != 0) && ( abs( dx ) != abs( dy ) ) )
continue;
NbItems++;
if( outfile == NULL )
continue; /* car simple decompte des items */
/* generation de la zone interdite */
if( dx < 0 )
{
EXCHG( ox, fx ); EXCHG( oy, fy ); dx = -dx; dy = -dy;
}
if( (dx == 0) && (dy < 0 ) )
{
EXCHG( oy, fy ); dy = -dy;
}
width = PtDrawSegment->m_Width;
width += g_GridRoutingSize;
angle = -ArcTangente( dy, dx );
if( angle % 450 )/* not H, V or X */
{
wxBell();
continue;
}
/* 1er point */
dx = -width; dy = -width;
RotatePoint( &dx, &dy, angle );
lim[0].x = ox + dx;
lim[0].y = oy + dy;
/* 2eme point */
RotatePoint( &dx, &dy, -900 );
lim[1].x = fx + dx;
lim[1].y = fy + dy;
/* 3eme point */
RotatePoint( &dx, &dy, -900 );
lim[2].x = fx + dx;
lim[2].y = fy + dy;
/* 4eme point */
RotatePoint( &dx, &dy, -900 );
lim[3].x = ox + dx;
lim[3].y = oy + dy;
if( angle % 900 )
{
}
/* mise a l'echelle */
for( ii = 0; ii < 4; ii++ )
{
lim[ii].x = (int) ( ( (double) lim[ii].x + 0.5 ) / PSCALE );
lim[ii].y = (int) ( ( (double) lim[ii].y + 0.5 ) / PSCALE );
}
/* sortie du 1er point */
fprintf( outfile, "n %d %d %ld %ld %d\n",
0, /* layer number, 0 = all layers */
0, /* -1 (no via), 0 (no via no track), 1 (no track) */
(long) lim[0].x, (long) lim[0].y,
NB_CORNERS );
/* sortie des autres points */
for( ii = 1; ii < 4; ii++ )
{
fprintf( outfile, "c %ld %ld\n",
(long) lim[ii].x, (long) lim[ii].y );
}
}
return NbItems;
}
/****************************************************/
void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC )
/****************************************************/
{
wxFileName fn;
char Line[1024];
wxString msg;
int LineNum = 0, NbTrack = 0, NetCode = 0;
FILE* File;
TRACK* newTrack;
SEGVIA* newVia;
int track_count, track_layer, image, track_width;
int via_layer1, via_layer2, via_size;
wxPoint track_start, track_end;
int max_layer = GetBoard()->m_BoardSettings->m_CopperLayerCount;
/* Calcule du nom du fichier intermediaire de communication */
fn = GetScreen()->m_FileName;
fn.SetExt( wxT( "trc" ) );
if( ( File = wxFopen( fn.GetFullPath(), wxT( "rt" ) ) ) == NULL )
{
msg = _( "Unable to find data file " ) + fn.GetFullPath();
DisplayError( this, msg, 20 );
return;
}
else
{
msg = _( "Reading autorouter data file " ) + fn.GetFullPath();
Affiche_Message( msg );
}
SetLocaleTo_C_standard( );
track_width = g_DesignSettings.m_CurrentTrackWidth;
via_size = g_DesignSettings.m_CurrentViaSize;
while( GetLine( File, Line, &LineNum ) != NULL )
{
char ident = Line[0];
switch( ident )
{
case 'j': // Header, not used
break;
case 'R': // Net record
sscanf( Line + 2, "%d", &NetCode );
break;
case 'V': // via record: fmt = V symbol pos_x pos_y layer1 layer2
sscanf( Line + 2, "%d %d %d %d %d", &image,
&track_start.x, &track_start.y, &via_layer1, &via_layer2 );
via_layer1--; via_layer2--;
if( via_layer1 == max_layer - 1 )
via_layer1 = CMP_N;
if( via_layer2 == max_layer - 1 )
via_layer2 = CMP_N;
newVia = new SEGVIA( GetBoard() );
newVia->m_Start = newVia->m_End = track_start;
newVia->m_Width = via_size;
newVia->SetLayer( via_layer1 + (via_layer2 << 4) );
if( newVia->GetLayer() == 0x0F || newVia->GetLayer() == 0xF0 )
newVia->m_Shape = VIA_THROUGH;
else
newVia->m_Shape = VIA_BLIND_BURIED;
GetBoard()->m_Track.PushFront( newVia );
NbTrack++;
break;
case 'T': // Track list start: fmt = T image layer t_count
sscanf( Line + 2, "%d %d %d", &image, &track_layer, &track_count );
track_layer--;
if( (track_layer != COPPER_LAYER_N) && (track_layer == max_layer - 1) )
track_layer = CMP_N;
// Read corners: fmt = C x_pos y_pos
for( int ii = 0; ii < track_count; ii++ )
{
if( GetLine( File, Line, &LineNum ) != NULL )
{
if( Line[0] != 'C' )
break;
if( ii == 0 )
sscanf( Line + 2, "%d %d", &track_start.x, &track_start.y );
else
{
sscanf( Line + 2, "%d %d", &track_end.x, &track_end.y );
newTrack = new TRACK( GetBoard() );
newTrack->m_Width = track_width;
newTrack->SetLayer( track_layer );
newTrack->m_Start = track_start;
newTrack->m_End = track_end;
track_start = track_end;
GetBoard()->m_Track.PushFront( newTrack );
NbTrack++;
}
}
else
break;
}
break;
default:
break;
}
}
fclose( File );
SetLocaleTo_Default( );
if( NbTrack == 0 )
DisplayError( this, wxT( "Warning: No tracks" ), 10 );
else
{
GetBoard()->m_Status_Pcb = 0;
GetScreen()->SetModify();
}
Compile_Ratsnest( DC, TRUE );
if( NbTrack )
GetScreen()->SetRefreshReq();
}
......@@ -251,7 +251,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
net = GetBoard()->FindNet( current_net_code );
if( net )
{
msg.Printf( wxT( "[%8.8s]" ), net->GetNetname().GetData() );
msg.Printf( wxT( "[%8.8s]" ), GetChars( net->GetNetname() ) );
Affiche_1_Parametre( this, 1, wxT( "Net route" ), msg, BROWN );
msg.Printf( wxT( "%d / %d" ), Ncurrent, Ntotal );
Affiche_1_Parametre( this, 12, wxT( "Activity" ), msg, BROWN );
......
......@@ -45,7 +45,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
continue;
Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), net->GetNet(),
net->GetNetname().GetData() );
GetChars( net->GetNetname() ) );
List.Append( Line );
}
......
......@@ -53,6 +53,9 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
if( aSegmCount )
*aSegmCount = 0;
if( aTrackLen )
*aTrackLen = 0;
if( aStartSegm == NULL )
return NULL;
......@@ -259,7 +262,6 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
/* Set the BUSY flag of all connected segments, first search starting at aRef_pos
* Search ends when:
* - a pad is found (end of a track)
* - a segment found is flagged "EDIT"
* - a segment end has more than one other segment end connected
* - and obviously when no connected item found
* Vias are a special case, because we must see others segment connected on others layers
......@@ -284,9 +286,6 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
pt_via = Fast_Locate_Via( aPcb->m_Track, NULL, aRef_pos, aLayerMask );
if( pt_via )
{
if( pt_via->GetState( EDIT ) )
return;
aLayerMask = pt_via->ReturnMaskLayer();
aList->push_back( pt_via );
......@@ -302,9 +301,6 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
while( ( pt_segm = Fast_Locate_Piste( pt_segm, NULL,
aRef_pos, aLayerMask ) ) != NULL )
{
if( pt_segm->GetState( EDIT ) ) // End of track
return;
if( pt_segm->GetState( BUSY ) ) // already found and selected: skip it
{
pt_segm = pt_segm->Next();
......
......@@ -296,14 +296,14 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
check_module_value = true;
value = m_CurrentModule->m_Value->m_Text;
msg.Printf( _( "Change modules <%s> -> <%s> (val = %s)?" ),
m_CurrentModule->m_LibRef.GetData(),
newmodulename.GetData(),
m_CurrentModule->m_Value->m_Text.GetData() );
GetChars( m_CurrentModule->m_LibRef ),
GetChars( newmodulename ),
GetChars( m_CurrentModule->m_Value->m_Text ) );
}
else
{
msg.Printf( _( "Change modules <%s> -> <%s> ?" ),
lib_reference.GetData(), newmodulename.GetData() );
GetChars( lib_reference ), GetChars( newmodulename ) );
}
if( !IsOK( this, msg ) )
......@@ -327,7 +327,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( value.CmpNoCase( Module->m_Value->m_Text ) != 0 )
continue;
}
if( Change_1_Module( Module, newmodulename.GetData(), &pickList, ShowErr ) )
if( Change_1_Module( Module, newmodulename, &pickList, ShowErr ) )
change = true;
else if( ShowErr )
ShowErr--;
......@@ -376,7 +376,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
{
PtBack = Module->Back();
if( Change_1_Module( Module, Module->m_LibRef.GetData(), &pickList, ShowErr ) )
if( Change_1_Module( Module, Module->m_LibRef, &pickList, ShowErr ) )
change = true;
else if( ShowErr )
ShowErr--;
......@@ -424,7 +424,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
/* Chargement du module */
Line.Printf( _( "Change module %s (%s) " ),
Module->m_Reference->m_Text.GetData(), oldnamecmp.GetData() );
GetChars( Module->m_Reference->m_Text ), GetChars( oldnamecmp ) );
m_WinMessages->AppendText( Line );
namecmp.Trim( true );
......
......@@ -256,7 +256,7 @@ int BOARD::ClipAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList,
{
wxString str;
str.Printf( wxT( "Area %8.8X of net \"%s\" has arcs intersecting other sides.\n" ),
aCurrArea->m_TimeStamp, aCurrArea->m_Netname.GetData() );
aCurrArea->m_TimeStamp, GetChars( aCurrArea->m_Netname ) );
str += wxT( "This may cause problems with other editing operations,\n" );
str += wxT( "such as adding cutouts. It can't be fixed automatically.\n" );
str += wxT( "Manual correction is recommended." );
......@@ -279,7 +279,7 @@ int BOARD::ClipAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList,
wxString str;
str.Printf( wxT(
"Area %8.8X of net \"%s\" is self-intersecting and will be clipped.\n" ),
aCurrArea->m_TimeStamp, aCurrArea->m_Netname.GetData() );
aCurrArea->m_TimeStamp, GetChars( aCurrArea->m_Netname ) );
str += wxT( "This may result in splitting the area.\n" );
str += wxT( "If the area is complex, this may take a few seconds." );
wxMessageBox( str );
......@@ -445,7 +445,7 @@ int BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode,
"Areas %d and %d of net \"%s\" intersect, but some of the intersecting sides are arcs.\n" ),
ia1 + 1,
ia2 + 1,
curr_area->m_Netname.GetData() );
GetChars( curr_area->m_Netname ) );
str += wxT( "Therefore, these areas can't be combined." );
wxMessageBox( str );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment