surbrill.cpp 6.21 KB
Newer Older
1 2 3
/****************************/
/* affichage des empreintes */
/****************************/
4 5 6 7 8 9 10 11

#include "fctsys.h"
#include "gr_basic.h"

#include "common.h"
#include "pcbnew.h"

#include "protos.h"
12 13
#include "collectors.h"

14 15 16

#define Pad_fill (Pad_Fill_Item.State == RUN)

17
static void Pad_Surbrillance( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, int NetCode );
18 19

/* variables locales : */
20
static int draw_mode;
21 22 23


/*********************************************************/
24
void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event )
25
/*********************************************************/
26

27
/* Display a filtered list of equipot names
28 29
 *  if an equipot is selected the corresponding tracks and pads are highlighted
 */
30
{
31 32 33 34 35 36
    EQUIPOT*          Equipot;
    wxString          msg;
    WinEDA_TextFrame* List;
    int ii, jj;

    msg = wxT( "*" );
37
    Get_Message( _( "Filter for net names:" ), _("Net Filter"), msg, this );
38 39 40 41 42 43
    if( msg.IsEmpty() )
        return;

    List = new WinEDA_TextFrame( this, _( "List Nets" ) );

    Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
44
    for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Next() )
45 46 47 48 49 50
    {
        wxString Line;
        /* calcul adr relative du nom de la pastille reference de la piste */
        if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
            continue;

51
        Line.Printf( wxT( "net_code = %3.3d  [%.16s] " ), Equipot->GetNet(),
52 53 54 55
                    Equipot->m_Netname.GetData() );
        List->Append( Line );
    }

dickelbeck's avatar
dickelbeck committed
56 57 58 59
    ii = List->ShowModal();

    List->Destroy();

60 61 62 63 64
    if( ii < 0 )
        return;

    /* Recherche du numero de net rellement selectionn�*/
    Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
65
    for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Next() )
66 67 68 69
    {
        /* calcul adr relative du nom de la pastille reference de la piste */
        if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
            continue;
dickelbeck's avatar
dickelbeck committed
70

71 72
        if( ii == jj )
        {
73
            ii = Equipot->GetNet();
74 75 76 77 78 79 80 81 82 83 84
            break;
        }
        jj++;
    }

    wxClientDC dc( DrawPanel );

    DrawPanel->PrepareGraphicContext( &dc );

    if( g_HightLigt_Status )
        Hight_Light( &dc );
dickelbeck's avatar
dickelbeck committed
85

86 87
    g_HightLigth_NetCode = ii;
    Hight_Light( &dc );
88 89 90 91
}


/**************************************************/
92
int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
93
/**************************************************/
94

95
/* Localise track ou pad et met en surbrillance le net correspondant
96
 *  Retourne le netcode, ou -1 si pas de net localis�*/
97
{
98 99
    if( g_HightLigt_Status )
        Hight_Light( DC );
dickelbeck's avatar
dickelbeck committed
100

101 102
    // use this scheme because of pad is higher priority than tracks in the
    // search, and finding a pad, instead of a track on a pad,
dickelbeck's avatar
dickelbeck committed
103
    // allows us to fire a message to eeschema.
104 105 106

    GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();

dickelbeck's avatar
dickelbeck committed
107

108
    // optionally, modify the "guide" here as needed using its member functions
dickelbeck's avatar
dickelbeck committed
109 110 111


    m_Collector->Collect( m_Pcb, GENERAL_COLLECTOR::PadsTracksOrZones,
112 113 114
                         GetScreen()->RefPos( true ), guide );

    BOARD_ITEM* item = (*m_Collector)[0];
dickelbeck's avatar
dickelbeck committed
115

116
    if( item )
117
    {
118
        switch( item->Type() )
119
        {
120
        case TYPE_PAD:
121
            g_HightLigth_NetCode = ((D_PAD*)item)->GetNet();
122
            Hight_Light( DC );
123 124
            SendMessageToEESCHEMA( item );
            return g_HightLigth_NetCode;
dickelbeck's avatar
dickelbeck committed
125

126 127 128
        case TYPE_TRACK:
        case TYPE_VIA:
        case TYPE_ZONE:
129 130
            // since these classes are all derived from TRACK, use a common
            // GetNet() function:
131 132 133
            g_HightLigth_NetCode = ((TRACK*)item)->GetNet();
            Hight_Light( DC );
            return g_HightLigth_NetCode;
dickelbeck's avatar
dickelbeck committed
134

135
        case TYPE_ZONE_CONTAINER:
dickelbeck's avatar
dickelbeck committed
136 137 138 139
            g_HightLigth_NetCode = ((ZONE_CONTAINER*)item)->GetNet();
            Hight_Light( DC );
            return g_HightLigth_NetCode;

140 141 142
        default:
            ;   // until somebody changes GENERAL_COLLECTOR::PadsOrTracks,
                // this should not happen.
143 144
        }
    }
dickelbeck's avatar
dickelbeck committed
145

146
    return -1;      // HitTest() failed.
147 148 149 150
}


/*******************************************/
151
void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
152
/*******************************************/
153

154
/*
155 156 157
 *  fonction d'appel de Surbrillance a partir du menu
 *  Met ou supprime la surbrillance d'un net pointe par la souris
 */
158
{
159 160
    g_HightLigt_Status = !g_HightLigt_Status;
    DrawHightLight( DC, g_HightLigth_NetCode );
161 162 163 164
}


/****************************************************************/
165
void WinEDA_PcbFrame::DrawHightLight( wxDC* DC, int NetCode )
166
/****************************************************************/
167

168
/* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode'
169
 */
170
{
171 172 173 174 175
    if( g_HightLigt_Status )
        draw_mode = GR_SURBRILL | GR_OR;
    else
        draw_mode = GR_AND | GR_SURBRILL;

dickelbeck's avatar
dickelbeck committed
176 177 178
#if 0   // does not unhighlight properly
    // redraw the zones with the NetCode
    for( SEGZONE* zone = m_Pcb->m_Zone;   zone;   zone = zone->Next() )
179
    {
dickelbeck's avatar
dickelbeck committed
180
        if( zone->GetNet() == NetCode )
181
        {
dickelbeck's avatar
dickelbeck committed
182
            zone->Draw( DrawPanel, DC, draw_mode );
183 184
        }
    }
dickelbeck's avatar
dickelbeck committed
185
#endif
dickelbeck's avatar
dickelbeck committed
186 187 188 189 190 191 192

    // Redraw ZONE_CONTAINERS
    BOARD::ZONE_CONTAINERS& zones = m_Pcb->m_ZoneDescriptorList;
    for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin();  zc!=zones.end();  ++zc )
    {
        if( (*zc)->GetNet() == NetCode )
        {
dickelbeck's avatar
dickelbeck committed
193
            (*zc)->Draw( DrawPanel, DC, draw_mode );
dickelbeck's avatar
dickelbeck committed
194 195
        }
    }
dickelbeck's avatar
dickelbeck committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210

    /* Redraw pads */
    for( MODULE* module = m_Pcb->m_Modules;  module;   module = module->Next() )
    {
        Pad_Surbrillance( DrawPanel, DC, module, NetCode );
    }

    /* Redraw track and vias: */
    for( TRACK* pts = m_Pcb->m_Track;   pts;   pts = pts->Next() )
    {
        if( pts->GetNet() == NetCode )
        {
            pts->Draw( DrawPanel, DC, draw_mode );
        }
    }
211 212 213 214
}


/*******************************************************/
215 216
static void Pad_Surbrillance( WinEDA_DrawPanel* panel,
                              wxDC* DC, MODULE* Module, int NetCode )
217 218 219
/*******************************************************/
/* Mise en Surbrillance des Pads */
{
220 221 222
    D_PAD* pt_pad;

    /* trace des pastilles */
223
    for( pt_pad = Module->m_Pads;  pt_pad;  pt_pad = pt_pad->Next() )
224
    {
225
        if( pt_pad->GetNet() == NetCode )
226
        {
dickelbeck's avatar
dickelbeck committed
227
            pt_pad->Draw( panel, DC, draw_mode );
228 229
        }
    }
230
}