Commit 8a8377ff authored by dickelbeck's avatar dickelbeck

beautification, hit test improvements

parent ea6aba82
This diff is collapsed.
...@@ -332,9 +332,10 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -332,9 +332,10 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
public: public:
EDA_BaseStruct* found; EDA_BaseStruct* found;
int layer; int layer;
int layer_mask;
PadOrModule( int alayer ) : PadOrModule( int alayer ) :
found(0), layer(alayer) found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
{} {}
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ) SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
...@@ -343,23 +344,33 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -343,23 +344,33 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
if( testItem->m_StructType == TYPEPAD ) if( testItem->m_StructType == TYPEPAD )
{ {
if( testItem->HitTest( refPos ) ) D_PAD* pad = (D_PAD*) testItem;
if( pad->HitTest( refPos ) )
{ {
found = testItem; if( layer_mask & pad->m_Masque_Layer )
return SEARCH_QUIT; {
found = testItem;
return SEARCH_QUIT;
}
else if( !found )
{
MODULE* parent = (MODULE*) pad->m_Parent;
if( IsModuleLayerVisible( parent->m_Layer ) )
found = testItem;
}
} }
} }
else if( testItem->m_StructType == TYPEMODULE ) else if( testItem->m_StructType == TYPEMODULE )
{ {
int mlayer = ((MODULE*)testItem)->m_Layer; MODULE* module = (MODULE*) testItem;
// consider only visible modules // consider only visible modules
if( IsModuleLayerVisible( mlayer ) ) if( IsModuleLayerVisible( module->m_Layer ) )
{ {
if( testItem->HitTest( refPos ) ) if( module->HitTest( refPos ) )
{ {
if( layer == mlayer ) if( layer == module->m_Layer )
{ {
found = testItem; found = testItem;
return SEARCH_QUIT; return SEARCH_QUIT;
......
...@@ -27,11 +27,13 @@ ...@@ -27,11 +27,13 @@
D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD ) D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD )
{ {
m_NumPadName = 0; m_NumPadName = 0;
m_Masque_Layer = CUIVRE_LAYER; m_Masque_Layer = CUIVRE_LAYER;
m_NetCode = 0; /* Numero de net pour comparaisons rapides */ m_NetCode = 0; /* Numero de net pour comparaisons rapides */
m_DrillShape = CIRCLE; // Drill shape = circle m_DrillShape = CIRCLE; // Drill shape = circle
m_Size.x = m_Size.y = 500; m_Size.x = m_Size.y = 500;
if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) )
{ {
m_Pos = ( (MODULE*) m_Parent )->m_Pos; m_Pos = ( (MODULE*) m_Parent )->m_Pos;
...@@ -91,7 +93,8 @@ const wxPoint D_PAD::ReturnShapePos( void ) ...@@ -91,7 +93,8 @@ const wxPoint D_PAD::ReturnShapePos( void )
wxPoint shape_pos; wxPoint shape_pos;
int dX, dY; int dX, dY;
dX = m_Offset.x; dY = m_Offset.y; dX = m_Offset.x;
dY = m_Offset.y;
RotatePoint( &dX, &dY, m_Orient ); RotatePoint( &dX, &dY, m_Orient );
...@@ -458,12 +461,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int ...@@ -458,12 +461,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color ); GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color );
} }
}
break; break;
default: default:
break; break;
} }
}
/* Draw the pad hole */ /* Draw the pad hole */
int cx0 = m_Pos.x - offset.x; int cx0 = m_Pos.x - offset.x;
......
This diff is collapsed.
...@@ -336,9 +336,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -336,9 +336,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
bool keep_on_grid = TRUE; bool keep_on_grid = TRUE;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT ) if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = FALSE; keep_on_grid = FALSE;
/* Cursor is left off grid if no block in progress and no moving object */ /* Cursor is left off grid if no block in progress and no moving object */
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK ) if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE; keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem; EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem;
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
keep_on_grid = TRUE; keep_on_grid = TRUE;
......
...@@ -35,7 +35,8 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC ) ...@@ -35,7 +35,8 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
{ {
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos ); WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
} }
......
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
/* fonctions locales */ /* fonctions locales */
EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc ); EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc );
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer );
/** /**
...@@ -390,10 +391,10 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ) ...@@ -390,10 +391,10 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
} }
/*************************************************/ /*************************************************
/* D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer) */ * D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer)
/* D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer) */ * D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer)
/*************************************************/ *************************************************/
/* /*
* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou * localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/****************************/ /****************************/
/* affichage des empreintes */ /* affichage des empreintes */
/****************************/ /****************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -12,160 +12,171 @@ ...@@ -12,160 +12,171 @@
#define Pad_fill (Pad_Fill_Item.State == RUN) #define Pad_fill (Pad_Fill_Item.State == RUN)
static void Pad_Surbrillance(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, int NetCode); static void Pad_Surbrillance( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, int NetCode );
/* variables locales : */ /* variables locales : */
static int draw_mode ; static int draw_mode;
/*********************************************************/ /*********************************************************/
void WinEDA_PcbFrame::Liste_Equipot(wxCommandEvent & event) void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event )
/*********************************************************/ /*********************************************************/
/* Display a filtered list of equipot names /* Display a filtered list of equipot names
if an equipot is selected the corresponding tracks and pads are highlighted * if an equipot is selected the corresponding tracks and pads are highlighted
*/ */
{ {
EQUIPOT * Equipot ; EQUIPOT* Equipot;
wxString msg; wxString msg;
WinEDA_TextFrame * List; WinEDA_TextFrame* List;
int ii, jj; int ii, jj;
msg = wxT("*"); msg = wxT( "*" );
Get_Message(_("Filter for net names:"),msg, this); Get_Message( _( "Filter for net names:" ), msg, this );
if ( msg.IsEmpty() ) return; if( msg.IsEmpty() )
return;
List = new WinEDA_TextFrame(this, _("List Nets") );
List = new WinEDA_TextFrame( this, _( "List Nets" ) );
Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
for ( ; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
{ for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
wxString Line; {
/* calcul adr relative du nom de la pastille reference de la piste */ wxString Line;
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE ) ) continue ; /* calcul adr relative du nom de la pastille reference de la piste */
if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
Line.Printf( wxT("net_code = %3.3d [%.16s] "),Equipot->m_NetCode, continue;
Equipot->m_Netname.GetData());
List->Append(Line); Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), Equipot->m_NetCode,
} Equipot->m_Netname.GetData() );
ii = List->ShowModal(); List->Destroy(); List->Append( Line );
if (ii < 0) return; }
/* Recherche du numero de net rellement selectionn */ ii = List->ShowModal(); List->Destroy();
Equipot = (EQUIPOT*) m_Pcb->m_Equipots; if( ii < 0 )
for ( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) return;
{
/* calcul adr relative du nom de la pastille reference de la piste */ /* Recherche du numero de net rellement selectionn�*/
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE) ) continue ; Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
if ( ii == jj ) for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{ {
ii = Equipot->m_NetCode; /* calcul adr relative du nom de la pastille reference de la piste */
break; if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
} continue;
jj++; if( ii == jj )
} {
ii = Equipot->m_NetCode;
break;
wxClientDC dc(DrawPanel); }
DrawPanel->PrepareGraphicContext(&dc); jj++;
}
if(g_HightLigt_Status) Hight_Light(&dc);
g_HightLigth_NetCode = ii; wxClientDC dc( DrawPanel );
Hight_Light(&dc);
DrawPanel->PrepareGraphicContext( &dc );
if( g_HightLigt_Status )
Hight_Light( &dc );
g_HightLigth_NetCode = ii;
Hight_Light( &dc );
} }
/**************************************************/ /**************************************************/
int WinEDA_PcbFrame::Select_High_Light(wxDC * DC) int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
/**************************************************/ /**************************************************/
/* Localise track ou pad et met en surbrillance le net correspondant /* Localise track ou pad et met en surbrillance le net correspondant
Retourne le netcode, ou -1 si pas de net localis */ * Retourne le netcode, ou -1 si pas de net localis�*/
{ {
TRACK * pt_piste; TRACK* pt_piste;
D_PAD* pt_pad ; D_PAD* pt_pad;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
int code = -1; int code = -1;
if ( g_HightLigt_Status ) Hight_Light(DC); if( g_HightLigt_Status )
pt_piste = Locate_Pistes(m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE); Hight_Light( DC );
if ( pt_piste) pt_piste = Locate_Pistes( m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE );
{ if( pt_piste )
code = g_HightLigth_NetCode = pt_piste->m_NetCode; {
Hight_Light(DC); code = g_HightLigth_NetCode = pt_piste->m_NetCode;
} Hight_Light( DC );
else }
{ else
pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); {
if( pt_pad != NULL ) pt_pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE );
{ if( pt_pad != NULL )
code = g_HightLigth_NetCode = pt_pad->m_NetCode ; {
Hight_Light(DC) ; code = g_HightLigth_NetCode = pt_pad->m_NetCode;
} Hight_Light( DC );
} }
}
return code;
return code;
} }
/*******************************************/ /*******************************************/
void WinEDA_PcbFrame::Hight_Light(wxDC * DC) void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
/*******************************************/ /*******************************************/
/* /*
fonction d'appel de Surbrillance a partir du menu * fonction d'appel de Surbrillance a partir du menu
Met ou supprime la surbrillance d'un net pointe par la souris * Met ou supprime la surbrillance d'un net pointe par la souris
*/ */
{ {
g_HightLigt_Status = !g_HightLigt_Status; g_HightLigt_Status = !g_HightLigt_Status;
DrawHightLight( DC, g_HightLigth_NetCode) ; DrawHightLight( DC, g_HightLigth_NetCode );
} }
/****************************************************************/ /****************************************************************/
void WinEDA_PcbFrame::DrawHightLight(wxDC * DC, int NetCode) void WinEDA_PcbFrame::DrawHightLight( wxDC* DC, int NetCode )
/****************************************************************/ /****************************************************************/
/* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode' /* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode'
*/ */
{ {
TRACK * pts ; TRACK* pts;
MODULE * Module; MODULE* Module;
if(g_HightLigt_Status ) draw_mode = GR_SURBRILL | GR_OR; if( g_HightLigt_Status )
else draw_mode = GR_AND | GR_SURBRILL; draw_mode = GR_SURBRILL | GR_OR;
else
Module = m_Pcb->m_Modules; draw_mode = GR_AND | GR_SURBRILL;
/* Redraw pads */ Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ /* Redraw pads */
Pad_Surbrillance(DrawPanel, DC, Module, NetCode) ; for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
} {
Pad_Surbrillance( DrawPanel, DC, Module, NetCode );
/* Redraw track and vias: */ }
for ( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext)
{ /* Redraw track and vias: */
if( pts->m_NetCode == NetCode ) for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext )
{ {
pts->Draw(DrawPanel, DC, draw_mode); if( pts->m_NetCode == NetCode )
} {
} pts->Draw( DrawPanel, DC, draw_mode );
}
}
} }
/*******************************************************/ /*******************************************************/
static void Pad_Surbrillance(WinEDA_DrawPanel * panel, static void Pad_Surbrillance( WinEDA_DrawPanel* panel,
wxDC * DC, MODULE * Module, int NetCode) wxDC* DC, MODULE* Module, int NetCode )
/*******************************************************/ /*******************************************************/
/* Mise en Surbrillance des Pads */ /* Mise en Surbrillance des Pads */
{ {
D_PAD * pt_pad ; D_PAD* pt_pad;
/* trace des pastilles */ /* trace des pastilles */
for(pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext) for( pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
if ( pt_pad->m_NetCode == NetCode ) if( pt_pad->m_NetCode == NetCode )
{ {
pt_pad->Draw(panel, DC, wxPoint(0,0),draw_mode); pt_pad->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode );
} }
} }
} }
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/* Data to build the layer pair indicator button */ /* Data to build the layer pair indicator button */
static wxBitmap* LayerPairBitmap = NULL; static wxBitmap* LayerPairBitmap = NULL;
static char s_BitmapLayerIcon[16][16] = { static const char s_BitmapLayerIcon[16][16] = {
// 0 = draw pixel with active layer color // 0 = draw pixel with active layer color
// 1 = draw pixel with top layer color (top/bottom layer used in autoroute and place via) // 1 = draw pixel with top layer color (top/bottom layer used in autoroute and place via)
// 2 = draw pixel with bottom layer color // 2 = draw pixel with bottom layer color
......
This diff is collapsed.
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