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 )
public:
EDA_BaseStruct* found;
int layer;
int layer_mask;
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 )
......@@ -343,23 +344,33 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
if( testItem->m_StructType == TYPEPAD )
{
if( testItem->HitTest( refPos ) )
D_PAD* pad = (D_PAD*) testItem;
if( pad->HitTest( refPos ) )
{
if( layer_mask & pad->m_Masque_Layer )
{
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 )
{
int mlayer = ((MODULE*)testItem)->m_Layer;
MODULE* module = (MODULE*) testItem;
// 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;
return SEARCH_QUIT;
......
......@@ -31,7 +31,9 @@ D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD )
m_Masque_Layer = CUIVRE_LAYER;
m_NetCode = 0; /* Numero de net pour comparaisons rapides */
m_DrillShape = CIRCLE; // Drill shape = circle
m_Size.x = m_Size.y = 500;
if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) )
{
m_Pos = ( (MODULE*) m_Parent )->m_Pos;
......@@ -91,7 +93,8 @@ const wxPoint D_PAD::ReturnShapePos( void )
wxPoint shape_pos;
int dX, dY;
dX = m_Offset.x; dY = m_Offset.y;
dX = m_Offset.x;
dY = m_Offset.y;
RotatePoint( &dX, &dY, m_Orient );
......@@ -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 );
}
}
break;
default:
break;
}
}
/* Draw the pad hole */
int cx0 = m_Pos.x - offset.x;
......
This diff is collapsed.
......@@ -336,9 +336,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
bool keep_on_grid = TRUE;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = FALSE;
/* Cursor is left off grid if no block in progress and no moving object */
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem;
if( DrawStruct && DrawStruct->m_Flags )
keep_on_grid = TRUE;
......
......@@ -35,7 +35,8 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
{
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 @@
/* fonctions locales */
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 )
}
/*************************************************/
/* 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 typeloc, 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
......
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 "gr_basic.h"
......@@ -12,51 +12,57 @@
#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 : */
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
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 ;
wxString msg;
WinEDA_TextFrame * List;
int ii, jj;
EQUIPOT* Equipot;
wxString msg;
WinEDA_TextFrame* List;
int ii, jj;
msg = wxT("*");
Get_Message(_("Filter for net names:"),msg, this);
if ( msg.IsEmpty() ) return;
msg = wxT( "*" );
Get_Message( _( "Filter for net names:" ), msg, this );
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 )
for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{
wxString Line;
/* calcul adr relative du nom de la pastille reference de la piste */
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE ) ) continue ;
if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
continue;
Line.Printf( wxT("net_code = %3.3d [%.16s] "),Equipot->m_NetCode,
Equipot->m_Netname.GetData());
List->Append(Line);
Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), Equipot->m_NetCode,
Equipot->m_Netname.GetData() );
List->Append( Line );
}
ii = List->ShowModal(); List->Destroy();
if (ii < 0) return;
if( ii < 0 )
return;
/* Recherche du numero de net rellement selectionn */
/* Recherche du numero de net rellement selectionn�*/
Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
for ( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext )
for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{
/* calcul adr relative du nom de la pastille reference de la piste */
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE) ) continue ;
if ( ii == jj )
if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
continue;
if( ii == jj )
{
ii = Equipot->m_NetCode;
break;
......@@ -64,41 +70,44 @@ int ii, jj;
jj++;
}
wxClientDC dc( DrawPanel );
wxClientDC dc(DrawPanel);
DrawPanel->PrepareGraphicContext(&dc);
DrawPanel->PrepareGraphicContext( &dc );
if(g_HightLigt_Status) Hight_Light(&dc);
if( g_HightLigt_Status )
Hight_Light( &dc );
g_HightLigth_NetCode = ii;
Hight_Light(&dc);
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
Retourne le netcode, ou -1 si pas de net localis */
* Retourne le netcode, ou -1 si pas de net localis�*/
{
TRACK * pt_piste;
D_PAD* pt_pad ;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
int code = -1;
if ( g_HightLigt_Status ) Hight_Light(DC);
pt_piste = Locate_Pistes(m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE);
if ( pt_piste)
TRACK* pt_piste;
D_PAD* pt_pad;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
int code = -1;
if( g_HightLigt_Status )
Hight_Light( DC );
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);
Hight_Light( DC );
}
else
{
pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE);
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 );
}
}
......@@ -107,65 +116,67 @@ int code = -1;
/*******************************************/
void WinEDA_PcbFrame::Hight_Light(wxDC * DC)
void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
/*******************************************/
/*
fonction d'appel de Surbrillance a partir du menu
Met ou supprime la surbrillance d'un net pointe par la souris
*/
* fonction d'appel de Surbrillance a partir du menu
* Met ou supprime la surbrillance d'un net pointe par la souris
*/
{
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'
*/
*/
{
TRACK * pts ;
MODULE * Module;
TRACK* pts;
MODULE* Module;
if(g_HightLigt_Status ) draw_mode = GR_SURBRILL | GR_OR;
else draw_mode = GR_AND | GR_SURBRILL;
if( g_HightLigt_Status )
draw_mode = GR_SURBRILL | GR_OR;
else
draw_mode = GR_AND | GR_SURBRILL;
Module = m_Pcb->m_Modules;
/* Redraw pads */
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
Pad_Surbrillance(DrawPanel, DC, Module, NetCode) ;
Pad_Surbrillance( DrawPanel, DC, Module, NetCode );
}
/* Redraw track and vias: */
for ( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext)
for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext )
{
if( pts->m_NetCode == NetCode )
{
pts->Draw(DrawPanel, DC, draw_mode);
pts->Draw( DrawPanel, DC, draw_mode );
}
}
}
/*******************************************************/
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 )
/*******************************************************/
/* Mise en Surbrillance des Pads */
{
D_PAD * pt_pad ;
D_PAD* pt_pad;
/* 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 @@
/* Data to build the layer pair indicator button */
static wxBitmap* LayerPairBitmap = NULL;
static char s_BitmapLayerIcon[16][16] = {
static const char s_BitmapLayerIcon[16][16] = {
// 0 = draw pixel with active layer color
// 1 = draw pixel with top layer color (top/bottom layer used in autoroute and place via)
// 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