Commit 8bde66af authored by jean-pierre charras's avatar jean-pierre charras

Eeschema, Pcbnew, fix issues when creating new pins, tracks or segments.

parent f52ed783
...@@ -48,6 +48,7 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" ); ...@@ -48,6 +48,7 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" );
/* Default font size */ /* Default font size */
#define FONT_DEFAULT_SIZE 10 /* Default font size. */ #define FONT_DEFAULT_SIZE 10 /* Default font size. */
static wxString languageCfgKey( wxT( "LanguageID" ) );
/** /**
* The real font size will be computed at run time * The real font size will be computed at run time
...@@ -336,8 +337,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId ) ...@@ -336,8 +337,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId )
ReadPdfBrowserInfos(); ReadPdfBrowserInfos();
// Internationalization: loading the kicad suitable Dictionary // Internationalization: loading the kicad suitable Dictionary
m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId, m_EDA_CommonConfig->Read( languageCfgKey, &m_LanguageId, wxLANGUAGE_DEFAULT );
wxLANGUAGE_DEFAULT );
bool succes = SetLanguage( TRUE ); bool succes = SetLanguage( TRUE );
if( !succes ) if( !succes )
...@@ -627,8 +627,7 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory) ...@@ -627,8 +627,7 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
m_HelpSize.x = 500; m_HelpSize.x = 500;
m_HelpSize.y = 400; m_HelpSize.y = 400;
m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ), m_LanguageId = m_EDA_CommonConfig->Read( languageCfgKey, wxLANGUAGE_DEFAULT );
wxLANGUAGE_DEFAULT );
m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) ); m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );
m_fileHistory.Load( *m_EDA_Config ); m_fileHistory.Load( *m_EDA_Config );
...@@ -718,10 +717,10 @@ bool WinEDA_App::SetLanguage( bool first_time ) ...@@ -718,10 +717,10 @@ bool WinEDA_App::SetLanguage( bool first_time )
if( !first_time ) if( !first_time )
{ {
m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); m_EDA_CommonConfig->Write( languageCfgKey, m_LanguageId );
} }
// Test if floating point notation is working (bug in cross compilation) // Test if floating point notation is working (bug in cross compilation, using wine)
// Make a conversion double <=> string // Make a conversion double <=> string
double dtst = 0.5; double dtst = 0.5;
wxString msg; wxString msg;
......
...@@ -25,21 +25,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -25,21 +25,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
if( m_component == NULL ) // No component loaded ! if( m_component == NULL ) // No component loaded !
return; return;
if( DrawEntry && DrawEntry->m_Flags ) if( DrawEntry == NULL || DrawEntry->m_Flags == 0 )
{
switch( DrawEntry->Type() )
{
case LIB_PIN_T:
PlacePin( DC );
DrawEntry = NULL;
break;
default:
EndDrawGraphicItem( DC );
break;
}
}
else
{ {
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition ); DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
...@@ -56,80 +42,90 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -56,80 +42,90 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
DisplayCmpDoc(); DisplayCmpDoc();
} }
if( m_ID_current_state ) switch( m_ID_current_state )
{ {
switch( m_ID_current_state ) case 0:
case ID_LIBEDIT_NO_TOOL:
if( DrawEntry && DrawEntry->m_Flags ) // moved object
{ {
case 0: switch( DrawEntry->Type() )
case ID_LIBEDIT_NO_TOOL:
break;
case ID_LIBEDIT_PIN_BUTT:
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{
CreatePin( DC );
}
else
{ {
case LIB_PIN_T:
PlacePin( DC ); PlacePin( DC );
} break;
break;
case ID_LIBEDIT_BODY_LINE_BUTT:
case ID_LIBEDIT_BODY_ARC_BUTT:
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT:
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{
m_drawItem = CreateGraphicItem( m_component, DC );
}
else if( m_drawItem )
{
if( m_drawItem->IsNew() )
GraphicItemBeginDraw( DC );
else
EndDrawGraphicItem( DC );
}
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT:
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
if( DrawEntry == NULL )
{
DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->GetCrossHairPosition() );
}
if( DrawEntry == NULL ) default:
{ EndDrawGraphicItem( DC );
DisplayCmpDoc();
break; break;
} }
}
break;
SaveCopyInUndoList( m_component ); case ID_LIBEDIT_PIN_BUTT:
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{
CreatePin( DC );
}
else
{
PlacePin( DC );
}
break;
if( DrawEntry->Type() == LIB_PIN_T ) case ID_LIBEDIT_BODY_LINE_BUTT:
DeletePin( DC, m_component, (LIB_PIN*) DrawEntry ); case ID_LIBEDIT_BODY_ARC_BUTT:
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT:
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{
m_drawItem = CreateGraphicItem( m_component, DC );
}
else if( m_drawItem )
{
if( m_drawItem->IsNew() )
GraphicItemBeginDraw( DC );
else else
m_component->RemoveDrawItem( DrawEntry, DrawPanel, DC ); EndDrawGraphicItem( DC );
}
break;
DrawEntry = NULL; case ID_LIBEDIT_DELETE_ITEM_BUTT:
OnModify( ); DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT: if( DrawEntry == NULL )
SaveCopyInUndoList( m_component ); {
PlaceAncre(); DrawEntry = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); GetScreen()->GetCrossHairPosition() );
break; }
default: if( DrawEntry == NULL )
DisplayError( this, wxT( "LIB_EDIT_FRAME::OnLeftClick error" ) ); {
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); DisplayCmpDoc();
break; break;
} }
SaveCopyInUndoList( m_component );
if( DrawEntry->Type() == LIB_PIN_T )
DeletePin( DC, m_component, (LIB_PIN*) DrawEntry );
else
m_component->RemoveDrawItem( DrawEntry, DrawPanel, DC );
DrawEntry = NULL;
OnModify( );
break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SaveCopyInUndoList( m_component );
PlaceAncre();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break;
default:
DisplayError( this, wxT( "LIB_EDIT_FRAME::OnLeftClick error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break;
} }
} }
......
...@@ -134,10 +134,9 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* ...@@ -134,10 +134,9 @@ LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC*
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
case ID_LIBEDIT_BODY_ARC_BUTT: case ID_LIBEDIT_BODY_ARC_BUTT:
{
m_drawItem = new LIB_ARC( LibEntry ); m_drawItem = new LIB_ARC( LibEntry );
break; break;
}
case ID_LIBEDIT_BODY_CIRCLE_BUTT: case ID_LIBEDIT_BODY_CIRCLE_BUTT:
m_drawItem = new LIB_CIRCLE( LibEntry ); m_drawItem = new LIB_CIRCLE( LibEntry );
break; break;
......
...@@ -27,32 +27,35 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -27,32 +27,35 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->CrossHairOff( DC ); DrawPanel->CrossHairOff( DC );
if( item && item->m_Flags ) // Command in progress if( m_ID_current_state == 0 || m_ID_current_state == ID_MODEDIT_NO_TOOL )
{ {
switch( item->Type() ) if( item && item->m_Flags ) // Move item command in progress
{ {
case TYPE_TEXTE_MODULE: switch( item->Type() )
PlaceTexteModule( (TEXTE_MODULE*) item, DC ); {
break; case TYPE_TEXTE_MODULE:
PlaceTexteModule( (TEXTE_MODULE*) item, DC );
break;
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( (EDGE_MODULE*) item ); Place_EdgeMod( (EDGE_MODULE*) item );
break; break;
case TYPE_PAD: case TYPE_PAD:
PlacePad( (D_PAD*) item, DC ); PlacePad( (D_PAD*) item, DC );
break; break;
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ), msg.Printf( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ),
item->Type(), item->m_Flags ); item->Type(), item->m_Flags );
DisplayError( this, msg ); DisplayError( this, msg );
item->m_Flags = 0; item->m_Flags = 0;
break; break;
} }
}
} }
} }
...@@ -79,9 +82,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -79,9 +82,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
int shape = S_SEGMENT; int shape = S_SEGMENT;
if( m_ID_current_state == ID_PCB_CIRCLE_BUTT ) if( m_ID_current_state == ID_MODEDIT_CIRCLE_TOOL )
shape = S_CIRCLE; shape = S_CIRCLE;
if( m_ID_current_state == ID_PCB_ARC_BUTT ) if( m_ID_current_state == ID_MODEDIT_ARC_TOOL )
shape = S_ARC; shape = S_ARC;
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) ); SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
......
...@@ -20,84 +20,90 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -20,84 +20,90 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{ {
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false; bool exit = false;
bool no_tool = m_ID_current_state == 0 || m_ID_current_state == ID_PCB_NO_TOOL;
if( DrawStruct && DrawStruct->m_Flags ) // Command in progress if( no_tool || ( DrawStruct && DrawStruct->m_Flags ) )
{ {
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
DrawPanel->m_IgnoreMouseEvents = true; if( DrawStruct && DrawStruct->m_Flags ) // Command in progress
DrawPanel->CrossHairOff( aDC );
switch( DrawStruct->Type() )
{ {
case TYPE_ZONE_CONTAINER: DrawPanel->m_IgnoreMouseEvents = true;
if( DrawStruct->IsNew() ) DrawPanel->CrossHairOff( aDC );
{
DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( aDC );
}
else
End_Move_Zone_Corner_Or_Outlines( aDC, (ZONE_CONTAINER*) DrawStruct );
exit = true;
break;
case TYPE_TRACK: switch( DrawStruct->Type() )
case TYPE_VIA:
if( DrawStruct->m_Flags & IS_DRAGGED )
{ {
PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, aDC ); case TYPE_ZONE_CONTAINER:
if( DrawStruct->IsNew() )
{
DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( aDC );
}
else
End_Move_Zone_Corner_Or_Outlines( aDC, (ZONE_CONTAINER*) DrawStruct );
exit = true; exit = true;
} break;
break;
case TYPE_TEXTE: case TYPE_TRACK:
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, aDC ); case TYPE_VIA:
exit = true; if( DrawStruct->m_Flags & IS_DRAGGED )
break; {
PlaceDraggedOrMovedTrackSegment( (TRACK*) DrawStruct, aDC );
exit = true;
}
break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE:
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, aDC ); Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_PAD: case TYPE_TEXTE_MODULE:
PlacePad( (D_PAD*) DrawStruct, aDC ); PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_MODULE: case TYPE_PAD:
Place_Module( (MODULE*) DrawStruct, aDC ); PlacePad( (D_PAD*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_MIRE: case TYPE_MODULE:
Place_Mire( (MIREPCB*) DrawStruct, aDC ); Place_Module( (MODULE*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_DRAWSEGMENT: case TYPE_MIRE:
Place_DrawItem( (DRAWSEGMENT*) DrawStruct, aDC ); Place_Mire( (MIREPCB*) DrawStruct, aDC );
exit = true; exit = true;
break; break;
case TYPE_DIMENSION: case TYPE_DRAWSEGMENT:
// see above. if( no_tool ) // when no tools: existing item moving.
break; {
Place_DrawItem( (DRAWSEGMENT*) DrawStruct, aDC );
exit = true;
}
break;
default: case TYPE_DIMENSION:
DisplayError( this, // see above.
wxT( break;
"WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ),
DrawStruct->Type() );
exit = true;
break;
}
DrawPanel->m_IgnoreMouseEvents = false; default:
DrawPanel->CrossHairOn( aDC ); DisplayError( this,
wxT(
"WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ),
DrawStruct->Type() );
exit = true;
break;
}
if( exit ) DrawPanel->m_IgnoreMouseEvents = false;
return; DrawPanel->CrossHairOn( aDC );
if( exit )
return;
}
else if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) else if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) ) && !wxGetKeyState( WXK_CONTROL ) )
{ {
......
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