Commit b0a52709 authored by charras's avatar charras

pcbnew: apply zone patch, fixed very minor bugs

parent 8b3d5a69
...@@ -57,6 +57,10 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) ...@@ -57,6 +57,10 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
switch( id ) // Arret eventuel de la commande de dplacement en cours switch( id ) // Arret eventuel de la commande de dplacement en cours
{ {
case ID_TOOLBARH_PCB_AUTOPLACE:
case ID_TOOLBARH_PCB_AUTOROUTE:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur ) && DrawPanel->ForceCloseManageCurseur )
...@@ -71,9 +75,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) ...@@ -71,9 +75,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
{ {
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
m_ID_current_state = 0; SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
DisplayToolMsg( wxEmptyString );
DrawPanel->SetCursor( wxCursor( wxCURSOR_ARROW ) );
break; break;
} }
......
...@@ -55,6 +55,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -55,6 +55,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_ON_ZOOM_SELECT: case ID_ON_ZOOM_SELECT:
case ID_PCB_USER_GRID_SETUP: case ID_PCB_USER_GRID_SETUP:
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
case ID_POPUP_PCB_ROTATE_TEXTEPCB: case ID_POPUP_PCB_ROTATE_TEXTEPCB:
case ID_POPUP_PCB_EDIT_TEXTEPCB: case ID_POPUP_PCB_EDIT_TEXTEPCB:
case ID_POPUP_PCB_EDIT_MIRE: case ID_POPUP_PCB_EDIT_MIRE:
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
/********************************************************************/ /********************************************************************/
void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************/ /********************************************************************/
...@@ -23,26 +22,26 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -23,26 +22,26 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
*/ */
{ {
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false; bool exit = false;
if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) ) if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) )
{ {
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress
{ {
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = true;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
if ( (DrawStruct->m_Flags & IS_NEW) ) if( (DrawStruct->m_Flags & IS_NEW) )
{ {
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( DC ); Begin_Zone( DC );
} }
else else
End_Move_Zone_Corner_Or_Outlines( DC, (ZONE_CONTAINER *) DrawStruct ); End_Move_Zone_Corner_Or_Outlines( DC, (ZONE_CONTAINER*) DrawStruct );
exit = true; exit = true;
break; break;
...@@ -92,7 +91,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -92,7 +91,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
{ {
DisplayError( this, DisplayError( this,
wxT( "WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ), DrawStruct->Type() ); wxT(
"WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ),
DrawStruct->Type() );
exit = true; exit = true;
} }
break; break;
...@@ -100,11 +101,11 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -100,11 +101,11 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
if ( exit ) return; 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) )
{ {
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct ) if( DrawStruct )
...@@ -130,18 +131,18 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -130,18 +131,18 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_HIGHLIGHT_BUTT: case ID_PCB_HIGHLIGHT_BUTT:
{
int netcode = Select_High_Light( DC );
if( netcode < 0 )
GetBoard()->DisplayInfo( this );
else
{ {
int netcode = Select_High_Light( DC ); NETINFO_ITEM* net = GetBoard()->FindNet( netcode );
if( netcode < 0 ) if( net )
GetBoard()->DisplayInfo( this ); net->DisplayInfo( this );
else
{
NETINFO_ITEM * net = GetBoard()->FindNet(netcode);
if ( net )
net->DisplayInfo( this );
}
} }
break; }
break;
case ID_PCB_SHOW_1_RATSNEST_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT:
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
...@@ -175,7 +176,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -175,7 +176,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == ID_PCB_ARC_BUTT ) if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC; shape = S_ARC;
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer <= LAST_COPPER_LAYER ) if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Graphic not authorized on Copper layers" ) ); DisplayError( this, _( "Graphic not authorized on Copper layers" ) );
break; break;
...@@ -184,7 +185,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -184,7 +185,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
DrawStruct = Begin_DrawSegment( NULL, shape, DC ); DrawStruct = Begin_DrawSegment( NULL, shape, DC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct else if( DrawStruct
&& (DrawStruct->Type() == TYPE_DRAWSEGMENT) && (DrawStruct->Type() == TYPE_DRAWSEGMENT)
...@@ -192,13 +193,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -192,13 +193,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC ); DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
break; break;
} }
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer > LAST_COPPER_LAYER ) if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer > LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Tracks on Copper layers only " ) ); DisplayError( this, _( "Tracks on Copper layers only " ) );
break; break;
...@@ -209,22 +210,48 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -209,22 +210,48 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = Begin_Route( NULL, DC ); DrawStruct = Begin_Route( NULL, DC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
if( DrawStruct ) if( DrawStruct )
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) ) else if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{ {
TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC ); TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC );
if( track ) // c'est a dire si OK if( track ) // c'est a dire si OK
SetCurItem( DrawStruct = track ); SetCurItem( DrawStruct = track );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
break; break;
case ID_PCB_ZONES_BUTT: case ID_PCB_ZONES_BUTT:
/* ZONE Tool is selected. Determine action for a left click:
* this can be start a new zone or select and move an existing zone outline corner
* if found near the mouse cursor
*/
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
if ( Begin_Zone( DC ) ) // there is no current item, try to find something under mouse
DrawStruct = PcbGeneralLocateAndDisplay();
bool hit_on_corner = false;
if( DrawStruct && (DrawStruct->Type() == TYPE_ZONE_CONTAINER) )
{
// We have a hit under mouse (a zone outline corner or segment)
// test for a corner only because want to move corners only.
ZONE_CONTAINER* edge_zone = (ZONE_CONTAINER*) DrawStruct;
if( edge_zone->HitTestForCorner( GetScreen()->RefPos( true ) ) >= 0 ) // corner located!
hit_on_corner = true;
}
if( hit_on_corner )
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Corner( DC,
zone_cont,
zone_cont->m_CornerSelection,
false );
}
else if( Begin_Zone( DC ) )
{ {
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
DrawStruct = GetBoard()->m_CurrentZoneContour; DrawStruct = GetBoard()->m_CurrentZoneContour;
...@@ -234,14 +261,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -234,14 +261,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
else if( DrawStruct else if( DrawStruct
&& (DrawStruct->Type() == TYPE_ZONE_CONTAINER) && (DrawStruct->Type() == TYPE_ZONE_CONTAINER)
&& (DrawStruct->m_Flags & IS_NEW) ) && (DrawStruct->m_Flags & IS_NEW) )
{ { // Add a new corner to the current outline beeing created:
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( DC ); Begin_Zone( DC );
DrawStruct = GetBoard()->m_CurrentZoneContour; DrawStruct = GetBoard()->m_CurrentZoneContour;
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( DrawStruct );
} }
else else
DisplayError( this, wxT( "Edit: zone internal error" ) ); DisplayError( this, wxT( "WinEDA_PcbFrame::OnLeftClick() zone internal error" ) );
break; break;
case ID_PCB_ADD_TEXT_BUTT: case ID_PCB_ADD_TEXT_BUTT:
...@@ -249,7 +276,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -249,7 +276,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
SetCurItem( Create_Texte_Pcb( DC ) ); SetCurItem( Create_Texte_Pcb( DC ) );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct->Type() == TYPE_TEXTE ) else if( DrawStruct->Type() == TYPE_TEXTE )
{ {
...@@ -279,7 +306,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -279,7 +306,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_COTATION_BUTT: case ID_PCB_COTATION_BUTT:
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer <= LAST_COPPER_LAYER ) if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Cotation not authorized on Copper layers" ) ); DisplayError( this, _( "Cotation not authorized on Copper layers" ) );
break; break;
...@@ -288,7 +315,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -288,7 +315,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
DrawStruct = Begin_Cotation( NULL, DC ); DrawStruct = Begin_Cotation( NULL, DC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
else if( DrawStruct else if( DrawStruct
&& (DrawStruct->Type() == TYPE_COTATION) && (DrawStruct->Type() == TYPE_COTATION)
...@@ -296,7 +323,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -296,7 +323,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC ); DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC );
SetCurItem( DrawStruct ); SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = true;
} }
else else
DisplayError( this, wxT( "Internal err: Struct not COTATION" ) ); DisplayError( this, wxT( "Internal err: Struct not COTATION" ) );
...@@ -337,9 +364,9 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -337,9 +364,9 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/* handle the double click on the mouse left button /* handle the double click on the mouse left button
*/ */
{ {
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition(); wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
...@@ -405,7 +432,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -405,7 +432,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
InstallGraphicItemPropertiesDialog((DRAWSEGMENT*)DrawStruct, &dc); InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) DrawStruct, &dc );
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
...@@ -429,7 +456,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -429,7 +456,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_ZONES_BUTT: case ID_PCB_ZONES_BUTT:
if ( End_Zone( DC ) ) if( End_Zone( DC ) )
{ {
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL ); SetCurItem( NULL );
......
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