Commit 8a8377ff authored by dickelbeck's avatar dickelbeck
Browse files

beautification, hit test improvements

parent ea6aba82
Loading
Loading
Loading
Loading
+1098 −1015

File changed.

Preview size limit exceeded, changes collapsed.

+19 −8
Original line number Original line Diff line number Diff line
@@ -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 )
    
    
            if( testItem->m_StructType == TYPEPAD )
            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;
                        found = testItem;
                        return SEARCH_QUIT;
                        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;
+10 −6
Original line number Original line Diff line number Diff line
@@ -31,7 +31,9 @@ D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD )
    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 )
    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


            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;
+862 −790

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Original line Diff line number Diff line
@@ -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;
Loading